#!/bin/sh

### BEGIN INIT INFO
# Provides:            bind
# Required-Start:      $time $network
# Should-Start:
# Required-Stop:       $network
# Should-Stop:         $remote_fs
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   DNS Daemon
# Description:         Provides a local DNS daemon
### END INIT INFO

. /lib/lsb/init-functions
[ -r /etc/default/named ] && . /etc/default/named

NAME="named"
DAEMON="/usr/sbin/named"
PIDFILE="/var/run/named.pid"

case "$1" in
  start)
    log_init_msg "Starting named"
    start_daemon "$DAEMON" "$NAMEDOPTS" && log_success_msg || log_failure_msg
    ;;
  stop)
    log_init_msg "Stopping named"
    killproc -p "$PIDFILE" "$DAEMON" && log_success_msg || log_failure_msg
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  reload)
    log_init_msg "Reloading named"
    killproc -p "$PIDFILE" "$DAEMON" -HUP && log_success_msg || log_failure_msg
    ;;
  status)
    status_of_proc -p "$PIDFILE" "$DAEMON"
    ;;

  *)
    echo "Usage: $0 {start|stop|restart|reload|status}"
    exit 1
    ;;
esac
