Oct
03
2012
This blog post is based on Sotiris Tsimbonis’s work.
You should always checkzone the dns zone file you have just edited.
But you can also automate this, with a vim wrapper.
small changes @ Thu, 04 Oct 2012 14:03:15 +0300
#!/bin/sh
# ebal, Thu, 04 Oct 2012 14:03:15 +0300
/usr/sbin/named-checkconf
RES=$?
if [ ${RES} -gt 0 ]; then
echo ""
echo "Fix the above errors before editing your zone file"
echo ""
exit ${RES}
fi
ZONE=$1
PREFIX="/var/named/"
CHECKSUM=`/usr/bin/sha1sum ${PREFIX}/${ZONE}`
/usr/bin/vim ${PREFIX}/${ZONE}
echo ""
echo "Checking ${ZONE} for errors..."
echo ""
/usr/sbin/named-checkzone -i local ${ZONE} ${PREFIX}/${ZONE}
RES=$?
if [ ${RES} -gt 0 ]; then
echo ""
echo "You need to fix the errors and try again."
echo ""
exit ${RES}
fi
SHA1SUM=`/usr/bin/sha1sum ${PREFIX}/${ZONE}`
if [[ "$CHECKSUM" != "$SHA1SUM" ]]; then
echo "reloading zone ..."
/usr/sbin/rndc reload ${ZONE}
fi