cvsdist 2f7f4b
#!/bin/bash
cvsdist 2f7f4b
#
cvsdist 2f7f4b
# named           This shell script takes care of starting and stopping
cvsdist 2f7f4b
#                 named (BIND DNS server).
cvsdist 2f7f4b
#
cvsdist 2f7f4b
# chkconfig: - 55 45
cvsdist 2f7f4b
# description: named (BIND) is a Domain Name Server (DNS) \
cvsdist 2f7f4b
# that is used to resolve host names to IP addresses.
cvsdist 2f7f4b
# probe: true
cvsdist 2f7f4b
cvsdist 2f7f4b
# Source function library.
cvsdist 2f7f4b
. /etc/rc.d/init.d/functions
cvsdist 2f7f4b
cvsdist 2f7f4b
# Source networking configuration.
cvsdist 4f506d
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
cvsdist 2f7f4b
cvsdist 78e1f2
RETVAL=0
cvsdist 78e1f2
prog="named"
cvsdist 78e1f2
cvsdist 2f7f4b
# Check that networking is up.
cvsdist aed712
[ "${NETWORKING}" = "no" ] && exit 0
cvsdist aed712
cvsdist 78e1f2
[ -r /etc/sysconfig/named ] && . /etc/sysconfig/named
cvsdist 2f7f4b
cvsdist 78e1f2
[ -x /usr/sbin/named ] || exit 0 
cvsdist 2f7f4b
cvsdist 78e1f2
[ -r ${ROOTDIR}/etc/named.conf ] || exit 0 
cvsdist 2f7f4b
cvsdist 2f7f4b
cvsdist 2f7f4b
start() {
cvsdist 2f7f4b
        # Start daemons.
cvsdist 0a52a5
	if [ -n "`/sbin/pidof named`" ]; then
cvsdist 0a52a5
		echo -n $"$prog: already running"
cvsdist 0a52a5
		return 1
cvsdist 0a52a5
	fi
cvsdist aed712
        echo -n $"Starting $prog: "
cvsdist aed712
	if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
cvsdist aed712
		OPTIONS="${OPTIONS} -t ${ROOTDIR}"
cvsdist aed712
	fi
cvsdist 78e1f2
	daemon /usr/sbin/named -u named ${OPTIONS}
cvsdist 2f7f4b
	RETVAL=$?
cvsdist 78e1f2
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named 
cvsdist 4f506d
        echo
cvsdist 2f7f4b
	return $RETVAL
cvsdist 2f7f4b
}
cvsdist 2f7f4b
stop() {
cvsdist 2f7f4b
        # Stop daemons.
cvsdist aed712
        echo -n $"Stopping $prog: "
cvsdist aa0a29
	/usr/sbin/rndc stop
cvsdist 2f7f4b
	RETVAL=$?
cvsdist aa0a29
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named || {
cvsdist aa0a29
        	killproc named
cvsdist aa0a29
		RETVAL=$?
cvsdist aa0a29
		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
cvsdist 4f506d
		echo
cvsdist 4f506d
		return $RETVAL 
cvsdist aa0a29
	}
cvsdist 4f506d
	success
cvsdist 2f7f4b
        echo
cvsdist 2f7f4b
	return $RETVAL
cvsdist 2f7f4b
}
cvsdist 2f7f4b
rhstatus() {
cvsdist 366442
	/usr/sbin/rndc status
cvsdist 366442
	return $?
cvsdist 2f7f4b
}	
cvsdist 2f7f4b
restart() {
cvsdist 2f7f4b
	stop
cvsdist 78e1f2
# wait a couple of seconds for the named to finish closing down
cvsdist 78e1f2
	sleep 2
cvsdist 2f7f4b
	start
cvsdist 2f7f4b
}	
cvsdist 2f7f4b
reload() {
cvsdist 78e1f2
        echo -n $"Reloading $prog: "
cvsdist aa0a29
	/usr/sbin/rndc reload >/dev/null 2>&1 || /usr/bin/killall -HUP `/sbin/pidof -o %PPID named`
cvsdist 78e1f2
	[ "$?" -eq 0 ] && success $"$prog reload" || failure $"$prog reload"
cvsdist 78e1f2
        echo
cvsdist 2f7f4b
	return $?
cvsdist 2f7f4b
}
cvsdist 2f7f4b
probe() {
cvsdist 2f7f4b
	# named knows how to reload intelligently; we don't want linuxconf
cvsdist 2f7f4b
	# to offer to restart every time
cvsdist aed712
	/usr/sbin/rndc reload >/dev/null 2>&1 || echo start
cvsdist 2f7f4b
	return $?
cvsdist 2f7f4b
}  
cvsdist 2f7f4b
cvsdist 2f7f4b
# See how we were called.
cvsdist 2f7f4b
case "$1" in
cvsdist 2f7f4b
	start)
cvsdist 2f7f4b
		start
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	stop)
cvsdist 2f7f4b
		stop
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	status)
cvsdist 2f7f4b
		rhstatus
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	restart)
cvsdist 2f7f4b
		restart
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	condrestart)
cvsdist 31bdca
		if [ -e /var/lock/subsys/named ]; then restart; fi
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	reload)
cvsdist 2f7f4b
		reload
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	probe)
cvsdist 2f7f4b
		probe
cvsdist 2f7f4b
		;;
cvsdist 2f7f4b
	*)
cvsdist aed712
        	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|probe}"
cvsdist 2f7f4b
		exit 1
cvsdist 2f7f4b
esac
cvsdist 2f7f4b
cvsdist 2f7f4b
exit $?
cvsdist 2f7f4b