OSDN Git Service

Addition of a new log function
authorniwa-hideyuki <niwa.niwa@nifty.ne.jp>
Sat, 2 Apr 2016 02:12:07 +0000 (11:12 +0900)
committerniwa-hideyuki <niwa.niwa@nifty.ne.jp>
Sat, 2 Apr 2016 02:12:07 +0000 (11:12 +0900)
src/cmd/slot-os
src/lib/lib-image-catalog
src/subcmd/br-add
src/subcmd/console
src/subcmd/erase
src/subcmd/restart
src/subcmd/resume
src/subcmd/start
src/subcmd/stop
src/subcmd/suspend

index 09b2c31..66c4e32 100755 (executable)
@@ -7,15 +7,22 @@ umask 022
 
 LOGFILE=/var/log/fulcon/slot-os.log
 
-print_log()
+print_log1()
+{
+       EXLINE=$*
+       DATETIME=`date "+%m%d:%H%M%S"`
+       echo $DATETIME ":" slot-os $EXLINE >> $LOGFILE
+}
+
+print_log2()
 {
        EXLINE=$*
        while read l
        do
-               echo $l
+               echo $l 1>&2
                echo $l | egrep "^error:" >& /dev/null
                if [ $? -eq 0 ]; then
-                       DATETIME=`date "+%Y%m%d%H%M%S"`
+                       DATETIME=`date "+%m%d:%H%M%S"`
                        echo $DATETIME ":" slot-os $EXLINE ":" $l >> $LOGFILE
                fi
        done
@@ -56,8 +63,32 @@ if [ $# -eq 0 ] ; then
 else
   if [ -f /usr/lib/slot-os/sbin/$1 ]; then
     EXLINE=`echo /usr/lib/slot-os/sbin/$* | sed -e 's/\$//g' -e 's/\`//g' -e "s/'//g" -e 's/\"//g' -e 's/;//g' -e 's/&//g' -e 's/|//g'`
-#    . $EXLINE |& print_log $*
-    . $EXLINE
+    case $1 in
+    "start" ) print_log1 $* ;;
+    "stop"  ) print_log1 $* ;;
+    "restart" ) print_log1 $* ;;
+    "suspend" ) print_log1 $* ;;
+    "resume" ) print_log1 $* ;;
+    "backup" ) print_log1 $* ;;
+    "backup-del" ) print_log1 $* ;;
+    "backup-restore" ) print_log1 $* ;;
+    "update" ) print_log1 $* ;;
+    "update-prog" ) print_log1 $* ;;
+    "update-deploy" ) print_log1 $* ;;
+    esac
+
+    case $1 in
+    "console" ) . $EXLINE ;;
+    "list" ) . $EXLINE ;;
+    "autostart" ) . $EXLINE ;;
+    "help" ) . $EXLINE ;;
+    "list" ) . $EXLINE ;;
+    "backup-list" ) . $EXLINE ;;
+    "br-info" ) . $EXLINE ;;
+    "net-info" ) . $EXLINE ;;
+    * ) . $EXLINE | print_log2 $* ;;
+    esac
+
   else
     echo "error: unknown command:" $1
   fi
index 4b94ddb..46e75fa 100755 (executable)
@@ -4,7 +4,7 @@
 
 ls /var/lib/fulcon/driver/dockerfile/* >& /dev/null
 if [ $? -ne 0 ]; then 
-       echo "there is not a image"
+       echo "error: there is not a image"
        exit -1
 fi
 
index 6e38173..e1d5baa 100755 (executable)
@@ -55,7 +55,7 @@ fi
 if [ x"$NETDEV" != x"" ]; then
        ip a show $NETDEV >& /dev/null
        if [ $? -ne 0 ]; then
-               echo "can't find a NET_DEVICE:" $NETDEV
+               echo "error: can't find a NET_DEVICE:" $NETDEV
                exit -1
        fi
 fi
index 432e383..16e072f 100755 (executable)
@@ -35,7 +35,7 @@ if [ $FLG_N -eq 1 ]; then
                        N=`printf "%04d" $i`
                        ST=`fulcon list | awk '{if ($1 == "'$NAME$N'") {if ($2 == "RUNNING"){print 0} else {print 1}}}'`
                        if [ x"$ST" != x"0" ]; then
-                               echo $NAME$N "is not running"
+                               echo "error:" $NAME$N "is not running"
                        else    
                                gnome-terminal -e "lib-console $OPT_FLG $NAME$N" >& /dev/null
                                if [ $? -ne 0 ]; then
@@ -67,7 +67,7 @@ for i in $NAMES
 do
        ST=`fulcon list | awk '{if ($1 == "'$i'") {if ($2 == "RUNNING"){print 0} else {print 1}}}'`
        if [ x"$ST" != x"0" ]; then
-               echo $i "is not running"
+               echo "error:" $i "is not running"
 
        else
                lib-console $OPT_FLG $i
index c775918..7e44fd2 100755 (executable)
@@ -40,7 +40,7 @@ if [ $FLG_N -eq 1 ]; then
                done;
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi
 
index 7639d53..7609d2f 100755 (executable)
@@ -61,7 +61,7 @@ if [ $FLG_N -eq 1 ]; then
                done;
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi
 
index ebe8eba..0364858 100755 (executable)
@@ -42,7 +42,7 @@ if [ $FLG_N -eq 1 ]; then
                done;
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi
 
index 358105f..b831a29 100755 (executable)
@@ -58,7 +58,7 @@ if [ $FLG_N -eq 1 ]; then
                done;
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi
 
index ecedc19..38e74be 100755 (executable)
@@ -40,7 +40,7 @@ if [ $FLG_N -eq 1 ]; then
                echo stop $NAME$N
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi
 
index 9fe88c1..3661f1e 100755 (executable)
@@ -42,7 +42,7 @@ if [ $FLG_N -eq 1 ]; then
                done;
                exit 0
        else
-               echo "REPEAT_NUMBER must be [1...999]"
+               echo "error: REPEAT_NUMBER must be [1...999]"
                exit -1
        fi