Rather than keeping an unnecessary mount around just because it was the cwd, cd to...
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 8 Dec 2006 13:28:02 +0000 (13:28 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 8 Dec 2006 13:28:02 +0000 (13:28 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2418 94cd875c-1c1d-0410-91d2-eb244daf1a30

scripts/functions
scripts/vserver
scripts/vserver.functions

index 8f73ec8..61dbd00 100644 (file)
@@ -268,13 +268,27 @@ function unlock
     _VS_LOCKS="$@"
 }
 
+function get_init_cwd
+{
+    if test -n "$INIT_CWD"; then
+       echo "$INIT_CWD"
+    else
+       pwd
+    fi
+}
+function set_init_cwd
+{
+    INIT_CWD="`pwd`"
+    export INIT_CWD
+}
+
 function _getVserverDir
 {
     local vserver="$1"
     case "$vserver" in
-       ./*) VSERVER_DIR=`pwd`/$vserver     ;;
-       /*)  VSERVER_DIR=$vserver           ;;
-       *)   VSERVER_DIR=$__CONFDIR/$vserver;;
+       ./*) VSERVER_DIR="`get_init_cwd`/$vserver";;
+       /*)  VSERVER_DIR="$vserver"               ;;
+       *)   VSERVER_DIR="$__CONFDIR/$vserver"    ;;
     esac
 }
 
index db03034..f4080a6 100755 (executable)
@@ -206,6 +206,9 @@ test "$2" != enter -a "$2" != stop || \
     ! isVserverRunning "$VSERVER_DIR" || \
     exec $_VNAMESPACE --enter "$VSERVER_DIR" -- $_VSERVER ----nonamespace "${OPTIONS_ORIG[@]}"
 
+set_init_cwd
+cd /
+
 . $__PKGLIBDIR/vserver.functions
 case "$2" in
     (start|stop|delete)
index 260bd6e..6d25458 100644 (file)
@@ -1199,7 +1199,7 @@ function _namespaceCleanup
 
     # these are things that have to be accessible post-cleanup
     for tmp in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \
-       "$__PKGSTATEDIR" "`pwd`" "${skip[@]}"; do
+       "$__PKGSTATEDIR" "${skip[@]}"; do
        while test -n "$tmp"; do
            list=( "${list[@]}" "$tmp" )
            tmp="${tmp%/*}"