summaryrefslogtreecommitdiffstats
path: root/usr/sbin/update_dns_cache.sh
blob: 32e99969088109c9d2f3adf96a9ec9eb0d1d84d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

mkdir -p /var/db/dnscache 
cd /var/db/dnscache 

while [ /bin/true ]; do
	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
OpenPOWER on IntegriCloud