#! /bin/sh
#
# crond          Start/Stop the cron clock daemon.
#
# chkconfig: 345 75 35
# description: cron is a standard UNIX program that runs user-specified \
#              programs at periodic scheduled times. vixie cron adds a \
#              number of features to the basic UNIX cron, including better \
#              security and more powerful configuration options.
# processname: diald
# config: /etc/diald/diald.conf
# pidfile: /var/run/diald/diald.pid
# fifofile: /var/run/diald/diald.ctl

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

. /etc/sysconfig/diald

RETVAL=0

start()
{
	start_daemon  --lockfile "$LOCKFILE" --pidfile "$PIDFILE" --expect-user root -- diald -f "$CONFFILE" fifo "$FIFOFILE" $EXTRAPARAM
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root diald
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user root diald
		RETVAL=$?
		;;
	*)
		echo "Usage: ${0##*/} {start|stop|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
