- #!/bin/bash
- # named This shell script takes care of starting and stopping
- # named (BIND DNS server).
- # chkconfig: - 13 87
- # description: named (BIND) is a Domain Name Server (DNS) \
- # that is used to resolve host names to IP addresses.
- # Source function library.
- . /etc/rc.d/init.d/functions
- # Source networking configuration.
- [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
- rootdir='/usr/local/bind'
- named_conf='/usr/local/bind/etc/named.conf'
- RETVAL=0
- named='named'
- prog=$named
- pidofnamed() {
- pidofproc -p "$roodir/etc/named.pid" "$named";
- }
- named_conf=${named_c_option:-$rootdir/etc/named.conf};
- start() {
- # Start daemons.
- echo -n $"Starting $named: "
- if [ -n "`pidofnamed`" ]; then
- echo -n $"$named: already running"
- failure
- echo
- return 1
- fi
- /usr/local/bind/sbin/named -n 1 -uroot -c /usr/local/bind/etc/named.conf
- RETVAL=0
- if [ $RETVAL -eq 0 ]; then
- success
- else
- failure
- fi;
- echo
- return $RETVAL
- }
- stop() {
- # Stop daemons.
- echo -n $"Stopping $named: "
- $rootdir/sbin/rndc stop >/dev/null 2>&1
- RETVAL=$?
- [ "$RETVAL" -eq 0 ] || \
- killproc -p "$rootdir/etc/named.pid" "$named" -TERM >/dev/null 2>&1
- timeout=0
- RETVAL=0
- if [ $RETVAL -eq 0 ]; then
- success
- else
- failure
- fi;
- echo
- return $RETVAL
- }
- restart() {
- stop
- # wait a couple of seconds for the named to finish closing down
- sleep 2
- start
- }
- status() {
- $rootdir/sbin/rndc status
- status $rootdir/sbin/$named
- return $?
- }
- reload() {
- echo -n $"Reloading $named: "
- RETVAL=$?
- [ "$RETVAL" -eq 0 ] && success $"$named reload" || failure $"$named reload"
- echo
- return $RETVAL
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status
- ;;
- restart)
- restart
- ;;
- reload)
- reload
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload}"
- exit 2
- esac
- exit $?