#! /bin/sh
#
# mydns		Start the MyDNS server
#
# Author:	Philipp Kern <phil@philkern.de>.
#		Based upon skeleton 1.9.4 by Miquel van Smoorenburg
#		<miquels@cistron.nl> and Ian Murdock <imurdock@gnu.ai.mit.edu>.
#

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mydns
CONFIG=/etc/mydns.conf
NAME=mydns
DESC="DNS server"

SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

# Start only if a configuration file is present.
test -e $CONFIG || exit 0

case "$1" in
  start)
	echo -n "Starting $DESC: $NAME"
	start-stop-daemon --start --quiet \
		--exec $DAEMON -- -b
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC: $NAME"
	start-stop-daemon --stop --oknodo --quiet \
		--exec $DAEMON
	echo "."
	;;
  reload|force-reload)
	echo -n "Reloading $DESC configuration..."
	start-stop-daemon --stop --signal HUP --quiet \
		--exec $DAEMON
	echo "done."
  	;;
  restart)
	echo -n "Restarting $DESC: $NAME"
	start-stop-daemon --stop --quiet --oknodo \
		--exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet \
		--exec $DAEMON -- -b
	echo "."
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
