Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 103961ca21f1748a687d602445178fcd > files > 4

bind-9.9.1.P4-1.mga2.i586.rpm

#!/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
# Required-Start: $network
# Required-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
	/usr/sbin/setup-named-chroot.sh /var/lib/named

	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
        }       

	if egrep -q '^/proc[[:space:]]+'/var/lib/named'/proc' /proc/mounts; then
	    umount /var/lib/named/proc >/dev/null 2>&1
	fi

        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