709b0f5
#!/bin/sh
709b0f5
12a40fb
# Paul Wouters <paul@xelerance.com>
12a40fb
# This folds back zone updates, dynamic updates, etc that nsd records
12a40fb
# in the ixfr.db and nsd.db files back into the zone files or visa
12a40fb
# versa
709b0f5
12a40fb
# Ideally check if ixfr.db newer then any zones, only then do
a25e271
/usr/sbin/nsdc patch > /dev/null 2>%1
da6cbb8
217da49
# We try to only rebuild/reload when neccessary. If 1 zone is newer,
217da49
# we need to rebuild the db file.
217da49
# This might give problems with huge zones, eg TLD's, which cannot
217da49
# complete this operation within an hour, but it should work fine for
217da49
# most other uses.
da6cbb8
da6cbb8
for zonefile in `/usr/sbin/nsd-checkconf -v /etc/nsd/nsd.conf  |grep zonefile: | sed "s/^.*\"\(.*\)\"/\1/"`
da6cbb8
do
217da49
	if [ $zonefile -nt /var/lib/nsd/nsd.db ]
da6cbb8
	then
da6cbb8
		echo "Zone $zonefile update requires nsd.db rebuild"
a25e271
		/usr/sbin/nsdc rebuild > /dev/null 2>%1
a25e271
		/usr/sbin/nsdc reload > /dev/null 2>%1
da6cbb8
		break
da6cbb8
	fi
da6cbb8
done
da6cbb8
709b0f5
709b0f5
# nsd checks the serial in notify requests, so its better to send an
12a40fb
# occasional redundant notify, then to miss it.
12a40fb
# According to the nsd team, this is no longer neccessary
a25e271
# /usr/sbin/nsdc notify > /dev/null 2>%1