declare -a CAPCHROOT_OPTS=()
declare -a INTERFACES=()
+declare -a INITCMD_RESCUE=( /bin/sleep 900 )
declare -a INITCMD_START=()
declare -a INITCMD_START_SYNC=()
declare -a INITCMD_STOP=()
declare -a OPTS_VCONTEXT_CREATE=()
declare -a OPTS_VCONTEXT_MIGRATE=()
+declare -a OPTS_VCONTEXT_ENTER=()
declare -a OPTS_VATTRIBUTE=( --flag fakeinit )
declare -a OPTS_VSCHED=()
declare -a VSERVER_EXTRA_CMDS=()
+INIT_RESCUE=
VSHELPER_SYNC_TIMEOUT=30
USE_VNAMESPACE=
INTERFACE_CMDS_IDX=0
: ${VSERVER_NAME:=$(basename "$VSERVER_DIR")}
-if test -e "$VSERVER_DIR"/noisy -o "$OPTION_VERBOSE"; then
+if test -e "$VSERVER_DIR"/noisy -o -n "$OPTION_VERBOSE"; then
SILENT_OPT=
else
SILENT_OPT='--silent'
local i
local bcast=
- test "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
+ test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
local f=$vdir/interfaces/bcast
getFileValue bcast "$f"
NICE_CMD=( $_NICE -$nice )
}
+
+function _generatePersonalityOptions
+{
+ local vdir="$1"
+ local f="$vdir"/personality
+ local type flags
+
+ test -s "$f" || return 0
+
+ {
+ local delim tmp
+
+ read type
+ while read tmp; do
+ case x$tmp in
+ (x\#*|x) ;;
+ (*) flags=$flags$delim$tmp
+ delim=,
+ ;;
+ esac
+ done
+ } <"$f"
+
+ OPTS_VCONTEXT_ENTER=( "${OPTS_VCONTEXT_ENTER[@]}"
+ --personality-type "$type"
+ ${flags:+--personality-flags "$flags"} )
+}
+
function _generateCCapabilityOptions
{
local vdir=$1
ENTER_SHELL=()
- getFileValue ENTER_SHELL "$vdir"/shell "$CONFDIR"/.defaults/shell
+ getFileValue ENTER_SHELL "$vdir"/shell "$__CONFDIR"/.defaults/shell
- test "$ENTER_SHELL" || {
+ test -n "$ENTER_SHELL" || {
local i
for i in "/bin/bash -login" "/bin/sh -l" /bin/csh; do
set -- $i
while isCtxRunning "$ctx"; do
test -z "$wait" || sleep "$wait"
-
- $_VKILL -c "$ctx" ${1:+-s "$1"} 2>/dev/null || :
- test "$2" || break
+
+ killContext "$ctx" "$1"
+ test -n "$2" || break
wait="$2"
shift 2
done
getFileArray INITKILL_SEQ "$cfgdir"/killseq || :
case x"$INITSTYLE" in
+ (xrescue)
+ INITCMD_START=( "${INITCMD_RESCUE[@]}" )
+ INITCMD_STOP=( /sbin/killall5 )
+ _IS_FAKEINIT=1
+ _NEED_VSHELPER_SYNC=
+ ;;
+
(xsysv)
- test "$RUNLEVEL_START" || RUNLEVEL_START=3
- test "$RUNLEVEL_STOP" || RUNLEVEL_STOP=6
+ test -n "$RUNLEVEL_START" || RUNLEVEL_START=3
+ test -n "$RUNLEVEL_STOP" || RUNLEVEL_STOP=6
for i in /etc/init.d/rc /etc/rc.d/rc; do
test -x "$vdir/vdir/$i" || continue
_IS_FAKEINIT=1
INITCMD_START_SYNC=( "$_INITSYNC_MINIT_START" "$vdir" )
_NEED_VSHELPER_SYNC=1
- test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
- test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
+ test -z "$RUNLEVEL_START" || INITCMD_START=( "${INITCMD_START[@]}" "$RUNLEVEL_START" )
+ test -z "$RUNLEVEL_STOP" || INITCMD_STOP=( "${INITCMD_STOP[@]}" "$RUNLEVEL_STOP" )
+ ! isNumber "${RUNLEVEL_START:-3}" || INITCMD_PREPARE=( $_FAKE_RUNLEVEL "${RUNLEVEL_START:-3}" /var/run/utmp )
;;
(xgentoo)
exit 1;;
esac
- getFileArray INITCMD_START "$cfgdir"/cmd.start || :
- getFileArray INITCMD_STOP "$cfgdir"/cmd.stop || :
- getFileArray INITCMD_START_SYNC "$cfgdir"/cmd.start-sync || :
- getFileArray INITCMD_STOP_SYNC "$cfgdir"/cmd.stop-sync || :
- getFileArray INITCMD_PREPARE "$cfgdir"/cmd.prepare || :
-
+ if test x"$INITSTYLE" != xrescue; then
+ getFileArray INITCMD_START "$cfgdir"/cmd.start || :
+ getFileArray INITCMD_STOP "$cfgdir"/cmd.stop || :
+ getFileArray INITCMD_START_SYNC "$cfgdir"/cmd.start-sync || :
+ getFileArray INITCMD_STOP_SYNC "$cfgdir"/cmd.stop-sync || :
+ getFileArray INITCMD_PREPARE "$cfgdir"/cmd.prepare || :
+ fi
- test "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
+ test -n "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || {
INITCMD_START_SYNC=()
INITCMD_STOP_SYNC=()
_NEED_VSHELPER_SYNC=
} <"$f"
} 2>/dev/null
- test "$prio_bias" || {
+ test -n "$prio_bias" || {
echo $"Bad content in '$f'; aborting..." >&2
false
}
{
local _tm2p_tmp=$2
- test "$_tm2p_tmp" || {
+ test -n "$_tm2p_tmp" || {
$_MASK2PREFIX "$3" || _tm2p_tmp=$?
}
_getInterfaceValue scope '' "$iface" "$iface/.."
_getInterfaceValue mac '' "$iface"
- test "$ip" || { echo $"Can not read ip for '$iface'" >&2; return 1; }
- test "$dev" -o -e "$iface"/nodev || {
+ test -n "$ip" || { echo $"Can not read ip for '$iface'" >&2; return 1; }
+ test -n "$dev" -o -e "$iface"/nodev || {
echo $"No device specified for '$iface'" >&2
return 1;
}
_addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" broadcast ${bcast:-+} ${name:+label "$dev:$name"} dev "$dev"
#_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev"
_addInterfaceCmd IP_LINK "$dev" $up
- elif ! test "$ctx"; then
+ elif ! test -n "$ctx"; then
echo $"Using 'dummy' (indirect) for interface '$dev' requires a fixed context number; dynamic ctx are not supported" >&2
return 1
else
- test "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
+ test -z "$mac" || _generateMac mac "$(basename $iface)" "$ctx" || return 1
_addInterfaceCmd MODPROBE dummy "$dev"
_addInterfaceCmd IP_LINK dev dummy0 address "$mac"
_addInterfaceCmd NAMEIF "$dev" "$mac"
local i=0
declare -a var
- lock "$LOCKDIR"/vserver.interfaces
+ lock "$__LOCKDIR"/vserver.interfaces
while test $i -lt $INTERFACE_CMDS_IDX; do
eval var='( "${INTERFACE_CMDS_'$i'[@]}" )'
function disableInterfaces
{
- test "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
+ test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$1"
local i=$INTERFACE_CMDS_IDX
declare -a var
- lock "$LOCKDIR"/vserver.interfaces
+ lock "$__LOCKDIR"/vserver.interfaces
while test $i -gt 0; do
let --i || :
function generateOptions
{
- _generateInterfaceOptions "$1"
- test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
- _generateNiceCommand "$1"
- _generateInitOptions "$1"
- _generateChcontextOptions "$1"
- _generateScheduleOptions "$1"
+ _generateInterfaceOptions "$1"
+ test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1"
+ _generateNiceCommand "$1"
+ _generateInitOptions "$1"
+ _generateChcontextOptions "$1"
+ _generateScheduleOptions "$1"
+ _generatePersonalityOptions "$1"
- if test "$_IS_FAKEINIT"; then
+ if test -n "$_IS_FAKEINIT"; then
CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit )
OPTS_VCONTEXT_MIGRATE=( "${OPTS_VCONTEXT_MIGRATE[@]}" --initpid --disconnect )
fi
-e "$cfgdir"/fstab.local -o \
-e "$cfgdir"/fstab.remote || return 0
- findObject -r mtab_src "$vdir"/apps/init/mtab "$CONFDIR"/.defaults/init/mtab "$PKGLIBDEFAULTDIR"/mtab /dev/null
+ findObject -r mtab_src "$cfgdir"/apps/init/mtab "$__CONFDIR"/.defaults/init/mtab "$__PKGLIBDEFAULTDIR"/mtab /dev/null
pushd "$vdir" >/dev/null
$_CHROOT_CAT /etc/mtab <"$mtab_src"
popd >/dev/null
- test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
+ test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \
$_VNAMESPACE --cleanup
$_TAC "$fstab" | {
is_ok=1
while read src dst tmp; do
- test "$tmp" || continue
+ test -n "$tmp" || continue
case x"$src" in
(x\#*) continue;;
esac
"$@" $_EXEC_CD "$dst" $_UMOUNT -lfn . || is_ok=
done
- test "$is_ok"
+ test -n "$is_ok"
}
}
isAvoidNamespace "$cfgdir" || return 0
test -e "$cfgdir"/fstab -o \
-e "$cfgdir"/fstab.local || return 0
- test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
+ test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
pushd "$vdir/" >/dev/null || return 1
_umountVserverInternal "$cfgdir"/fstab.local || is_ok=
_umountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || is_ok=
popd >/dev/null || return 1
- test "$is_ok"
+ test -n "$is_ok"
}
## Usage: waitForSync <vserver> <vshelper-fifo-varname>
function initSync
{
- test -z "$_NEED_VSHELPER_SYNC" || vshelper.initSync "$1" "$2"
+ local _is_meth=sync
+ test -n "$_NEED_VSHELPER_SYNC" || _is_meth=async
+
+ vshelper.initSync "$1" "$2" "$_is_meth"
}
## Usage: waitForSync <vserver> [<vshelper-fifo>]
local cfgdir=$1
local fifo=$2
- if test "$_NEED_VSHELPER_SYNC"; then
+ if test -n "$_NEED_VSHELPER_SYNC"; then
$_VSHELPER_SYNC "$fifo" "$VSHELPER_SYNC_TIMEOUT" || \
warning $"\
A timeout or other error occured while waiting for the synchronization
declare -r flavor=$3
local base i
- for base in "$vdir"/scripts "$CONFDIR"/.defaults/scripts; do
+ for base in "$vdir"/scripts "$__CONFDIR"/.defaults/scripts; do
local DONT_SKIP_DEFAULTS=
local already_handled=
for i in "$base/$flavor" "$base/$flavor.d"/*; do
- test -f "$i" -a -r "$i" || continue
+ isRegularFile "$i" || continue
+ test -r "$i" || continue
+
already_handled=1
local start=
test -x "$i" || start=_sourceWrap
$start "$i" "$flavor" "$name"
done
- test -z "$already_handled" -o "$DONT_SKIP_DEFAULTS" || break
+ test -z "$already_handled" -o -n "$DONT_SKIP_DEFAULTS" || break
done
}
$_VSERVER_INFO - VERIFYCAP ||
panic $"capabilities are not enabled in kernel-setup"
+
+ $_VSERVER_INFO - VERIFYPROC ||
+ panic $"\
+/proc/uptime can not be accessed. Usually, this is caused by
+procfs-security. Please read the FAQ for more details
+http://www.linux-vserver.org/index.php?page=Linux-Vserver+FAQ"
}