X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fvserver.start;h=246647f67e28b0c5916e9de6f675f36184aec902;hb=8df6314090cda53869d92a1526081fa01fe2080b;hp=85dfcb9c5a9e42580f2ad2ff06949e2d6b7f8d40;hpb=11008d3e8c9a5fc41e16b77925d6a9012ef6875e;p=util-vserver.git diff --git a/util-vserver/scripts/vserver.start b/util-vserver/scripts/vserver.start index 85dfcb9..246647f 100644 --- a/util-vserver/scripts/vserver.start +++ b/util-vserver/scripts/vserver.start @@ -16,28 +16,101 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if isVserverRunning "$VSERVER_DIR"; then - echo $"vserver '$VSERVER_NAME' already running; aborting..." + echo $"vserver '$VSERVER_NAME' already running; aborting..." >&2 exit 1 fi +function cleanup() +{ + test -z "$is_started" || return 0 + + if test "$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 +(${INITCMD_START[@]}) failed. + +Common causes are: +* /etc/rc.d/rc on Fedora Core 1 and RH9 fails always; the 'apt-rpm' build + method knows how to deal with this, but on existing installations, + appending 'true' to this file will help." + fi + + if test "$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 +manual execution of + + $_VSERVER '$VSERVER_NAME' stop + +is recommended to fix this." + else + warning $" + +Failed to start vserver '$VSERVER_NAME'" + fi + + test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null + test -z "$is_mounted" || umountVserver "$VSERVER_DIR" || : + test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || : +} + +is_configured= +is_executed= +is_started= +is_mounted= +is_vshelper_init= +have_interfaces= + +set -e +trap "cleanup" EXIT + +vshelper.doSanityCheck + generateOptions "$VSERVER_DIR" execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" prepre-start -enableInterfaces "$VSERVER_DIR" +enableInterfaces "$VSERVER_DIR" && have_interfaces=1 -mountVserver "$VSERVER_DIR" +mountVserver "$VSERVER_DIR" && is_mounted=1 prepareInit "$VSERVER_DIR" cd "$VSERVER_DIR"/vdir/ - execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" pre-start -"${NICE_CMD[@]}" \ - "$_CHBIND" "${CHBIND_OPTS[@]}" \ - "$_EXEC_ULIMIT" "$VSERVER_DIR/ulimits" \ - "$_CHCONTEXT" "${CHCONTEXT_OPTS[@]}" "${CHCONTEXT_INIT_OPTS[@]}" \ - "$_SAVE_CTXINFO" "$VSERVER_DIR" \ - "$_CAPCHROOT" "${CAPCHROOT_OPTS[@]}" . "${INITCMD_START[@]}" +cd "$VSERVER_DIR"/vdir/ + +is_configured=1 +if $_VSERVER_INFO - FEATURE migrate; then + $_CHBIND "${CHBIND_OPTS[@]}" -- \ + $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \ + ${USE_VNAMESPACE:+$_VNAMESPACE --set -- } \ + $_VLIMIT --dir "$VSERVER_DIR"/rlimits --missingok -- \ + $_VSCHED --xid self "${OPTS_VSCHED[@]}" -- \ + $_VUNAME --xid self --dir "$VSERVER_DIR"/uts --missingok -- \ + "${VSERVER_EXTRA_CMDS[@]}" \ + $_VUNAME --xid self --set -t context="$VSERVER_DIR" -- \ + $_VATTRIBUTE --set "${OPTS_VATTRIBUTE[@]}" -- \ + $_SAVE_CTXINFO "$VSERVER_DIR" \ + $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT "${OPTS_VCONTEXT_MIGRATE[@]}" -- \ + "${INITCMD_START[@]}" +else + ${NICE_CMD[@]} \ + $_CHBIND "${CHBIND_OPTS[@]}" \ + $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \ + $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" "${CHCONTEXT_INIT_OPTS[@]}" \ + $_SAVE_CTXINFO "$VSERVER_DIR" \ + $_CLEARENV \ + $_CAPCHROOT "${CAPCHROOT_OPTS[@]}" . \ + "${INITCMD_START[@]}" +fi +is_executed=1 "${INITCMD_START_SYNC[@]}" execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" post-start + +is_vshelper_init=1 +! vshelper.isEnabled "$VSERVER_DIR" || vshelper.doInit "$VSERVER_DIR" + +is_started=1