#!/bin/sh
# chkconfig: 2345 50 50
### BEGIN INIT INFO
# Provides:          bind named
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start bind at boot time
# Description:       Enable service provided by bind.
# X-Start-Before:    
# X-Stop-After:      
# X-Timesys-Start-Number:  50
# X-Timesys-Stop-Number:  50
### END INIT INFO

set -e

PATH=/usr/bin:/bin:/usr/sbin:/sbin
CONFIG_FILE=/etc/named.conf
DAEMON=named
PID_FILE=/var/run/named.pid
DESC="BIND named daemon"

case "$1" in
    start)
        echo -n "Starting named: "
        $DAEMON && \
          echo '[ OK ]' || echo '[FAIL]'
    ;;
    stop)
        if [ -f $PID_FILE ]; then
            echo -n "Stopping named: "
            read PID < $PID_FILE
            kill $PID && \
              echo '[ OK ]' || echo '[FAIL]'
        else
            echo "pid file not found... is named running?"
        fi
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "usage: $0 {start|stop|restart}"
    ;;
esac
