X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Ffunctions;h=4002642692d29a8fc9fbcbb298e937b512ff4620;hb=2c1197fc141259181542b9bcc38380c699c433d6;hp=b9212d807c8981c3d6f7f5231ff1d540fcba6a2c;hpb=182aac6bb24727e598bceb8e6d572169f6e83d39;p=util-vserver.git diff --git a/util-vserver/scripts/functions b/util-vserver/scripts/functions index b9212d8..4002642 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") @@ -102,7 +102,7 @@ function _pkgSetVarsBase } VDIR=$BASEDIR/vdir - test -d "$VDIR" || VDIR=/vservers/$vserver + test -d "$VDIR" || VDIR=$DEFAULT_VSERVERDIR/$vserver VDIR=$(getPhysicalDir "$VDIR") PKGDIR=$BASEDIR/apps/pkgmgmt @@ -176,6 +176,9 @@ function _pkgMountRPM "$_SECURE_MOUNT" --chroot "$VDIR" -n --secure --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint" test -z "$WORKAROUND_106057" || mount -n --bind "$RPMSTATEDIR" "$_rpmdb_mntpoint" + + test -e "$VDIR"/proc/self/status || \ + "$_SECURE_MOUNT" --chroot "$VDIR" -n --secure -t proc none /proc } function _pkgSetEnvBase @@ -237,6 +240,13 @@ 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 @@ -246,6 +256,9 @@ function getAllVservers test -d "$i" || continue test ! -e "$i"/disabled || continue test -d "$i"/vdir || continue + case "$i" in + *.~*~) continue;; + esac _tmp=( "${_tmp[@]}" "${i##$CONFDIR/}") done @@ -257,19 +270,29 @@ function getAllVservers 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 - _tmp=$(readlink "$1/run") + _tmp=$($_READLINK "$1/run") test "$_tmp" || return 1 rm -f "$_tmp" 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 {