diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/anoperc.in | 84 | ||||
-rw-r--r-- | src/init.cpp | 6 |
2 files changed, 44 insertions, 46 deletions
diff --git a/src/bin/anoperc.in b/src/bin/anoperc.in index 8440a3c13..5dce8b5ef 100644 --- a/src/bin/anoperc.in +++ b/src/bin/anoperc.in @@ -17,20 +17,20 @@ ANOPEPID="@INSTDIR@/data/services.pid" ANOPROG="@INSTDIR@/bin/services" LOG="@INSTDIR@/data/logs/" -ARCVERSION="1.3" +ARCVERSION="1.4" isAnopeRunning () { -if [ ! -f $ANOPEPID ] ; then - echo "Warning: Anope is not currently running" - exit 1 -fi + if [ ! -f $ANOPEPID ] ; then + echo "Warning: Anope is not currently running" + exit 1 + fi -PID=`cat $ANOPEPID` + PID=`cat $ANOPEPID` -if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then - echo "Warning: Anope is not currently running" - exit 1 -fi + if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then + echo "Warning: Anope is not currently running" + exit 1 + fi } if [ ! -f $ANOPROG ] ; then @@ -38,44 +38,35 @@ if [ ! -f $ANOPROG ] ; then exit 1 fi - if [ "$UID" = "0" ] ; then - echo "######################################"; - echo "# Warning: Do NOT run Anope as root! #"; - echo "######################################"; - exit 1 + echo "######################################"; + echo "# Warning: Do NOT run Anope as root! #"; + echo "######################################"; + exit 1 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 - echo "Warning! Anope is already running" - exit 1 + if [ -f $ANOPEPID ] ; then + PID=`cat $ANOPEPID` + if [ `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` = 1 ] ; then + echo "Warning! Anope is already running" + exit 1 + fi fi -fi + echo "Starting Anope" shift $ANOPROG $* - sleep 1 - if [ ! -f $ANOPEPID ] ; then + + if [ "$?" -ne "0" ] ; then + echo "" echo "Unfortunately it seems Anope did not start successfully" echo "This error has been logged in your Anope Log file" echo "Located in "$LOG"" echo "This may help you diagnose the problem" echo "Further help may be available from http://www.anope.org/" exit 1 - fi - PID=`cat $ANOPEPID` - if [ ! `ps auxw | grep $ANOPROG | grep $PID | grep -v -c grep` ] ; then - echo "Unfortunately it seems Anope did not start successfully" - echo "This error has been logged in your Anope Log file" - echo "Located in "$LOG"" - echo "This may help you diagnose the problem" - echo "Further help may be available from http://www.anope.org/" - exit 1 - fi + fi elif [ "$1" = "stop" ] ; then isAnopeRunning @@ -87,7 +78,7 @@ elif [ "$1" = "status" ] ; then PID=`cat $ANOPEPID` if [ `ps auxw | grep $PID | grep -v -c grep` = 1 ] ; then echo "Anope is currently running" - exit 1 + exit 0 fi fi @@ -98,9 +89,20 @@ elif [ "$1" = "restart" ] ; then echo "Restarting Anope" kill -15 `cat $ANOPEPID` sleep 1 + shift $ANOPROG $* + if [ "$?" -ne "0" ] ; then + echo "" + echo "Unfortunately it seems Anope did not start successfully" + echo "This error has been logged in your Anope Log file" + echo "Located in "$LOG"" + echo "This may help you diagnose the problem" + echo "Further help may be available from http://www.anope.org/" + exit 1 + fi + elif [ "$1" = "rehash" ] ; then isAnopeRunning echo "Saving Databases and Rehashing Configuration" @@ -112,19 +114,13 @@ elif [ "$1" = "version" ] ; then elif [ "$1" = "help" ] ; then if [ "$2" = "paramlist" ] ; then $ANOPROG -help - else + else echo "AnopeRC is a remote control script for easy" echo "controlling of Anope from the command console" - echo "$0 start Start Anope" - echo " Additional parameters may be passed" - echo " (e.g. $0 start -nofork)" - echo " For a list type $0 $1 paramlist" + echo "$0 start Start Anope." echo "$0 stop Shutdown Anope" echo "$0 status Show Anope's Status" - echo "$0 restart Restart Anope (Databases will be saved)" - echo " Additional parameters may be passed" - echo " (e.g. $0 restart -logchan)" - echo " For a list type $0 $1 paramlist" + echo "$0 restart Restart Anope (Databases will be saved)." echo "$0 rehash Rehash Configuration and Save Databases" echo "$0 version Return Anope Version and Build Information" echo "$0 help Show this help menu" diff --git a/src/init.cpp b/src/init.cpp index cd2430f8b..e1ccf6c17 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -267,9 +267,11 @@ class SignalSigChld : public Signal void OnNotify() { - int status = 0; + int status = 0, ret = -1; wait(&status); - exit(status); + if (WIFEXITED(status)) + ret = WEXITSTATUS(status); + exit(ret); } }; #endif |