bind/named.init

87 lines
2.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#
# named -- This shell script takes care of starting and stopping
# named (BIND DNS server).
#
# chkconfig: 345 30 45
# 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
NAME=named
DAEMON=/usr/sbin/$NAME
DAEMONPID=/var/run/$NAME.pid
DAEMONCONF=/etc/named.conf
DAEMONLOG=
OPTIONS=
[ -x $DAEMON ] || exit 0
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
[ -r ${ROOTDIR}${DAEMONCONF} ] || exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n $"Starting $NAME: "
if [ -n "$ROOTDIR" -a "x$ROOTDIR" != "x/" ]; then
OPTIONS="$OPTIONS -t $ROOTDIR"
fi
daemon $DAEMON -u named $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
echo
# perform a query so we are sure service is working
# before the system starts other services
dig > /dev/null
exit $RETVAL
;;
stop)
echo -n $"Stopping $NAME: "
killproc $DAEMON
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME
exit $RETVAL
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
condrestart)
[ -e /var/lock/subsys/$NAME ] && $0 restart
;;
reload)
/usr/sbin/rndc -c $ROOTDIR/etc/rndc.conf reload >/dev/null 2>&1 || \
/usr/bin/killall -HUP $NAME
exit $?
;;
status)
/usr/sbin/rndc -c $ROOTDIR/etc/rndc.conf status
exit $?
;;
probe)
# named knows how to reload intelligently; we don't want linuxconf
# to offer to restart every time
/usr/sbin/rndc -c $ROOTDIR/etc/rndc.conf reload >/dev/null 2>&1 || \
echo start
exit $?
;;
*)
echo $"Usage: ""/etc/init.d/$NAME {start|stop|status|restart|condrestart|reload|probe}"
exit 1
;;
esac