diff options
author | Seth Mos <seth.mos@xs4all.nl> | 2007-09-25 21:54:38 +0000 |
---|---|---|
committer | Seth Mos <seth.mos@xs4all.nl> | 2007-09-25 21:54:38 +0000 |
commit | 6a0161b34d5199b3946c9e882432a36d5ee5b0ca (patch) | |
tree | 5c754a124d47928b0f47ed49747dee79472014f7 /usr | |
parent | c941ea1c16a617a5cec4231dc2ac2a7b06c8c505 (diff) | |
download | pfsense-6a0161b34d5199b3946c9e882432a36d5ee5b0ca.zip pfsense-6a0161b34d5199b3946c9e882432a36d5ee5b0ca.tar.gz |
Works with multiple ip addresses.
FIXME: Compare tmp file with old addresses
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/sbin/update_dns_cache.sh | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/usr/sbin/update_dns_cache.sh b/usr/sbin/update_dns_cache.sh index ca95e2c..32e9996 100755 --- a/usr/sbin/update_dns_cache.sh +++ b/usr/sbin/update_dns_cache.sh @@ -1,19 +1,25 @@ #!/bin/sh -mkdir -p cd /var/db/dnscache +mkdir -p /var/db/dnscache +cd /var/db/dnscache while [ /bin/true ]; do - cd /var/db/dnscache - needsfilterreload=0 - for FILE in *; do - OLDIP=`cat $FILE` - NEWIP=`host $FILE | grep -v NXDOMAIN | awk '{ print $4 }'` - if [ "$OLDIP" != "$NEWIP" ]; then - needsfilterreload=1 - fi - done - if [ "$needsfilterreload" -gt 0 ]; then - /etc/rc.filter_configure_sync - fi - sleep 480 + cd /var/db/dnscache + needsfilterreload=0 + for FILE in *; do + DNSENTRIES=`host -t A $FILE | awk '/address/ {print $4}' | sort` + echo "$DNSENTRIES" > /tmp/Njkd98u79.tmp + CURRENTNR=`cat /tmp/Njkd98u79.tmp | wc -l | awk '{print $1}'` + OLDNR=`cat $FILE | wc -l | awk '{print $1}'` + if [ "$CURRENTNR" != "$OLDNR" ]; then + needsfilterreload=1 + # if the number of hosts is different we reload and skip the rest + continue + fi + # We need to compare the files. + done + if [ "$needsfilterreload" -gt 0 ]; then + /etc/rc.filter_configure_sync + fi + sleep 480 done |