#! /bin/sh
# chkconfig: - 65 50
# description:  mydns server.
# mydns         Start the MyDNS server
set -e
PATH=/usr/local/mydns/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mydns
DAEMON=/usr/local/mydns/sbin/$NAME
DESC="MyDNS Server"
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        $DAEMON --background
        echo "."
        ;;
  stop)
        echo "Stopping $DESC: $NAME."
        kill -9 `pidof $NAME` &> /dev/null
        ;;
  restart)
        echo "Restarting $DESC: $NAME."
        $0 stop && sleep 1
        $0 start
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        exit 1
        ;;
esac
exit 0