X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fvserver.functions;h=9f92c7a780979f096928036d76920fb7d7d22b3a;hb=58500d8d9b9f281bddf5889614c152597a884a3d;hp=d999d7e05e3c59e4aaf5593b90bef5d296e33693;hpb=ac167c247af836930d3043ee670e582b70b08e43;p=util-vserver.git diff --git a/util-vserver/scripts/vserver.functions b/util-vserver/scripts/vserver.functions index d999d7e..9f92c7a 100644 --- a/util-vserver/scripts/vserver.functions +++ b/util-vserver/scripts/vserver.functions @@ -28,6 +28,7 @@ declare -a CHCONTEXT_OPTS=() 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=() @@ -38,6 +39,7 @@ declare -a ENTER_SHELL=() 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=() @@ -45,6 +47,7 @@ declare -a STOPCMD_PREPARE=() declare -a VSERVER_EXTRA_CMDS=() +INIT_RESCUE= VSHELPER_SYNC_TIMEOUT=30 USE_VNAMESPACE= INTERFACE_CMDS_IDX=0 @@ -100,6 +103,34 @@ function _generateNiceCommand 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 @@ -186,8 +217,8 @@ function sendKillSequence while isCtxRunning "$ctx"; do test -z "$wait" || sleep "$wait" - - $_VKILL --xid "$ctx" ${1:+-s "$1"} 2>/dev/null || : + + killContext "$ctx" "$1" test -n "$2" || break wait="$2" shift 2 @@ -218,6 +249,13 @@ function _generateInitOptions 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 -n "$RUNLEVEL_START" || RUNLEVEL_START=3 test -n "$RUNLEVEL_STOP" || RUNLEVEL_STOP=6 @@ -245,8 +283,9 @@ function _generateInitOptions _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) @@ -259,12 +298,13 @@ function _generateInitOptions 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 -n "$OPTION_FORCE_SYNC" -o -e "$cfgdir"/sync || { INITCMD_START_SYNC=() @@ -613,12 +653,13 @@ function prepareStop function generateOptions { - _generateInterfaceOptions "$1" + _generateInterfaceOptions "$1" test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" - _generateNiceCommand "$1" - _generateInitOptions "$1" - _generateChcontextOptions "$1" - _generateScheduleOptions "$1" + _generateNiceCommand "$1" + _generateInitOptions "$1" + _generateChcontextOptions "$1" + _generateScheduleOptions "$1" + _generatePersonalityOptions "$1" if test -n "$_IS_FAKEINIT"; then CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit ) @@ -722,7 +763,10 @@ function umountVserver ## Usage: waitForSync 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 [] @@ -767,7 +811,9 @@ function execScriptlets 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 @@ -819,4 +865,10 @@ WARNING: The 'only_ip' flag for interface '$iface' is deprecated; use $_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" }