diff options
author | Adam <Adam@anope.org> | 2014-02-23 23:08:35 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-02-23 23:08:35 -0500 |
commit | 4ac3ade126728e4a4c448c7a14b5f19f90f18805 (patch) | |
tree | c644b095d6116c355908f47366123084542a5ac5 | |
parent | 212abeb986a57c312f1a43e09509c6a8af00498c (diff) |
Use a more reliable way to detect if services are running in anoperc
-rw-r--r-- | src/tools/anoperc.in | 12 |
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 |