execute the prepre script in the configuration directory (*not* the
[util-vserver.git] / util-vserver / scripts / vserver.start
index ef18c3f..f3a8ff2 100644 (file)
@@ -16,7 +16,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
-lock "$LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
+lock "$__LOCKDIR"/vserver."$($_VSERVER_INFO "$VSERVER_DIR" CANONIFY)".startup
 
 if isVserverRunning "$VSERVER_DIR"; then
     warning $"vserver '$VSERVER_NAME' already running"
@@ -30,7 +30,7 @@ function cleanup()
     test -z "$startsync_pipe"  || $_RM -f "$startsync_pipe"
     test -z "$is_started"      || { unlock; return 0; }
 
-    if test "$is_configured" -a -z "$is_executed"; then
+    if test -n "$is_configured" -a -z "$is_executed"; then
        warning $"
 An error occured while executing the vserver startup sequence; when
 there are no other messages, it is very likely that the init-script
@@ -42,7 +42,7 @@ Common causes are:
   appending 'true' to this file will help."
     fi
 
-    if test "$is_executed"; then
+    if test -n "$is_executed"; then
        warning $"
 An error occured after executing the vserver startup sequence. This
 means that some processes may exist in the created context and the
@@ -57,7 +57,7 @@ is recommended to fix this."
 Failed to start vserver '$VSERVER_NAME'"
     fi
 
-    test    "$OPTION_DEBUG"    || exec 2>/dev/null >/dev/null
+    test -n "$OPTION_DEBUG"    || exec 2>/dev/null >/dev/null
     test -z "$is_mounted"      || umountVserver     "$VSERVER_DIR" || :
     test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || :
 
@@ -72,13 +72,27 @@ is_vshelper_init=
 have_interfaces=
 startsync_pipe=
 
+while test "$#" -gt 0; do
+    case "$1" in
+       (--rescue)      INITSTYLE=rescue;;
+       (--rescue-cmd)  INITCMD_RESCUE=( $2 ); shift;;
+       (*)             panic $"vserver ... start: unknown option '$1'";;
+    esac
+    shift
+done
+
 set -e
 trap "cleanup" EXIT
 
-vshelper.doSanityCheck
+sanityCheck      "$VSERVER_DIR"
 
+mountRootFS      "$VSERVER_DIR"
 generateOptions  "$VSERVER_DIR"
+
+pushd "$VSERVER_DIR" >/dev/null
 execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" prepre-start
+popd
+
 enableInterfaces "$VSERVER_DIR" && have_interfaces=1
 
 mountVserver "$VSERVER_DIR"     && is_mounted=1
@@ -105,10 +119,11 @@ if $_VSERVER_INFO - FEATURE migrate; then
     $_VATTRIBUTE --set "${OPTS_VATTRIBUTE[@]}" -- \
     $_SAVE_CTXINFO "$VSERVER_DIR" \
     $_ENV -i -- \
-    $_VCONTEXT   --migrate-self --endsetup --chroot $SILENT_OPT "${OPTS_VCONTEXT_MIGRATE[@]}" -- \
+    $_VCONTEXT   --migrate-self --endsetup --chroot $SILENT_OPT \
+    "${OPTS_VCONTEXT_MIGRATE[@]}" "${OPTS_VCONTEXT_ENTER[@]}" -- \
     "${INITCMD_START[@]}"
 else
-    if test "$_IS_FAKEINIT"; then
+    if test -n "$_IS_FAKEINIT"; then
        startsync_pipe=$($_MKTEMP /tmp/vserver-start.XXXXXX)
        $_RM -f "$startsync_pipe"
        $_MKFIFO -m600 "$startsync_pipe"        ## safe, since mkfifo does not follow symlinks