added isVserverRunning function
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 9 Oct 2003 01:38:58 +0000 (01:38 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 9 Oct 2003 01:38:58 +0000 (01:38 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@61 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/functions

index 655427a..6735f2e 100644 (file)
@@ -222,3 +222,22 @@ function getAllVservers
        eval "$var=\"$var ${i##$CONFDIR/}\""
     done
 }
+
+function isVserverRunning
+{
+    local vdir=$1
+    test -r "$vdir/run"   || return 1
+
+    local ctx
+    read ctx <"$vdir"/run || { echo "Failed to read ctx information" >&2; return 0; }
+    
+    local cnt=$($_VPS ax | $_AWK '{print $2}' | $_GREP -x "$ctx" | $_WC -l )
+
+    if test $cnt = 0; then
+       ## Remove old lock-file
+       rm -f $(readlink "$vdir/run")
+       return 1
+    else
+       return 0
+    fi
+}