Blob Blame History Raw
#!/bin/bash
#
# nsd:         Starts the NSD Name Server Daemon
#
# chkconfig: - 13 87
# description:  NSD is a complete implementation of an authoritative \
#               DNS name server. 
# processname: /usr/sbin/nsd
# config: /etc/nsd/nsd.conf
#
### BEGIN INIT INFO
# Provides: nsd
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start:
# Short-Description: start|stop|status|restart|try-restart|reload|force-reload DNS server
# Description: control NSD implementation of DNS server
### END INIT INFO

#extra verbosity
#ZONEC_VERBOSE=-v
OTHER_NSD_OPTS=""

# Source function library.
. /etc/rc.d/init.d/functions

[ -r /etc/sysconfig/nsd ] && . /etc/sysconfig/nsd

# Check that networking is configured.
[ ${NETWORKING} = "no" ] && exit 0

start() {
  # Source networking configuration.
  [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network

  # Check that networking is up
  [ "${NETWORKING}" = "no" ] && exit 1

  # Sanity checks.
  [ -f /etc/nsd/nsd.conf ] || exit 5
  [ -x /usr/sbin/nsd ] || exit 5

	echo -n $"Starting nsd:"
	/usr/sbin/nsdc rebuild >/dev/null 2>%1
	nsd $OTHER_NSD_OPTS
	RETVAL=$?
	echo
        if [ $RETVAL -eq 0 ]; then
           touch /var/lock/subsys/named;
        else
           exit 7;
        fi
  return 0;
}

stop() {
	echo -n $"Stopping nsd: "
	# save state to zonefiles
	/usr/sbin/nsdc patch > /dev/null 2>%1
	/usr/sbin/nsdc stop
	RETVAL=$?
	# was nsdc successful?
	[ "$RETVAL" -eq 0 ] || killproc nsd -TERM >/dev/null 2>&1
	if [ $RETVAL -eq 0 ] ; then
	  rm -f /var/run/nsd/nsd.pid
	  rm -f /var/lock/subsys/nsd
	  # ensure notifies are sent at startup
	  rm -f /var/lib/nsd/xfrd.state
	fi
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

RETVAL=0

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  condrestart)
        [ -f /var/lock/subsys/nsd ] && restart || :
	;;
  status)
	/usr/sbin/nsdc running
	;;
  stats|reload|rebuild|running|update|notify)
	/usr/sbin/nsdc $1 
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|stats|notify|reload|rebuild|running|update}"
	exit 1
esac

exit $RETVAL