Blob Blame History Raw
#!/bin/sh

# Paul Wouters <paul@xelerance.com>
# This folds back zone updates, dynamic updates, etc that nsd records
# in the ixfr.db and nsd.db files back into the zone files or visa
# versa

# Ideally check if ixfr.db newer then any zones, only then do
/usr/sbin/nsdc patch > /dev/null 2>%1

# We try to only rebuild/reload when neccessary. If 1 zone is newer,
# we need to rebuild the db file.
# This might give problems with huge zones, eg TLD's, which cannot
# complete this operation within an hour, but it should work fine for
# most other uses.

for zonefile in `/usr/sbin/nsd-checkconf -v /etc/nsd/nsd.conf  |grep zonefile: | sed "s/^.*\"\(.*\)\"/\1/"`
do
	if [ $zonefile -nt /var/lib/nsd/nsd.db ]
	then
		echo "Zone $zonefile update requires nsd.db rebuild"
		/usr/sbin/nsdc rebuild > /dev/null 2>%1
		/usr/sbin/nsdc reload > /dev/null 2>%1
		break
	fi
done


# nsd checks the serial in notify requests, so its better to send an
# occasional redundant notify, then to miss it.
# According to the nsd team, this is no longer neccessary
# /usr/sbin/nsdc notify > /dev/null 2>%1