#!/bin/sh
#
#  S95doinkd -- start or kill doinkd
#

if [ ! -f /usr/local/sbin/doinkd ]; then
	exit 1;
fi

# Get pid to see if doinkd is active and to kill if needed.
pid=`/usr/bin/ps -e | /usr/bin/grep doinkd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`

case "$1" in
	'start')
	# Start doinkd
		if [ -f /usr/local/sbin/doinkd ]; then
			if [ "$pid" = "" ]; then
				/usr/local/sbin/doinkd && echo "Idle daemon started"
			fi
		else
			echo "Could not find doinkd"
		fi
	;;

	'stop')
		if [ "$pid" != "" ]; then
   			kill $pid
   			echo "doinkd killed"
		fi
	;;

	'restart')
		start()
		stop()
	;;
	*)
		echo "usage: S95doinkd {start|stop|restart}"
	;;
esac
