3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 if isVserverRunning "$VSERVER_DIR"; then
19 echo $"vserver '$VSERVER_NAME' already running; aborting..." >&2
25 test -z "$startsync_pipe" || rm -f "$startsync_pipe"
26 test -z "$is_started" || return 0
28 if test "$is_configured" -a -z "$is_executed"; then
30 An error occured while executing the vserver startup sequence; when
31 there are no other messages, it is very likely that the init-script
32 (${INITCMD_START[@]}) failed.
35 * /etc/rc.d/rc on Fedora Core 1 and RH9 fails always; the 'apt-rpm' build
36 method knows how to deal with this, but on existing installations,
37 appending 'true' to this file will help."
40 if test "$is_executed"; then
42 An error occured after executing the vserver startup sequence. This
43 means that some processes may exist in the created context and the
46 $_VSERVER '$VSERVER_DIR' stop
48 is recommended to fix this."
52 Failed to start vserver '$VSERVER_NAME'"
55 test "$OPTION_DEBUG" || exec 2>/dev/null >/dev/null
56 test -z "$is_mounted" || umountVserver "$VSERVER_DIR" || :
57 test -z "$have_interfaces" || disableInterfaces "$VSERVER_DIR" || :
71 vshelper.doSanityCheck
73 generateOptions "$VSERVER_DIR"
74 execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" prepre-start
75 enableInterfaces "$VSERVER_DIR" && have_interfaces=1
77 mountVserver "$VSERVER_DIR" && is_mounted=1
78 prepareInit "$VSERVER_DIR"
80 pushd "$VSERVER_DIR"/vdir/ >/dev/null
81 execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" pre-start
84 test -z "$OPTION_DEFAULTTTY" || setDefaultTTY
86 pushd "$VSERVER_DIR"/vdir/ >/dev/null
88 if $_VSERVER_INFO - FEATURE migrate; then
89 $_CHBIND "${CHBIND_OPTS[@]}" -- \
90 $_VCONTEXT --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
91 ${USE_VNAMESPACE:+$_VNAMESPACE --set -- } \
92 $_VLIMIT --dir "$VSERVER_DIR"/rlimits --missingok -- \
93 $_VSCHED --xid self "${OPTS_VSCHED[@]}" -- \
94 $_VUNAME --xid self --dir "$VSERVER_DIR"/uts --missingok -- \
95 "${VSERVER_EXTRA_CMDS[@]}" \
96 $_VUNAME --xid self --set -t context="$VSERVER_DIR" -- \
97 $_VATTRIBUTE --set "${OPTS_VATTRIBUTE[@]}" -- \
98 $_SAVE_CTXINFO "$VSERVER_DIR" \
99 $_VCONTEXT --migrate-self --endsetup --chroot $SILENT_OPT "${OPTS_VCONTEXT_MIGRATE[@]}" -- \
100 "${INITCMD_START[@]}"
102 if test "$_IS_FAKEINIT"; then
103 startsync_pipe=$(mktemp /tmp/vserver-start.XXXXXX)
104 rm -f "$startsync_pipe"
105 mkfifo -m600 "$startsync_pipe" ## safe, since mkfifo does not follow symlinks
109 $_CHBIND "${CHBIND_OPTS[@]}" \
110 $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
111 $_CHCONTEXT_COMPAT "${CHCONTEXT_OPTS[@]}" "${CHCONTEXT_INIT_OPTS[@]}" \
112 $_SAVE_CTXINFO "$VSERVER_DIR" \
114 $_CHAINECHO "${_IS_FAKEINIT:+$startsync_pipe}" "" \
115 $_CAPCHROOT "${CAPCHROOT_OPTS[@]}" . \
116 "${INITCMD_START[@]}"
118 ## the additional synchronization step is needed since vshelper.doInit
119 ## below might be executed before needed context information were
120 ## saved by $_SAVE_CTXINFO
121 ${_IS_FAKEINIT:+cat "$startsync_pipe"} >/dev/null
125 "${INITCMD_START_SYNC[@]}"
128 pushd "$VSERVER_DIR"/vdir/ >/dev/null
129 execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" post-start
133 ! vshelper.isEnabled "" "$VSERVER_DIR" || vshelper.doInit "$VSERVER_DIR"