added locking
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 8 May 2004 01:33:11 +0000 (01:33 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 8 May 2004 01:33:11 +0000 (01:33 +0000)
call setDefaultTTY() correctly

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1550 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/vserver.start
util-vserver/scripts/vserver.stop

index 10aab16..f049d83 100644 (file)
@@ -15,6 +15,8 @@
 # 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."$(echo "$VSERVER_DIR" | tr -dc a-zA-Z0-9)".startup
+
 if isVserverRunning "$VSERVER_DIR"; then
     echo $"vserver '$VSERVER_NAME' already running; aborting..." >&2
     exit 1
@@ -22,8 +24,10 @@ fi
 
 function cleanup()
 {
+    set +e
+
     test -z "$startsync_pipe"  || rm -f "$startsync_pipe"
-    test -z "$is_started"      || return 0
+    test -z "$is_started"      || { unlock; return 0; }
 
     if test "$is_configured" -a -z "$is_executed"; then
        warning $"
@@ -55,6 +59,8 @@ Failed to start vserver '$VSERVER_NAME'"
     test    "$OPTION_DEBUG"    || exec 2>/dev/null >/dev/null
     test -z "$is_mounted"      || umountVserver     "$VSERVER_DIR" || :
     test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || :
+
+    unlock || :
 }
 
 is_configured=
@@ -81,7 +87,7 @@ pushd "$VSERVER_DIR"/vdir/ >/dev/null
 execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" pre-start
 popd >/dev/null
 
-test -z "$OPTION_DEFAULTTTY" || setDefaultTTY
+test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
 
 pushd "$VSERVER_DIR"/vdir/ >/dev/null
 is_configured=1
index 82e7aa6..b2365fe 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."$(echo "$VSERVER_DIR" | tr -dc a-zA-Z0-9)".startup
+
 if ! isVserverRunning "$VSERVER_DIR" S_CONTEXT; then
     echo $"vserver '$VSERVER_NAME' is not running; aborting..." >&2
     test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
     umountVserver     "$VSERVER_DIR" || :
     disableInterfaces "$VSERVER_DIR" || :
+    unlock
     exit 1
 fi
 
 function cleanup
 {
+    set +e
+    unlock
+    
     test ! -p "$sync_fifo" || {
        rm -f "$sync_fifo"
        rmdir $(dirname "$sync_fifo")
@@ -45,7 +52,7 @@ cd "$VSERVER_DIR"/vdir/
 execScriptlets    "$VSERVER_DIR" "$VSERVER_NAME" pre-stop
 cd "$VSERVER_DIR"/vdir/
 
-test -z "$OPTION_DEFAULTTTY" || setDefaultTTY
+test -z "$OPTION_DEFAULTTTY" || setDefaultTTY "$VSERVER_DIR"
 
 fail=
 if test "$_IS_FAKEINIT" && \