summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-02-23 23:08:35 -0500
committerAdam <Adam@anope.org>2014-02-23 23:08:35 -0500
commit4ac3ade126728e4a4c448c7a14b5f19f90f18805 (patch)
treec644b095d6116c355908f47366123084542a5ac5 /src/tools
parent212abeb986a57c312f1a43e09509c6a8af00498c (diff)
Use a more reliable way to detect if services are running in anoperc
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/anoperc.in12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/tools/anoperc.in b/src/tools/anoperc.in
index 7acd5abf7..5f4e6c5eb 100644
--- a/src/tools/anoperc.in
+++ b/src/tools/anoperc.in
@@ -17,7 +17,7 @@
ANOPEPID="@INSTDIR@/data/services.pid"
ANOPROG="@INSTDIR@/bin/services"
LOG="@INSTDIR@/data/logs/"
-ARCVERSION="1.4"
+ARCVERSION="2"
isAnopeRunning () {
if [ ! -f $ANOPEPID ] ; then
@@ -26,8 +26,8 @@ isAnopeRunning () {
fi
PID=`cat $ANOPEPID`
-
- if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then
+ kill -0 $PID 2>/dev/null
+ if [ $? -ne 0 ] ; then
echo "Warning: Anope is not currently running"
exit 1
fi
@@ -48,7 +48,8 @@ fi
if [ "$1" = "start" ] ; then
if [ -f $ANOPEPID ] ; then
PID=`cat $ANOPEPID`
- if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then
+ kill -0 $PID 2>/dev/null
+ if [ $? -eq 0 ] ; then
echo "Warning! Anope is already running"
exit 1
fi
@@ -76,7 +77,8 @@ elif [ "$1" = "stop" ] ; then
elif [ "$1" = "status" ] ; then
if [ -f $ANOPEPID ] ; then
PID=`cat $ANOPEPID`
- if [ `ps auxw | grep $PID | grep -v -c grep` = 1 ] ; then
+ kill -0 $PID 2>/dev/null
+ if [ $? -eq 0 ] ; then
echo "Anope is currently running"
exit 0
fi