applied http://vserver.lauft.net/wegen/util-vserver/patches/merge/util-vserver--merge...
[util-vserver.git] / util-vserver / scripts / vshelper
index 538d210..fc6ee6f 100755 (executable)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /usr/lib/util-vserver/sigexec /bin/bash
 
 # Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
 #  
@@ -54,11 +54,11 @@ function doInternalMethod
            case "$ACTION" in
                (restart)
                    logging $"Restarting vserver '$VSERVER'"
-                   execute $_VSERVER "$VSERVER" restart
+                   execute $_VSERVER --defaulttty "$VSERVER" restart
                    ;;
                (halt|poweroff)
                    logging $"Stopping vserver '$VSERVER'"
-                   execute $_VSERVER "$VSERVER" stop
+                   execute $_VSERVER --defaulttty "$VSERVER" stop
                    ;;
                (swsusp)
                    ## TODO: any senseful action here? Perhaps shutdown scheduler for it?
@@ -73,7 +73,7 @@ function doInternalMethod
            
        (sync)
            local f=${METHOD_ARGS[0]}
-           test "$f" ||
+           test -n "$f" ||
                panic $"Insufficent arguments for method '$method' and vserver '$VSERVER'"
 
            test -p "$f" ||
@@ -86,7 +86,7 @@ function doInternalMethod
            local script
            findObject -x script "$CONFDIR"/.defaults/apps/vshelper-methods/"$method" "$PKGLIBDIR"/vshelper-methods/"$method" ''
            
-           test '$script' || {
+           test -n '$script' || {
                warning $"No handler for internal method '$method' found"
                exit 1
            }
@@ -130,6 +130,7 @@ 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,6 +144,8 @@ else
     panic $"vshelper functionality not supported by kernel"
 fi
 
+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)
 pxid=
@@ -150,11 +153,11 @@ responsible_xid=$XID
 while true; do
     pxid=$($_VSERVER_INFO "$responsible_xid" PXID) || break
     test "$pxid" -ne "$this_xid"                   || break
-    xid=$responsible_xid
+    responsible_xid=$pxid
 done
 
 vserver_id=$($_VSERVER_INFO "$responsible_xid" ID) ||
-    panic $"No responsible vserver found for resonsible xid '$responsible_xid' ($XID); aborting..."
+    panic $"No responsible vserver found for xid '$responsible_xid' ($XID); aborting..."
     
 test "$XID" = "$responsible_xid" || {
     logging "Giving 'vshelper' task for '$XID' to parent vserver '$vserver_id' ($responsible_xid)"