X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Ffunctions;h=a4a02a2aecfe23c4e122bad1f178e69b4656d5b4;hb=bb23ba0d1b3ab139512fd137a5e7f7241a49c2d6;hp=f9215f760517eb70e7d9ab2ccefaff78cecd5045;hpb=0125615e9a648dbfd11f4ddfa6179f1ee98a25fe;p=util-vserver.git diff --git a/util-vserver/scripts/functions b/util-vserver/scripts/functions index f9215f7..a4a02a2 100644 --- a/util-vserver/scripts/functions +++ b/util-vserver/scripts/functions @@ -78,7 +78,7 @@ function _pkgMountBindDir() function _pkgSetVarsBase { case "$vserver" in - /*) + ./*|/*) if test -d "$vserver/vdir"; then BASEDIR=$vserver VDIR=$(getPhysicalDir "$vserver/vdir") @@ -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 @@ -234,30 +237,43 @@ function pkgInit _PKG_VSERVER=$vserver } +function isAvoidNamespace +{ + test ! -e "$1"/namespace || return 1 + test -e "$CONFDIR"/.defaults/nonamespace -o \ + -e "$1"/nonamespace +} + 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 +283,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 { @@ -293,3 +316,32 @@ function getFileArray local IFS=$_VS_NEWLINE eval "$1"='( $(< "$2") )' } + +function checkComponents +{ + local i + local msg=$1 + local x_failed= + + shift + + for i; do + local failed= + case "$i" in + core) test -x "$_CHBIND" || failed=1;; + build) test -x "$_VSERVER_BUILD" || failed=1;; + sysv) test -x "$INITRDDIR/vserver" || failed=1;; + devel) test -d "$INCLUDEDIR/vserver.h" || failed=1;; + *) echo "Unknown component '$i'" + return false + ;; + esac + + test -z "$failed" || { + echo "$msg: $i" + x_failed=1 + } + done + + test -z "$x_failed" +}