fea33a3
#!/bin/bash
fea33a3
#
fea33a3
# nsd:         Starts the NSD Name Server Daemon
fea33a3
#
c84fed8
# chkconfig: - 13 87
fea33a3
# description:  NSD is a complete implementation of an authoritative \
fea33a3
#               DNS name server. 
fea33a3
# processname: /usr/sbin/nsd
16359b2
# config: /etc/nsd/nsd.conf
fea33a3
#
fea33a3
### BEGIN INIT INFO
fea33a3
# Provides: nsd
c84fed8
# Required-Start: $local_fs $network $syslog
c84fed8
# Required-Stop: $local_fs $network $syslog
c84fed8
# Default-Start:
c84fed8
# Short-Description: start|stop|status|restart|try-restart|reload|force-reload DNS server
c84fed8
# Description: control NSD implementation of DNS server
fea33a3
### END INIT INFO
fea33a3
fea33a3
#extra verbosity
fea33a3
#ZONEC_VERBOSE=-v
fea33a3
OTHER_NSD_OPTS=""
fea33a3
fea33a3
# Source function library.
c84fed8
. /etc/rc.d/init.d/functions
fea33a3
c84fed8
[ -r /etc/sysconfig/nsd ] && . /etc/sysconfig/nsd
fea33a3
fea33a3
# Check that networking is configured.
fea33a3
[ ${NETWORKING} = "no" ] && exit 0
fea33a3
fea33a3
start() {
c84fed8
  # Source networking configuration.
c84fed8
  [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
c84fed8
c84fed8
  # Check that networking is up
c84fed8
  [ "${NETWORKING}" = "no" ] && exit 1
c84fed8
c84fed8
  # Sanity checks.
c84fed8
  [ -f /etc/nsd/nsd.conf ] || exit 5
c84fed8
  [ -x /usr/sbin/nsd ] || exit 5
c84fed8
c84fed8
	echo -n $"Starting nsd:"
709b0f5
	/usr/sbin/nsdc rebuild >/dev/null 2>%1
fea33a3
	nsd $OTHER_NSD_OPTS
fea33a3
	RETVAL=$?
fea33a3
	echo
c84fed8
        if [ $RETVAL -eq 0 ]; then
c84fed8
           touch /var/lock/subsys/named;
c84fed8
        else
c84fed8
           exit 7;
c84fed8
        fi
c84fed8
  return 0;
fea33a3
}
fea33a3
fea33a3
stop() {
c84fed8
	echo -n $"Stopping nsd: "
709b0f5
	# save state to zonefiles
709b0f5
	/usr/sbin/nsdc patch > /dev/null 2>%1
c84fed8
	/usr/sbin/nsdc stop
fea33a3
	RETVAL=$?
c84fed8
	# was nsdc successful?
c84fed8
	[ "$RETVAL" -eq 0 ] || killproc nsd -TERM >/dev/null 2>&1
fea33a3
	if [ $RETVAL -eq 0 ] ; then
ab5512b
	  rm -f /var/run/nsd/nsd.pid
c84fed8
	  rm -f /var/lock/subsys/nsd
ab5512b
	  # ensure notifies are sent at startup
ab5512b
	  rm -f /var/lib/nsd/xfrd.state
fea33a3
	fi
fea33a3
	echo
fea33a3
	return $RETVAL
fea33a3
}
fea33a3
fea33a3
restart() {
fea33a3
	stop
fea33a3
	start
fea33a3
}
fea33a3
fea33a3
RETVAL=0
fea33a3
fea33a3
# See how we were called.
fea33a3
case "$1" in
fea33a3
  start)
fea33a3
	start
fea33a3
	;;
fea33a3
  stop)
fea33a3
	stop
fea33a3
	;;
fea33a3
  restart)
fea33a3
	restart
fea33a3
	;;
fea33a3
  condrestart)
fea33a3
        [ -f /var/lock/subsys/nsd ] && restart || :
fea33a3
	;;
fea33a3
  status)
fea33a3
	/usr/sbin/nsdc running
fea33a3
	;;
fea33a3
  stats|reload|rebuild|running|update|notify)
fea33a3
	/usr/sbin/nsdc $1 
fea33a3
	;;
fea33a3
  *)
fea33a3
	echo $"Usage: $0 {start|stop|status|restart|condrestart|stats|notify|reload|rebuild|running|update}"
fea33a3
	exit 1
fea33a3
esac
fea33a3
c84fed8
exit $RETVAL