#!/bin/sh
#
# $FreeBSD: ports/dns/nsd/files/nsd.in,v 1.4 2009/01/16 00:30:07 miwi Exp $
#
# PROVIDE: nsd
# REQUIRE: DAEMON
#
# Add the following line to /etc/rc.conf to enable nsd:
#
# nsd_enable="YES"
# 
# Added the start command since rebuilding is required at first boot (richardvm@wirelessleiden.nl)

. /etc/rc.subr

name=nsd
rcvar=`set_rcvar`

required_files=/usr/local/etc/nsd/nsd.conf

command=/usr/local/sbin/${name}
pidfile=/var/run/${name}.pid

load_rc_config ${name}

nsd_enable=${nsd_enable-"NO"}

stop_cmd="nsd_stop"
start_cmd="nsd_start"

nsd_start()
{
        echo "Rebuilding zone files..."
	/usr/local/sbin/nsdc rebuild

        echo "Starting nsd."
	/usr/local/sbin/nsdc start
}

nsd_stop()
{
        echo "Merging nsd zone transfer changes to zone files."
        /usr/local/sbin/nsdc patch

        sleep 5

        echo "Stopping nsd."
        /usr/local/sbin/nsdc stop
}


run_rc_command "$1"

