#!/bin/bash # # named This shell script takes care of starting and stopping # named (BIND DNS server). # # chkconfig: 345 55 45 # description: named (BIND) is a Domain Name Server (DNS) \ # that is used to resolve host names to IP addresses. # probe: false # Comments to support LSB init script conventions ### BEGIN INIT INFO # Provides: named $named # Required-Start: $network # Requires-Stop: $network # Should-Start: mysqld postgresql ldap # Should-Stop: mysqld postgresql ldap # Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop BIND # Description: named (BIND) is a Domain Name Server (DNS). ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network RETVAL=0 prog="named" # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0 [ -f /etc/sysconfig/named ] && . /etc/sysconfig/named [ -f /usr/sbin/named ] || exit 0 [ -f /var/lib/named/etc/named.conf ] || exit 0 start() { # Start daemons. if [ -n "`/sbin/pidof named`" ]; then gprintf "$prog: already running" echo return 1 fi gprintf "Starting %s: " $prog # prepare the chroot if needed [ -e /var/lib/named/dev/null ] || mknod -m 0666 /var/lib/named/dev/null c 1 3 [ -e /var/lib/named/dev/random ] || mknod -m 0666 /var/lib/named/dev/random c 1 8 [ -e /var/lib/named/dev/urandom ] || mknod -m 0666 /var/lib/named/dev/urandom c 1 8 # better always copy localtime so it respects the system's timezone install -m 0644 -o root -g root /etc/localtime /var/lib/named/etc/ # try to load the capability module ignore any errors. If it's not available, named will fail by itself # and log the error. see http://qa.mandriva.com/show_bug.cgi?id=21043 modprobe capability > /dev/null 2>&1 daemon named -u named -t /var/lib/named ${OPTIONS} RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/named echo return $RETVAL } stop() { # Stop daemons. gprintf "Stopping %s: " $prog /usr/sbin/rndc -c /var/lib/named/etc/rndc.conf stop "$1" RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named || { killproc named RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named echo return $RETVAL } success echo return $RETVAL } status() { /usr/sbin/rndc -c /var/lib/named/etc/rndc.conf status return $? } restart() { stop # wait a couple of seconds for the named to finish closing down sleep 2 start } reload() { /usr/sbin/rndc -c /var/lib/named/etc/rndc.conf reload "$1" >/dev/null 2>&1 || /usr/bin/killall -HUP named return $? } # See how we were called. case "$1" in start) start ;; stop) stop "$2" ;; status) status ;; restart) restart ;; condrestart) [ -f /var/lock/subsys/named ] && restart ;; reload) reload "$2" ;; *) gprintf "Usage: %s {start|stop|status|restart|condrestart|reload|probe}\n" $0 exit 1 esac