File pnp4nagios-init of Package pnp4nagios
#! /bin/sh
# Copyright (c) 2007 SuSE Linux AG Nuernberg, Germany.
#
# Author: Lars Vogdt
#
# /etc/init.d/npcd
#
# and symbolic its link
#
# /usr/sbin/rcnpcd
#
# System startup script for ncpd
#
### BEGIN INIT INFO
# Provides: npcd
# Required-Start: $local_fs $remote_fs monitoring_daemon
# Required-Stop: $local_fs $remote_fs monitoring_daemon
# Should-Start: httpd2
# Should-Stop: $null
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Nagios-Perfdata-C-Daemon
# Description: Starts and stops the Nagios-Perfdata-C-Daemon
# to provide an asynchronous mode to handle performance data
# with nagios.
### END INIT INFO
. /etc/rc.status
NPCD_BIN=/usr/bin/npcd
NPCD_CFG=/etc/pnp4nagios/npcd.cfg
PID=/var/run/npcd.pid
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x $NPCD_BIN || { echo "$NPCD_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 3; fi; }
# Check for existence of needed config file and read it
test -r $NPCD_CFG || { echo "$NPCD_CFG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 3; fi; }
# Reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting npcd "
startproc -p $PID $NPCD_BIN -d -f $NPCD_CFG
rc_status -v
;;
stop)
echo -n "Shutting down npcd "
killproc -TERM $NPCD_BIN
for i in 1 2 3 4 5 6 7 8 9 10 ; do
if $0 status > /dev/null; then
echo -n '.'
killproc -TERM $NPCD_BIN
sleep 1
else
break
fi
done
rc_status -v
;;
try-restart|condrestart)
## Do a restart only if the service was active before.
## Note: try-restart is now part of LSB (as of 1.9).
## RH has a similar command named condrestart.
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 reload
rc_status
;;
reload)
echo -n "Reload service npcd "
killproc -HUP $NPCD_BIN
touch $PID
rc_status -v
;;
status)
echo -n "Checking for service npcd "
checkproc $NPCD_BIN
rc_status -v
;;
probe)
test $NPCD_CFG -nt $PID && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit