From 0436b01662c9f461544235dfc4d026ade36d3f1f Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Thu, 9 Oct 2003 01:38:58 +0000 Subject: [PATCH] added isVserverRunning function git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@61 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/scripts/functions | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/util-vserver/scripts/functions b/util-vserver/scripts/functions index 655427a..6735f2e 100644 --- a/util-vserver/scripts/functions +++ b/util-vserver/scripts/functions @@ -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 +} -- 1.8.1.5