#!/bin/sh
#
# MyDNS Server		Start the MyDNS server.
#

# Clear our environment so we don't leak.
unset `env | sed s/=.*//`
NAME=mydns
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/mydns
PIDFILE=/var/run/$NAME.pid
CONF=/etc/mydns.conf

trap "" 1
export LANG=C
export PATH

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting DNS server: $NAME"
    start-stop-daemon --start --quiet --exec /usr/sbin/mydns -- -b
    echo "."
    ;;
  stop)
    echo -n "Stopping DNS server: $NAME"
    start-stop-daemon --stop --quiet --exec /usr/sbin/mydns
    echo "."
    ;;
  restart)
    echo -n "Restarting DNS server: $NAME"
    start-stop-daemon --stop --quiet --exec /usr/sbin/mydns
    start-stop-daemon --start --quiet --exec /usr/sbin/mydns -- -b
    echo "."
    ;;
  reload|force-reload)
    echo -n "Reloading config file for DNS server: $NAME"
    start-stop-daemon --stop --signal HUP --exec /usr/sbin/mydns
    echo "."
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
  esac
exit 0
