Update Bind Configurations

#!/bin/bash 
 
# Check SVN repository for ACL update then, fetch and reload named
 
BINDPATH="/etc/bind"
MAILTO="jason@lithiumfox.com"
REPO="http://jason.lithiumfox.com/svn/repos/dns"
 
 
if $(svn st -u $BINDPATH|egrep '(acls.conf?|as[1-9]+.acl?)' > /dev/null 2>&1)
	then
	REVISION=$(svn update $BINDPATH | grep revision | awk '{print $NF}'| tr -d \.) 
	if ERROR=$(/usr/sbin/named-checkconf $BINDPATH/named.conf)
		then
		/etc/init.d/named reload > /dev/null 2>&1
	else
		let "REVISION -= 1" 
		echo $ERROR | mail -s "$HOSTNAME - DNS ACL update failed!" $MAILTO
		svn co -r $REVISION $REPO $BINDPATH > /dev/null 2>&1
	fi
fi