cfgdir="$1"
vdir="$cfgdir"/vdir
. "$2"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS"
# vserver name
# start vserver before we can exec anything inside it
$_VSERVER "$NAME" stop &>/dev/null || :
-$_VSERVER "$NAME" start --rescue --rescue-init bash -c '
- exec > /dev/null
- exec 2> /dev/null
-
- set -x
- f=/tmp/startwait
- trap "rm -f $f" EXIT
- mkfifo $f
- ( sleep 15; kill -s 9 -- -1 ) &
- cat "$f"
- kill -s 9 -- -1
- wait
-'
+startSleepingGuest "$NAME" 30
# run the configure commands from within the server
export LANG=C LC_ALL=C
done
# stop the vserver
-$_VSERVER "$NAME" exec bash -c ': >/tmp/startwait' &>/dev/null || :
-$_VSERVER "$NAME" stop &>/dev/null || :
+stopSleepingGuest "$NAME" &>/dev/null || :
popd &>/dev/null
vdir=$1/vdir
. "$2"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS"
function relink
{
## Do some magic to set the vserver into a defined state
$_VSERVER "$vserver" stop &>/dev/null || :
-$_VSERVER "$vserver" start --rescue --rescue-init bash -c '
- exec >/dev/null
- exec 2>/dev/null
-
- set -x
- f=/tmp/startwait
- trap "rm -f $f" EXIT
- mkfifo $f
- ( sleep 15; kill -s 9 -- -1 ) &
- cat "$f" >/dev/null
- kill -s 9 -- -1
- wait
-'
+startSleepingGuest "$vserver" 15
pushd "$vdir"/etc/init.d &>/dev/null ||
pushd "$vdir"/etc/rc.d/init.d &>/dev/null || exit 1
s!si::sysinit:/etc/rc.d/rc.sysinit!si::sysinit:/etc/rc.d/rc.sysinit.vserver!'
popd >/dev/null
-$_VSERVER "$vserver" exec bash -c ': >/tmp/startwait' &>/dev/null || :
-$_VSERVER "$vserver" stop &>/dev/null || :
+stopSleepingGuest "$vserver" &> /dev/null || :
<vserver> is the name of a vserver.
Possible commands are:
- start [--rescue [--rescue-init]] [<rescue-cmd> <args>*]
+ start [--rescue [--rescue-init] <rescue-cmd> <args>*]]
... starts the specified vserver
- stop ... stops the specified vserver
+ stop [--rescue-init]
+ ... stops the specified vserver
restart ... restarts the specified vserver; this is the subsequent
execution of a synchronized 'stop' and a 'start'
condrestart ... restarts the vserver when it is running already
{
__BASE_SUCCESS=1
}
+
+function startSleepingGuest
+{
+ local guest="$1"
+ local timeout="$2"
+ $_VSERVER "$guest" start --rescue --rescue-init bash -c "
+ exec > /dev/null
+ exec 2> /dev/null
+ sleep $timeout
+ kill -s 15 -- -1
+ sleep 1
+ kill -s 9 -- -1"
+}
+
+function stopSleepingGuest
+{
+ local guest="$1"
+ $_VSERVER "$guest" stop --rescue-init
+}
OPTION_FORCE_SYNC=1
+while test "$#" -gt 0; do
+ case "$1" in
+ (--rescue-init) _IS_FAKEINIT=1;;
+ (--) shift; break;;
+ (-*) panic $"vserver ... stop: unknown option '$1'";;
+ esac
+done
+
set -e
generateOptions "$VSERVER_DIR"
set +e