]> git.pld-linux.org Git - packages/nagios-nrpe.git/blobdiff - nrpe.init
up to 3.0.1 (2016-09-08)
[packages/nagios-nrpe.git] / nrpe.init
old mode 100644 (file)
new mode 100755 (executable)
index aa03c26..4cba6ef
--- a/nrpe.init
+++ b/nrpe.init
@@ -3,15 +3,14 @@
 #  Created 2000-01-03 by jaclu@grm.se
 #  Rewritten for PLD 2004-06-02 by patrys@pld-linux.org
 #
-# nrpe          This shell script takes care of starting and stopping
-#               nrpe.
+# nrpe         This shell script takes care of starting and stopping
+#              nrpe.
 #
-# chkconfig: 2345 80 30
-# description: nrpe is a daemon for a remote nagios server, \
-#              running nagios plugins on this host.
-# processname: nrpe
-# config: /usr/local/nagios/etc/nrpe.cfg
-
+# chkconfig:   2345 80 30
+# description: nrpe is a daemon for a remote nagios server, \
+#              running nagios plugins on this host.
+# processname: nrpe
+# config:      /etc/nagios/nrpe.cfg
 
 . /etc/rc.d/init.d/functions
 
 # Check that networking is up.
 if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
-               msg_network_down "nrpe"
+               msg_network_down "Nagios NRPE daemon"
                exit 1
        fi
 else
        exit 0
 fi
 
-case "$1" in
-  start)
+pidfile=/var/run/nrpe/nrpe.pid
+
+start() {
        if [ -f /var/lock/subsys/nrpe ]; then
-               msg_already_running "nrpe"
-       else
-               msg_starting "nrpe"
-               daemon nrpe -c /etc/nagios/nrpe.cfg -d
-               touch /var/lock/subsys/nrpe
+               msg_already_running "Nagios NRPE daemon"
+               return
+       fi
+
+       msg_starting "Nagios NRPE daemon"
+       daemon /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nrpe
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/nrpe ]; then
+               msg_not_running "Nagios NRPE daemon"
+               return
+       fi
+
+       msg_stopping "Nagios NRPE daemon"
+       killproc --pidfile $pidfile nrpe
+       rm -f /var/lock/subsys/nrpe
+}
+
+condrestart() {
+       if [ ! -f /var/lock/subsys/nrpe ]; then
+               msg_not_running "Nagios NRPE daemon"
+               RETVAL=$1
+               return
        fi
+
+       stop
+       start
+}
+
+RETVAL=0
+case "$1" in
+  start)
+       start
        ;;
   stop)
-       if [ -f /var/lock/subsys/nrpe ]; then
-               msg_stopping "nrpe"
-               killproc nrpe
-               rm -f /var/lock/subsys/nrpe
-       else
-               msg_not_running "nrpe"
-       fi
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
        ;;
   status)
-       status nrpe
+       status --pidfile $pidfile nrpe
+       exit $?
        ;;
   *)
-       echo "Usage: nrpe {start|stop|restart|status}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
 esac
 
-exit 0
+exit $RETVAL
This page took 0.155796 seconds and 4 git commands to generate.