X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Ffunctions;h=9c5a002525b091492f1bbc77d8186278fd3916d6;hb=b0a62d195efca12c5cb9e7c0b3bea3be2cd57fc9;hp=d2e00d374c8d8c3514e9e5558ec3fd85e1bd9b4d;hpb=fc28db1eb4146796ec27c2fb15780d6303120261;p=util-vserver.git diff --git a/scripts/functions b/scripts/functions index d2e00d3..9c5a002 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1,4 +1,4 @@ -# $Id: functions 2420 2006-12-09 16:02:03Z dhozac $ --*- sh -*-- +# $Id: functions 2531 2007-04-21 14:04:35Z dhozac $ --*- sh -*-- # Copyright (C) 2003,2004,2005,2006 Enrico Scholz # @@ -282,7 +282,7 @@ function set_init_cwd export INIT_CWD } -function _getVserverDir +function _setVserverDir { local vserver="$1" case "$vserver" in @@ -292,6 +292,15 @@ function _getVserverDir esac } +function _setVserverName +{ + if test -e "$VSERVER_DIR"/name; then + read VSERVER_NAME <"$VSERVER_DIR"/name + else + VSERVER_NAME=$(basename "$VSERVER_DIR") + fi +} + function _pkgMountBindDir() { test "$1" != "$2" || return 0 @@ -510,6 +519,7 @@ function isNamespaceCleanup $_VSERVER_INFO - FEATURE namespace || return 1 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1 + isAvoidNamespace "$1" && return 1 test -e "$cfgdir"/namespace-cleanup && return 0 test -e "$cfgdir"/nonamespace-cleanup -o \ -e "$__CONFDIR"/.defaults/nonamespace-cleanup && return 1 @@ -571,7 +581,7 @@ function _getProcNumberCount # Use /proc/virtual from kernel 2.6 when possible if test -d "/proc/virtual"; then - set -- $($_GREP '^PROC:' "/proc/virtual/$1/limit" 2>/dev/null) + set -- $($_GREP '^Tasks:' "/proc/virtual/$1/status" 2>/dev/null) _gp_procnr_cnt=$2 else _gp_procnr_cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l ) @@ -713,8 +723,12 @@ function setDefaultTTY "$__CONFDIR/.defaults/apps/init/tty" \ $2 /dev/null - exec <$ttyname - exec &>$ttyname + if test -f "$ttyname"; then + exec >$ttyname 2>&1 } ## Usage: killContext [] @@ -844,9 +858,11 @@ function vshelper.doSanityCheck vshelper=$(cat "$proc_file") $_CMP -s "$vshelper" "$_VSHELPER" || { + local readable="" + test -r "$vshelper" && readable=1 warnings=( "${warnings[@]}" $"The configured vshelper '$vshelper' does not match the 'vshelper' - script of the util-vserver package" + script of the util-vserver package.${readable:+ Maybe you have two versions installed?}" ) solution_disable=1 solution_sysctl=1 @@ -1062,6 +1078,12 @@ function vshelper.doStopSync test ! -p "$VSHELPER_STOP_SYNC" || echo stopped > "$VSHELPER_STOP_SYNC" } +function vshelper.isStopSync +{ + test -p "$VSHELPER_STOP_SYNC" || return 1 + return 0 +} + function _rpmFake.getCapFlags { local ctx=$1