X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=scripts%2Ffunctions;h=0edb7a3e73c3f210540d1c97c19cb6c43fdb5693;hb=9a44bc6e4f5be84c8cc9fe9a5054c86fde4e65e3;hp=51318e7d3cda4d10cf2ede43671a1d23bc779031;hpb=2b8e0679960b50d6511b2ecde8b69afeb2f7402e;p=util-vserver.git diff --git a/scripts/functions b/scripts/functions index 51318e7..0edb7a3 100644 --- a/scripts/functions +++ b/scripts/functions @@ -268,13 +268,27 @@ function unlock _VS_LOCKS="$@" } +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 _getVserverDir { 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 } @@ -496,10 +510,10 @@ function isNamespaceCleanup $_VSERVER_INFO - FEATURE namespace || return 1 cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || return 1 - test -e "$cfgdir"/nonamespace-cleanup && return 1 - test -e "$__CONFDIR"/.defaults/namespace-cleanup -o \ - -e "$cfgdir"/namespace-cleanup && return 0 - return 1 + test -e "$cfgdir"/namespace-cleanup && return 0 + test -e "$cfgdir"/nonamespace-cleanup -o \ + -e "$__CONFDIR"/.defaults/nonamespace-cleanup && return 1 + return 0 } ## Usage: getAllVservers [*] @@ -557,7 +571,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 +636,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 @@ -711,6 +729,11 @@ function killContext #$_VKILL -s CONT --xid "$1" 1 &>/dev/null || : } +function useVlogin +{ + test ! -e "$__CONFDIR/.defaults/apps/vlogin/disable" +} + ## Usage: pkgmgmt.guessStyle function pkgmgmt.guessStyle() { @@ -821,9 +844,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