use 'killContext()' instead of invoking 'vkill' manually
[util-vserver.git] / util-vserver / scripts / vserver.functions
index 4f26737..5877853 100644 (file)
@@ -164,7 +164,7 @@ function getEnterShell
 
     ENTER_SHELL=()
 
-    getFileValue ENTER_SHELL "$vdir"/shell "$CONFDIR"/.defaults/shell
+    getFileValue ENTER_SHELL "$vdir"/shell "$__CONFDIR"/.defaults/shell
     
     test -n "$ENTER_SHELL" || {
        local i
@@ -186,8 +186,8 @@ function sendKillSequence
 
     while isCtxRunning "$ctx"; do
        test -z "$wait" || sleep "$wait"
-       
-       $_VKILL -c "$ctx" ${1:+-s "$1"} 2>/dev/null || :
+
+       killContext "$ctx" "$1"
        test -n "$2" || break
        wait="$2"
        shift 2
@@ -245,8 +245,9 @@ function _generateInitOptions
            _IS_FAKEINIT=1
            INITCMD_START_SYNC=( "$_INITSYNC_MINIT_START" "$vdir" )
            _NEED_VSHELPER_SYNC=1
-           test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
-           test -z "$RUNLEVEL_STOP"  || INITCMD_STOP=(  "${INITCMD_STOP[@]}"  "$RUNLEVEL_STOP"  )
+           test -z "$RUNLEVEL_START"         || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
+           test -z "$RUNLEVEL_STOP"          || INITCMD_STOP=(  "${INITCMD_STOP[@]}"  "$RUNLEVEL_STOP"  )
+           ! isNumber "${RUNLEVEL_START:-3}" || INITCMD_PREPARE=( $_FAKE_RUNLEVEL "${RUNLEVEL_START:-3}" /var/run/utmp )
            ;;
 
        (xgentoo)
@@ -513,7 +514,7 @@ function enableInterfaces
     local i=0
     declare -a var
 
-    lock "$LOCKDIR"/vserver.interfaces
+    lock "$__LOCKDIR"/vserver.interfaces
 
     while test $i -lt $INTERFACE_CMDS_IDX; do
        eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
@@ -551,7 +552,7 @@ function disableInterfaces
     local i=$INTERFACE_CMDS_IDX
     declare -a var
 
-    lock "$LOCKDIR"/vserver.interfaces
+    lock "$__LOCKDIR"/vserver.interfaces
     
     while test $i -gt 0; do
        let --i || :
@@ -660,7 +661,7 @@ function mountVserver
          -e "$cfgdir"/fstab.local -o \
         -e "$cfgdir"/fstab.remote || return 0
 
-    findObject -r mtab_src "$vdir"/apps/init/mtab "$CONFDIR"/.defaults/init/mtab "$PKGLIBDEFAULTDIR"/mtab /dev/null
+    findObject -r mtab_src "$cfgdir"/apps/init/mtab "$__CONFDIR"/.defaults/init/mtab "$__PKGLIBDEFAULTDIR"/mtab /dev/null
     
     pushd "$vdir" >/dev/null
     $_CHROOT_CAT /etc/mtab <"$mtab_src"
@@ -722,7 +723,10 @@ function umountVserver
 ## Usage: waitForSync <vserver> <vshelper-fifo-varname>
 function initSync
 {
-    test -z "$_NEED_VSHELPER_SYNC" || vshelper.initSync "$1" "$2"
+    local _is_meth=sync
+    test -n "$_NEED_VSHELPER_SYNC" || _is_meth=async
+
+    vshelper.initSync "$1" "$2" "$_is_meth"
 }
 
 ## Usage: waitForSync <vserver> [<vshelper-fifo>]
@@ -737,7 +741,7 @@ function waitForSync
 A timeout or other error occured while waiting for the synchronization
 signal from vserver '$VSERVER_NAME'.
 The vserver will be killed nevertheless..."
-    elif test -n "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
+    elif test "${#INITCMD_STOP_SYNC[@]}" -ne 0; then
        "${INITCMD_STOP_SYNC[@]}" || \
            warning $"\
 Stop-synchronization for vserver '$VSERVER_NAME' failed. The vserver
@@ -762,7 +766,7 @@ function execScriptlets
     declare -r flavor=$3
     local base i
 
-    for base in "$vdir"/scripts "$CONFDIR"/.defaults/scripts; do
+    for base in "$vdir"/scripts "$__CONFDIR"/.defaults/scripts; do
        local   DONT_SKIP_DEFAULTS=
        local   already_handled=