X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fvserver.functions;h=b90596820ddea161401438cdc5677e30b4295bd5;hb=9e9bcf76d468cce2a545026c8e5aca3a2ac9507f;hp=ed487facf760bf5910d04831c5b7f83cdeed5aa9;hpb=413014460871c8ac7c6b4d04eb4bd2ca0a8d5c54;p=util-vserver.git diff --git a/scripts/vserver.functions b/scripts/vserver.functions index ed487fa..b905968 100644 --- a/scripts/vserver.functions +++ b/scripts/vserver.functions @@ -49,6 +49,8 @@ declare -a OPTS_VTAG_CREATE=() declare -a OPTS_VTAG_ENTER=() declare -a OPTS_VMEMCTRL=() declare -a OPTS_VSPACE=( --default ) +declare -a OPTS_VSPACE_SHARED=() +declare -a VSPACE_SHARED_CMD=() declare -a STOPCMD_PREPARE=() @@ -110,6 +112,12 @@ function _generateChbindOptions test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir" + if test -e "$vdir"/noncontext -o + \( -e "$vdir"/spaces/net -a ! -e "$vdir"/ncontext \); then + _HAVE_CHBIND_OPTIONS=1 + return 0 + fi + local f="$vdir"/interfaces/bcast getFileValue bcast "$f" f="$vdir"/interfaces/lback @@ -344,7 +352,8 @@ function _generateInitOptions panic "init-vserver.sh not found; aborting" fi - INITCMD_START=( env TERM=$TERM $RC_WRAP "$RUNLEVEL_START" ) + OPTS_ENV=( "${OPTS_ENV[@]}" TERM=$TERM ) + INITCMD_START=( $RC_WRAP "$RUNLEVEL_START" ) INITCMD_STOP=( env -i PATH=$RC_PATH TERM=$TERM RUNLEVEL=0 /sbin/rc shutdown ) INITCMD_PREPARE=( $_FAKE_RUNLEVEL 3 /var/run/utmp ) ;; @@ -786,16 +795,22 @@ function _generateSpaceOptions { local vdir="$1" local d="$vdir"/spaces - - ( test ! -e "$d"/pid ) || \ - OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --pid ) - - test ! -e "$d"/net || { - OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --net ) - # network context and namespace don't make much sense - _HAVE_CHBIND_OPTIONS=1 - CHBIND_CMD=() - } + local shared + local space + + for space in pid net; do + if test -e "$d"/$space; then + getFileValue shared "$d"/$space || shared="" + if test -z "$shared"; then + OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --$space ) + elif test "$shared" = "0"; then + # Do nothing + else + OPTS_VSPACE_SHARED=( "${OPTS_VSPACE_SHARED[@]}" --$space ) + VSPACE_SHARED_CMD=( "${VSPACE_SHARED_CMD[@]}" $_VSPACE --enter "$shared" --$space -- ) + fi + fi + done local mask getFileValue mask "$d"/mask || \ @@ -808,8 +823,8 @@ function prepareInit pushd "$1/vdir" >/dev/null case "$INITSTYLE" in sysv) - { find var/run ! -type d -print0; \ - find var/lock ! -type d -print0; } | xargs -0r $_CHROOT_SH rm + { $_FIND var/run ! -type d -print0; \ + $_FIND var/lock ! -type d -print0; } | xargs -0r $_CHROOT_SH rm ;; plain) $_CHROOT_SH rm .autofsck forcefsck 2>/dev/null || : @@ -1217,7 +1232,7 @@ WARNING: There is no cachedirectory configured for this vserver; ln -s ../.defaults/cachebase/$VSERVER_NAME $cfgdir/cache " - find "$cfgdir" -type f -exec "$_CHECK_UNIXFILE" '{}' ';' + $_FIND "$cfgdir" -type f -exec "$_CHECK_UNIXFILE" '{}' ';' vshelper.doSanityCheck @@ -1443,6 +1458,10 @@ function _generateCgroupOptions findFile file "$__CONFDIR/.defaults/cgroup/subsys" "" if test -n "$file"; then read CGROUP_SUBSYS < "$file" + elif $_GREP -q '^ns[[:space:]]' /proc/cgroups; then + # Hack for the ns subsystem, with which we are incompatible + CGROUP_SUBSYS=$($_SED '/^#/d;/^ns[[:space:]]/d;s/[[:space:]].*//' /proc/cgroups | \ + (s=""; while read x; do test -n "$s" && s="$s,"; s="$s$x"; done; echo "$s")) fi findFile file "$__CONFDIR/.defaults/cgroup/inherit" "" if test -n "$file"; then