X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Ffunctions;h=c3829fa3f7ce3ff3f3a11c0c453d1ce85f5cb898;hb=259eca12e04f314357b7606e12c287d6ad140712;hp=32a1bc7b17763fc575b9d0de5d2a07fca7265486;hpb=3ca57b4545d517cb2279b2515d3da706bfafb02e;p=util-vserver.git diff --git a/util-vserver/scripts/functions b/util-vserver/scripts/functions index 32a1bc7..c3829fa 100644 --- a/util-vserver/scripts/functions +++ b/util-vserver/scripts/functions @@ -154,6 +154,9 @@ function _pkgSetVarsApt findDir APTCACHEDIR "$VDIR"/var/cache/apt findDir APTARCHIVDIR "$VDIR"/var/cache/apt/archives /var/cache/apt/archives fi + + findFile APT_CONFIG "$APTETCDIR"/apt.conf "" + test -z "$APT_CONFIG" || export APT_CONFIG } function _pkgMountBase @@ -237,27 +240,33 @@ function pkgInit function getAllVservers { local i - declare -a tmp=() + declare -a _tmp=() for i in $CONFDIR/*; do test -d "$i" || continue test ! -e "$i"/disabled || continue test -d "$i"/vdir || continue + case "$i" in + *.~*~) continue;; + esac - tmp=( "${tmp[@]}" "${i##$CONFDIR/}") + _tmp=( "${_tmp[@]}" "${i##$CONFDIR/}") done - eval $1=\$tmp + eval $1='( "${_tmp[@]}" )' } ## Usage: getVserverCtx [ []] function getVserverStatus { test -r "$1"/run || return 1 - eval read "$2" <"$1"/run + + local _ctx + read _ctx <"$1"/run + eval "$2"=\$_ctx test "$3" || return 0 - local _tmp=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$ctx" | $_WC -l ) + local _tmp=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$_ctx" | $_WC -l ) eval "$3"=\$_tmp test "$4" -a $_tmp = 0 || return 0 @@ -267,6 +276,13 @@ function getVserverStatus return 0 } +## Usage: isCtxRunning +function isCtxRunning +{ + local _tmp=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l ) + test $_tmp -gt 0 +} + ## Usage: isVserverRunning [] function isVserverRunning {