moved isAvoidNamespace() into main-functions file
[util-vserver.git] / util-vserver / scripts / functions
index 1b94ce4..a4a02a2 100644 (file)
@@ -78,7 +78,7 @@ function _pkgMountBindDir()
 function _pkgSetVarsBase
 {
     case "$vserver" in
-       /*)
+       ./*|/*)
            if test -d "$vserver/vdir"; then
                BASEDIR=$vserver
                VDIR=$(getPhysicalDir "$vserver/vdir")
@@ -237,6 +237,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
@@ -260,10 +267,13 @@ 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
@@ -273,6 +283,13 @@ function getVserverStatus
     return 0
 }
 
+## Usage: isCtxRunning <ctx>
+function isCtxRunning
+{
+    local _tmp=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$1" | $_WC -l )
+    test $_tmp -gt 0
+}
+
 ## Usage: isVserverRunning <vdir> [<ctx-varname>]
 function isVserverRunning
 {