X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fvserver.functions;h=9db6007d88ebb5d0e1edd3eeb1adacc57ac00711;hb=66ff8eb2e4f7e51fab7bf0eae4a756c9f54b7132;hp=e87afe3afb81b0ace8cf1c80e7c6e80d9df574fb;hpb=bbc69d59f75750e728b98e7a6f054780329a6785;p=util-vserver.git diff --git a/util-vserver/scripts/vserver.functions b/util-vserver/scripts/vserver.functions index e87afe3..9db6007 100644 --- a/util-vserver/scripts/vserver.functions +++ b/util-vserver/scripts/vserver.functions @@ -127,6 +127,23 @@ function getEnterShell } } +## Usage: sendKillSequence [ ]* +function sendKillSequence +{ + local ctx=$1 + local wait= + shift + + while isCtxRunning "$ctx"; do + test -z "$wait" || sleep "$wait" + + $_VKILL -c "$ctx" ${1:+-s "$1"} + test "$2" || break + wait="$2" + shift 2 + done +} + function _generateInitOptions { local vdir=$1 @@ -149,7 +166,7 @@ function _generateInitOptions getFileValue runlevel_start "$cfgdir"/runlevel getFileValue runlevel_start "$cfgdir"/runlevel.start getFileValue runlevel_stop "$cfgdir"/runlevel.stop - getFileArray INITKILL_SEQ "$cfgdir"/killseq + getFileArray INITKILL_SEQ "$cfgdir"/killseq case x"$INITSTYLE" in xsysv) @@ -211,8 +228,8 @@ function _generateFlagOptions while read flag; do case x"$flag" in x|x#) ;; - dummy) ;; - fakeinit) + xnamespace) ;; + xfakeinit) CHCONTEXT_INIT_OPTS=( --disconnect --flag fakeinit ) ;; *) @@ -221,6 +238,9 @@ function _generateFlagOptions ;; esac done <"$vdir"/flags + + isAvoidNamespace "$cfgdir" || \ + CHCONTEXT_FLAG_OPTS=( "${CHCONTEXT_FLAG_OPTS[@]}" --flag namespace ) } function _generateChcontextOptions @@ -307,7 +327,7 @@ function _processSingleInterface _getInterfaceValue name '' "$iface" _getInterfaceValue scope '' "$iface" "$iface/.." - test "$ip" || { echo $"Can not read ip for '$iface'"; return 1; } + test "$ip" || { echo $"Can not read ip for '$iface'" >&2; return 1; } test ! -e "$iface"/only_ip || unset dev @@ -317,7 +337,7 @@ function _processSingleInterface case "$dev" in *.*) test -d /proc/net/vlan || { - echo -e $"VLAN device-name used, but vlan subsystem not enabled.\nTry to execute 'modprobe 8021q' before starting the vservers" + echo -e $"VLAN device-name used, but vlan subsystem not enabled.\nTry to execute 'modprobe 8021q' before starting the vservers" >&2 return 1 } test -f /proc/net/vlan || { @@ -423,12 +443,13 @@ function generateOptions function mountVserver { local cfgdir=$1 + local ns_opt=$2 local vdir=$1/vdir local mtab_src test -e "$cfgdir"/fstab || return 0 - findObject -r mtab_src "$vdir"/apps/init/mtab "$CONFDIR"/.defaults/init/mtab /dev/null + findObject -r mtab_src "$vdir"/apps/init/mtab "$CONFDIR"/.defaults/init/mtab "$PKGLIBDEFAULTDIR"/mtab /dev/null pushd "$vdir" >/dev/null $_CHROOT_CAT /etc/mtab <"$mtab_src" @@ -437,6 +458,9 @@ function mountVserver test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir" $_CHBIND "${CHBIND_OPTS[@]}" \ $_SECURE_MOUNT -a --chroot "$vdir" --fstab "$cfgdir"/fstab + + isAvoidNamespace "$cfgdir" || \ + $_SECURE_MOUNT --rbind -n "$vdir" "/" } function umountVserver @@ -446,7 +470,8 @@ function umountVserver is_ok=1 - test -e "$cfgdir"/fstab || return 0 + isAvoidNamespace "$cfgdir" || return 0 + test -e "$cfgdir"/fstab || return 0 test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir" pushd "$vdir/" >/dev/null @@ -456,8 +481,8 @@ function umountVserver x#*) continue;; esac - $_CHBIND "${CHBIND_OPTS[@]}" \ - $_SECURE_UMOUNT "$dst" || is_ok= + $_CHBIND "${CHBIND_OPTS[@]}" $_EXEC_CD "$dst" \ + $_UMOUNT -lfn . || is_ok= done popd >/dev/null