added documentation about failure reasons
[util-vserver.git] / util-vserver / scripts / vserver.stop
index 8ebdf90..b117826 100644 (file)
@@ -17,8 +17,9 @@
 
 if ! isVserverRunning "$VSERVER_DIR" S_CONTEXT; then
     echo $"vserver '$VSERVER_NAME' is not running; aborting..." >&2
-    umountVserver     "$VSERVER_DIR" &>/dev/null || :
-    disableInterfaces "$VSERVER_DIR" &>/dev/null || :
+    test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
+    umountVserver     "$VSERVER_DIR" || :
+    disableInterfaces "$VSERVER_DIR" || :
     exit 1
 fi
 
@@ -31,7 +32,12 @@ execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" pre-stop
 
 cd "$VSERVER_DIR"/vdir/
 
-if $_VSERVER_INFO - FEATURE migrate; then
+if test "$_IS_FAKEINIT" && \
+   $_VSERVER_INFO - FEATURE vkill && \
+   initpid=$($_VSERVER_INFO "$S_CONTEXT" INITPID 2>/dev/null); then
+    $_VKILL -s INT -- "$initpid" && "${INITCMD_STOP_SYNC[@]}" || :
+elif $_VSERVER_INFO - FEATURE migrate; then
+    "${NICE_CMD[@]}" \
     ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" -- } \
     $_VCONTEXT $SILENT_OPT --migrate --chroot --xid "$S_CONTEXT" -- \
     "${INITCMD_STOP[@]}" && "${INITCMD_STOP_SYNC[@]}" || :
@@ -47,6 +53,10 @@ fi
 
 sendKillSequence  "$S_CONTEXT" "${INITKILL_SEQ[@]}"
 
+## Small hack... isVserverRunning removes stale runfiles as a sideeffect
+! isVserverRunning  "$VSERVER_DIR" || \
+    echo $"Vserver '$VSERVER_DIR' still running unexpectedly; please investigate it manually..." >&2
+
 execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" post-stop
     
 umountVserver     "$VSERVER_DIR" || :