From 6a0161b34d5199b3946c9e882432a36d5ee5b0ca Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Tue, 25 Sep 2007 21:54:38 +0000 Subject: Works with multiple ip addresses. FIXME: Compare tmp file with old addresses --- usr/sbin/update_dns_cache.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'usr/sbin') 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 -- cgit v1.1