added defaulttty.c
[util-vserver.git] / util-vserver / scripts / vserver.stop
index 878a163..129ce0b 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+
+lock "$LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
+
 if ! isVserverRunning "$VSERVER_DIR" S_CONTEXT; then
-    echo $"vserver '$VSERVER_NAME' is not running; aborting..." >&2
+    warning $"vserver '$VSERVER_NAME' is not running" >&2
     test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
     umountVserver     "$VSERVER_DIR" || :
     disableInterfaces "$VSERVER_DIR" || :
-    exit 1
+    unlock
+    exit 0
 fi
 
 function cleanup
 {
+    set +e
+    unlock
+    
     test ! -p "$sync_fifo" || {
        rm -f "$sync_fifo"
        rmdir $(dirname "$sync_fifo")
@@ -40,11 +47,14 @@ set +e
 
 vshelper.doDestroy "$VSERVER_DIR" "$S_CONTEXT"
 initSync           "$VSERVER_DIR" sync_fifo
+prepareStop "$VSERVER_DIR"
 
 cd "$VSERVER_DIR"/vdir/
 execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" pre-stop
 cd "$VSERVER_DIR"/vdir/
 
+test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
+
 fail=
 if test "$_IS_FAKEINIT" && \
    $_VSERVER_INFO - FEATURE vkill && \