#!/bin/sh
#
#  Last Modified 01-07-2003 Ethan Galstad (nagios@nagios.org)
#  Notes
#  This script takes care of starting and stopping the NSCA daemon.
#  Modeled after init script for NRPE written by jaclu@grm.se
#
# chkconfig: 2345 80 30
# description: nscamd is a daemon for accepting service check results \
#              by IP multicast from applications running on other hosts.
# processname: nscamd
# config: /usr/local/nagios/etc/nscamd.cfg

# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/functions ]; then
. /etc/rc.d/functions
fi

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

NscamdBin=/usr/local/nagios/bin/nscamd
NscamdCfg=/usr/local/nagios/etc/nscamd.cfg
LockFile=/var/lock/subsys/nscamd

# See how we were called.
case "$1" in
  start)
	# Start daemons.
	echo -n "Starting nscamd: "
	daemon $NscamdBin -s -c $NscamdCfg
	RETVAL=$?
	echo
	touch $LockFile
	;;
  stop)
	# Stop daemons.
	echo -n "Shutting down nscamd: "
	killproc nscamd
	echo
	rm -f $LockFile
	;;
  restart)
	$0 stop
	$0 start
	;;
  status)
	status nscamd
	;;
  *)
	echo "Usage: nscamd {start|stop|restart|status}"
	exit 1
esac

exit 0


