#!/bin/bash ### BEGIN INIT INFO # Provides: NRPE # Required-Start: $syslog # Required-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: NRPE Init script # Description: NRPE Init script # ### END INIT INFO PID=/var/run/nrpe.pid not_working() { echo "NRPE daemon isn't working ..." } working() { echo "NRPE is working .. Not starting" } starting(){ echo "Starting NRPE daemon ..." } stopping(){ echo "Stopping NRPE daemon ..." } start() { if [ -e $PID ]; then working else starting /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d fi } stop() { if [ -e $PID ]; then stopping kill `cat /var/run/nrpe.pid` rm /var/run/nrpe.pid else not_working fi } restart() { if [ -e $PID ]; then stop else not_working fi start } usage(){ echo "$0 {start|stop|restart}" } case "$1" in start) start;; stop) stop;; restart) restart;; *) usage;; esac