|
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 |
2f7f4b |
. /etc/sysconfig/network
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
# Check that networking is up.
|
|
cvsdist |
aed712 |
[ "${NETWORKING}" = "no" ] && exit 0
|
|
cvsdist |
aed712 |
|
|
cvsdist |
aed712 |
[ -f /etc/sysconfig/named ] && . /etc/sysconfig/named
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
[ -f /usr/sbin/named ] || exit 0
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
a99a1d |
[ -f ${ROOTDIR}/etc/named.conf ] || exit 0
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
RETVAL=0
|
|
cvsdist |
aed712 |
prog="named"
|
|
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 |
0a52a5 |
# Since named doesn't return proper exit codes at the moment
|
|
cvsdist |
0a52a5 |
# (won't be fixed before 9.2), we can't use daemon here - emulate
|
|
cvsdist |
0a52a5 |
# its functionality
|
|
cvsdist |
0a52a5 |
base=$prog
|
|
cvsdist |
0a52a5 |
named -u named ${OPTIONS}
|
|
cvsdist |
2f7f4b |
RETVAL=$?
|
|
cvsdist |
0a52a5 |
usleep 100000
|
|
cvsdist |
0a52a5 |
if [ -z "`/sbin/pidof named`" ]; then
|
|
cvsdist |
0a52a5 |
# The child processes have died after fork()ing, e.g.
|
|
cvsdist |
0a52a5 |
# because of a broken config file
|
|
cvsdist |
0a52a5 |
RETVAL=1
|
|
cvsdist |
0a52a5 |
fi
|
|
cvsdist |
0a52a5 |
[ $RETVAL -ne 0 ] && failure $"$base startup"
|
|
cvsdist |
0a52a5 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named && success $"$base startup"
|
|
cvsdist |
2f7f4b |
echo
|
|
cvsdist |
2f7f4b |
return $RETVAL
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
stop() {
|
|
cvsdist |
2f7f4b |
# Stop daemons.
|
|
cvsdist |
aed712 |
echo -n $"Stopping $prog: "
|
|
cvsdist |
2f7f4b |
killproc named
|
|
cvsdist |
2f7f4b |
RETVAL=$?
|
|
cvsdist |
2f7f4b |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
|
|
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 |
2f7f4b |
start
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
reload() {
|
|
cvsdist |
366442 |
/usr/sbin/rndc reload >/dev/null 2>&1 || /usr/bin/killall -HUP named
|
|
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 |
aed712 |
[ -f /var/lock/subsys/named ] && restart
|
|
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 |
|