#!/bin/sh
# Init script for ELOG.
# Recai Oktas <roktas@omu.edu.tr>

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/elogd
NAME=elogd
DESC="ELOG daemon"

# Always run as daemon.
ARGS="-D"

# Admin might change some command line options without touching this script.
if [ -f /etc/default/elog ]; then
	. /etc/default/elog
fi

test -f $DAEMON || exit 0

set -e

case "$1" in
	start)
		echo -n "Starting $DESC: $NAME"
		start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
			--exec $DAEMON -- $ARGS >/dev/null
		echo "."
		;;
	stop)
		echo -n "Stopping $DESC: $NAME"
		start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
			--exec $DAEMON -- $ARGS >/dev/null
		echo "."
		;;
	reload)
		# Do nothing since ELOG daemon responds to 
		# the changes in conffile directly.
		;;
	restart|force-reload)
		echo -n "Restarting $DESC: $NAME"
		start-stop-daemon --stop --quiet --pidfile \
			/var/run/$NAME.pid --exec $DAEMON -- $ARGS >/dev/null
		sleep 1
		start-stop-daemon --start --quiet --pidfile \
			/var/run/$NAME.pid --exec $DAEMON -- $ARGS >/dev/null
		echo "."
		;;
	*)
		N=/etc/init.d/$NAME
		echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
		exit 1
		;;
esac

exit 0
