X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Ffunctions;h=fe7521b769504d05ebf509c84cf2e2e522f85de4;hb=63083b4ea0b6bba6c354c6df0ee745b21307b7da;hp=8f73ec8eac3f2ed83dfb201fde604eb02d9113a7;hpb=da54055d8657f709741f35ff0522bfeb7903538f;p=util-vserver.git diff --git a/scripts/functions b/scripts/functions index 8f73ec8..fe7521b 100644 --- a/scripts/functions +++ b/scripts/functions @@ -268,16 +268,39 @@ function unlock _VS_LOCKS="$@" } -function _getVserverDir +function get_init_cwd +{ + if test -n "$INIT_CWD"; then + echo "$INIT_CWD" + else + pwd + fi +} +function set_init_cwd +{ + INIT_CWD="`pwd`" + export INIT_CWD +} + +function _setVserverDir { local vserver="$1" case "$vserver" in - ./*) VSERVER_DIR=`pwd`/$vserver ;; - /*) VSERVER_DIR=$vserver ;; - *) VSERVER_DIR=$__CONFDIR/$vserver;; + ./*) VSERVER_DIR="`get_init_cwd`/$vserver";; + /*) VSERVER_DIR="$vserver" ;; + *) VSERVER_DIR="$__CONFDIR/$vserver" ;; 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 @@ -496,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 @@ -557,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 ) @@ -622,13 +646,17 @@ function getFileValue eval read "$_gfv_var" <"$_gfv_file" } -## Called as 'getFileArray ' +## Called as 'getFileArray +' function getFileArray { - test -r "$2" || return 1 - + local _gfa_var=$1 + local _gfa_file + shift + + findFile _gfa_file "$@" '' + test -n "$_gfa_file" -a -r "$_gfa_file" || return 0 local IFS=$_VS_NEWLINE - eval "$1"='( $(< "$2") )' + eval "$_gfa_var"='( $(< "$_gfa_file") )' } function checkComponents @@ -695,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 [] @@ -826,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 @@ -1044,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