diff options
| author | Adam <Adam@anope.org> | 2012-11-22 00:50:33 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-11-22 00:50:33 -0500 |
| commit | d33a0f75a5c0c584fbb7cc0076da36d494f39494 (patch) | |
| tree | 7b2274cc833c793c0f5595660cbd4d715de52ffd /src/tools | |
| parent | 368d469631763e9c8bf399980d0ac7c5b5664d39 (diff) | |
Pretty large coding style cleanup, in source doc
cleanup, and allow protocol mods to depend on each
other
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/tools/anoperc.in | 135 |
2 files changed, 143 insertions, 0 deletions
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 88fc37ffc..613e4ffc6 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -34,6 +34,14 @@ foreach(SRC ${TOOLS_SRCS}) endif(NOT SKIP) endforeach(SRC) +# If not on Windows, generate anoperc and install it along with mydbgen +if(NOT WIN32) + configure_file(${Anope_SOURCE_DIR}/src/tools/anoperc.in ${Anope_BINARY_DIR}/src/tools/anoperc) + install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc + DESTINATION ${BIN_DIR} + ) +endif(NOT WIN32) + # On non-Windows platforms, if RUNGROUP is set, change the permissions of the tools directory if(NOT WIN32 AND RUNGROUP) install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"\${CMAKE_INSTALL_PREFIX}/bin\")") diff --git a/src/tools/anoperc.in b/src/tools/anoperc.in new file mode 100644 index 000000000..9a71a22c3 --- /dev/null +++ b/src/tools/anoperc.in @@ -0,0 +1,135 @@ +#!/bin/sh +# +# Configuration script for Services +# +# (C) 2003-2012 Anope Team +# Contact us at team@anope.org +# +# Please read COPYING and README for further details. +# +# Based on the original code of Epona by Lara. +# Based on the original code of Services by Andy Church. +# +# + + + +ANOPEPID="@INSTDIR@/data/services.pid" +ANOPROG="@INSTDIR@/bin/services" +LOG="@INSTDIR@/data/logs/" +ARCVERSION="1.4" + +isAnopeRunning () { + if [ ! -f $ANOPEPID ] ; then + echo "Warning: Anope is not currently running" + exit 1 + fi + + 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 [ ! -f $ANOPROG ] ; then + echo "Error: $ANOPROG cannot be accessed" + exit 1 +fi + +if [ "$UID" = "0" ] ; then + 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 + fi + fi + + echo "Starting Anope" + 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" = "stop" ] ; then + isAnopeRunning + echo "Terminating Anope" + kill -15 `cat $ANOPEPID` + +elif [ "$1" = "status" ] ; then + if [ -f $ANOPEPID ] ; then + PID=`cat $ANOPEPID` + if [ `ps auxw | grep $PID | grep -v -c grep` = 1 ] ; then + echo "Anope is currently running" + exit 0 + fi + fi + + echo "Anope is not currently running" + +elif [ "$1" = "restart" ] ; then + isAnopeRunning + 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" + kill -1 `cat $ANOPEPID` + +elif [ "$1" = "version" ] ; then + $ANOPROG -version + +elif [ "$1" = "help" ] ; then + if [ "$2" = "paramlist" ] ; then + $ANOPROG -help + else + echo "AnopeRC is a remote control script for easy" + echo "controlling of Anope from the command console" + 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 "$0 rehash Rehash Configuration and Save Databases" + echo "$0 version Return Anope Version and Build Information" + echo "$0 help Show this help menu" + echo "If you need further help please check the /docs/" + echo "folder or make use of our extensive online support at" + echo "http://www.anope.org/" + fi + +else + echo "Anope Remote Control ($ARCVERSION)" + echo "Usage: $0 [start|stop|status|restart|rehash|version|help]" +fi |
