X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fvserver.functions;h=5bfda352a6a890d83a4f4ad36586546d94ff41f7;hb=8314751ea70853c629cbfc1c8f3ce2ea9647de3f;hp=ba07f332c1978467deb81ee39a927245b5b05973;hpb=ca2b0cc0a04e2ba7d5f2fa836167e711bfb7af25;p=util-vserver.git diff --git a/scripts/vserver.functions b/scripts/vserver.functions index ba07f33..5bfda35 100644 --- a/scripts/vserver.functions +++ b/scripts/vserver.functions @@ -278,6 +278,11 @@ function _generateInitOptions INITCMD_STOP=( "$i" "$RUNLEVEL_STOP" ) done INITCMD_PREPARE=( $_FAKE_RUNLEVEL "$RUNLEVEL_START" /var/run/utmp ) + OPTS_ENV=( "${OPTS_ENV[@]}" PREVLEVEL=N RUNLEVEL="$RUNLEVEL_START" ) + if test -n "$OPTION_DEBUG_SYSV"; then + INITCMD_START=( /bin/bash -x "${INITCMD_START[@]}" ) + INITCMD_STOP=( /bin/bash -x "${INITCMD_STOP[@]}" ) + fi ;; (xplain) @@ -303,24 +308,9 @@ function _generateInitOptions (xgentoo) test -n "$RUNLEVEL_START" || RUNLEVEL_START="default" - INITCMD_START=( /lib/rcscripts/sh/init-vserver.sh "$RUNLEVEL_START" ) - INITCMD_STOP=( /sbin/rc shutdown ) + INITCMD_START=( env TERM=$TERM /lib/rcscripts/sh/init-vserver.sh "$RUNLEVEL_START" ) + INITCMD_STOP=( env -i TERM=$TERM RUNLEVEL=0 /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) ;; @@ -570,7 +560,10 @@ function _processSingleInterface } if ! test -e "$iface"/indirect; then - _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" broadcast ${bcast:-+} ${name:+label "$dev:$name"} dev "$dev" + # XXX: IPv6 hack + use_bcast="broadcast ${bcast:-+}" + echo "$ip" | $_GREP -q : && use_bcast= + _addInterfaceCmd IP_ADDR "$ip${prefix:+/$prefix}" $use_bcast ${name:+label "$dev:$name"} dev "$dev" #_addInterfaceCmd IP_ROUTE "$ip${prefix:+/$prefix}" dev "$dev" _addInterfaceCmd IP_LINK "$dev" $up elif ! test -n "$ctx"; then @@ -702,7 +695,7 @@ function prepareStop pushd "$1/vdir" >/dev/null case "$INITSTYLE" in (sysv) - export PREVLEVEL=$RUNLEVEL_START # required by Debian's initscripts + export PREVLEVEL=$RUNLEVEL_START RUNLEVEL=$RUNLEVEL_STOP # required by Debian's initscripts ;; esac "${STOPCMD_PREPARE[@]}" @@ -1201,7 +1194,7 @@ function _namespaceCleanup # these are things that have to be accessible post-cleanup for tmp in "$root" "$__SBINDIR" "$__PKGLIBDIR" "$vdir" \ - "$__PKGSTATEDIR" "${skip[@]}"; do + "$__PKGSTATEDIR" "$__LOCKDIR" /usr/local /tmp "${skip[@]}"; do while test -n "$tmp"; do list=( "${list[@]}" "$tmp" ) tmp="${tmp%/*}" @@ -1226,3 +1219,28 @@ function _namespaceCleanup done } +function loadDeviceMap +{ + local xid="$1" + local dir="$2" + local flags device target + + test -d "$dir" || return 0 + + for i in "$dir"/*; do + test -d "$i" || continue + + local -a vdevmap_opts=() + test -e "$i/create" && vdevmap_opts=( "${vdevmap_opts[@]}" --create ) + test -e "$i/open" && vdevmap_opts=( "${vdevmap_opts[@]}" --open ) + test -e "$i/remap" && vdevmap_opts=( "${vdevmap_opts[@]}" --remap ) + + getFileValue flags "$i/flags" || : + getFileValue device "$i/device" || : + getFileValue target "$i/target" || : + vdevmap_opts=( "${vdevmap_opts[@]}" ${flags:+--flags "$flags"} \ + ${device:+--device "$device"} ${target:+--target "$target"} ) + + $_VDEVMAP --xid "$xid" "${vdevmap_opts[@]}" || return $? + done +}