X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fvserver.functions;h=12366299b86687e86b39c07dc6c7bf90bd2b80e1;hb=44d73b5bf7ced18ec382bb9e00574df74a03a3f6;hp=2c022769c523ab30e428de1de3f751253c6170de;hpb=a0ed579c492e03b41c53f5230374412dad736c8c;p=util-vserver.git diff --git a/scripts/vserver.functions b/scripts/vserver.functions index 2c02276..1236629 100644 --- a/scripts/vserver.functions +++ b/scripts/vserver.functions @@ -247,7 +247,8 @@ function _generateInitOptions CHCONTEXT_INIT_OPTS=() - getFileValue INITSTYLE "$cfgdir"/style + test -n "$INITSTYLE" || \ + getFileValue INITSTYLE "$cfgdir"/style getFileValue RUNLEVEL_START "$cfgdir"/runlevel getFileValue RUNLEVEL_START "$cfgdir"/runlevel.start getFileValue RUNLEVEL_STOP "$cfgdir"/runlevel.stop @@ -262,7 +263,7 @@ function _generateInitOptions (xrescue) INITCMD_START=( "${INITCMD_RESCUE[@]}" ) INITCMD_STOP=( /sbin/killall5 ) - _IS_FAKEINIT=1 + _IS_FAKEINIT= _NEED_VSHELPER_SYNC= ;; @@ -299,7 +300,27 @@ function _generateInitOptions ;; (xgentoo) - panic "init-style '$INITSTYLE' is no longer supported; please use plain instead; aborting";; + test -n "$RUNLEVEL_START" || RUNLEVEL_START="default" + + INITCMD_START=( /lib/rcscripts/sh/init-vserver.sh "$RUNLEVEL_START" ) + INITCMD_STOP=( /sbin/rc shutdown ) + INITCMD_PREPARE=( $_FAKE_RUNLEVEL 3 /var/run/utmp ) + + pushd "$vdir"/vdir &>/dev/null + basever=$($_CHROOT_SH cat /etc/gentoo-release | $_AWK '{print $5}') + popd &>/dev/null + + basemaj=${basever/.*} + basemin=${basever#*.} + basemin=${basemin/.*} + + test "$basemaj" -lt 1 -o "$basemin" -lt 13 && \ + panic "\ +Using init-style 'gentoo' requires >=baselayout-1.13 inside the vserver! + +Your vserver ($(basename "$vdir")) seems to have baselayout-$basever, +please use 'plain' init-style instead!" + ;; (x) ;; (*) panic "Unknown init-style '$INITSTYLE'; aborting";; @@ -390,6 +411,11 @@ function _generateChcontextOptions function _generateScheduleOptions { local vdir=$1 + if test -d "$vdir"/sched; then + OPTS_VSCHED=( --dir "$vdir"/sched --missingok ) + return 0 + fi + local f="$vdir"/schedule test -e "$f" || return 0 @@ -805,7 +831,7 @@ function mountVserver _mountVserverInternal "$cfgdir"/fstab.remote $_CHBIND "${CHBIND_OPTS[@]}" isNamespaceCleanup "$cfgdir" && \ - _namespaceCleanup + _namespaceCleanup "$cfgdir" isAvoidNamespace "$cfgdir" || \ $_SECURE_MOUNT --rbind -n "$vdir" "/" @@ -1161,26 +1187,39 @@ function saveDiskLimits function _namespaceCleanup { - local root=$(readlink -f "$vdir") - local tmp="$root" + local vdir="$1" + local root=$($_VSERVER_INFO "$1" VDIR 1) local -a list - while [ "$tmp" ]; do - list=( "${list[@]}" "$tmp" ) - tmp="${tmp%/*}" + local -a skip + local tmp + + getFileArray skip "$vdir"/namespace-cleanup-skip \ + "$__CONFDIR"/.defaults/namespace-cleanup-skip || : + + # these are things that have to be accessible post-cleanup + for tmp in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \ + "$__PKGSTATEDIR" "${skip[@]}"; do + while test -n "$tmp"; do + list=( "${list[@]}" "$tmp" ) + tmp="${tmp%/*}" + done done + local -a list_umount while read dev path opts; do - [ "$path" ] || continue - for i in "$root" /dev /proc; do - [ "${path#$i}" != "$path" ] && continue 2 - done - for i in "${list[@]}" /; do - [ "$path" = "$i" ] && continue 2 - done - list_umount=( "${list_umount[@]}" "$path" ) + test -n "$path" || continue + for i in "$root" /dev /proc; do + test "${path#$i}" != "$path" && continue 2 + done + for i in "${list[@]}" /; do + test "$path" = "$i" && continue 2 + done + # unmount them in reverse order so mounts further down the tree get unmounted first + list_umount=( "$path" "${list_umount[@]}" ) done < /proc/mounts + # separate loop to avoid races while reading /proc/mounts for i in "${list_umount[@]}"; do - umount -l -n "$i" + $_UMOUNT -l -n "$i" done }