do not quote $_VSHELPER in help message (reported by Roman Barczynski,
[util-vserver.git] / util-vserver / scripts / vshelper
index ae36f6d..2bd6ed1 100755 (executable)
@@ -54,10 +54,12 @@ function doInternalMethod
            case "$ACTION" in
                (restart)
                    logging $"Restarting vserver '$VSERVER'"
+                   spawn   killContext "$XID"
                    execute $_VSERVER --defaulttty "$VSERVER" restart
                    ;;
                (halt|poweroff)
                    logging $"Stopping vserver '$VSERVER'"
+                   spawn   killContext "$XID"
                    execute $_VSERVER --defaulttty "$VSERVER" stop
                    ;;
                (swsusp)
@@ -70,6 +72,10 @@ function doInternalMethod
                    exit 1
            esac
            ;;
+
+       (async)
+           spawn killContext "$XID"
+           ;;
            
        (sync)
            local f=${METHOD_ARGS[0]}
@@ -79,12 +85,13 @@ function doInternalMethod
            test -p "$f" ||
                panic $"File '$f' which is required for synchronisation of vserver '$VSERVER' is not a pipe"
 
+           spawn killContext "$XID"
            echo "$ACTION" >"$f"
            ;;
 
        (*)
            local script
-           findObject -x script "$CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$PKGLIBDIR"/vshelper-methods/"$method" ''
+           findObject -x script "$__CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$__PKGLIBDIR"/vshelper-methods/"$method" ''
            
            test -n '$script' || {
                warning $"No handler for internal method '$method' found"
@@ -113,23 +120,26 @@ function doDefaultMethod
 
 #===========
 
+test "$1" != '--version' || showVersion
+test "$1" != '--help'    || showHelp
+
 if ! tty -s; then
-    findObject -e _VS_LOGFILE "$CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
-    findObject -e _VS_ERRFILE "$CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
+    findObject -e _VS_LOGFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
+    findObject -e _VS_ERRFILE "$__CONFDIR"/.defaults/apps/vshelper/logfile /dev/null
 
     exec   </dev/null
     exec  >>$_VS_LOGFILE
     exec 2>>$_VS_ERRFILE
 fi
-    
-logging "$(date): vshelper $*"
 
-test "$1" != '--version' || showVersion
-test "$1" != '--help'    || showHelp
+logging "$(date): vshelper $*"
+    
 test "$#" -ge 2 ||
     panic $"vshelper called with missing arguments; try '--help' for more information"
 
+    
 vshelper.isEnabled || exit 0
+! vshelper.isDebug || set -x
     
 set -eu
 
@@ -143,7 +153,7 @@ else
     panic $"vshelper functionality not supported by kernel"
 fi
 
-findObject -x delegate "$CONFDIR"/.defaults/apps/vshelper-delegate/"$ACTION" "$PKGLIBDIR"/vshelper-delegate/"$ACTION" ''
+findObject -x delegate "$__CONFDIR"/.defaults/apps/vshelper-delegate/"$ACTION" "$__PKGLIBDIR"/vshelper-delegate/"$ACTION" ''
 test -e "$delegate" && exec -a "$ACTION" "$delegate" "$@"
 
 this_xid=$($_VSERVER_INFO - XID)
@@ -168,7 +178,7 @@ test "$XID" = "$responsible_xid" || {
 ARGS=( "$@" )
 
 declare -a state
-getFileArray state "$VSHELPERSTATEDIR/$XID" && test ${#state[@]} -ge 2 || {
+getFileArray state "$__VSHELPERSTATEDIR/$XID" && test ${#state[@]} -ge 2 || {
     logging "'vshelper' not configured for xid '$XID'"
     exit 0
 }