#!/bin/sh
#
# fishpoll: Fishpoll daemon
#
# chkconfig: - 99 05
# description:  fishpolld is a daemon to run scripts when triggered from the network
#
# processname: fishpolld
# pidfile: /var/run/fishpolld.pid
#
### BEGIN INIT INFO
# Provides: fishpoll
# Required-Start: $syslog $network
# Required-Stop: $syslog $network
# Description: fishpolld is a daemon to run scripts when triggered from the network
### END INIT INFO

prefix=/usr
exec_prefix=/usr
sbindir=/usr/sbin

FISHPOLLD_BIN=${sbindir}/fishpolld

# Source function library.
. /etc/rc.d/init.d/functions

# Source network configuration
. /etc/sysconfig/network

processname=fishpolld
servicename=fishpoll
pidfile=/var/run/fishpolld.pid

RETVAL=0

start()
{
        if [ -e /etc/sysconfig/fishpolld ] ; then
	   . /etc/sysconfig/fishpolld
	fi
	echo -n $"Starting Fishpoll daemon: "
        daemon $FISHPOLLD_BIN --pid-file=$pidfile $OPTIONS
	echo

	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
}

stop()
{
	echo -n $"Stopping Fishpoll daemon: "
	killproc -p $pidfile $servicename
	RETVAL=$?
	echo
	if [ $RETVAL -eq 0 ]; then
		rm -f /var/lock/subsys/$servicename
		rm -f $pidfile
	fi
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status -p $pidfile $processname
		RETVAL=$?
		;;
	restart)
		stop
		start
		;;
	condrestart)
		if [ -f /var/lock/subsys/$servicename ]; then
			stop
			start
		fi
		;;
	*)
		echo $"Usage: $0 {start|stop|status|restart|condrestart}"
		;;
esac
exit $RETVAL
