summaryrefslogtreecommitdiffstats
path: root/main/djbdns/dnscache.monthly
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2010-04-19 11:24:45 +0300
committerNatanael Copa <ncopa@alpinelinux.org>2010-04-19 13:15:55 +0000
commitfbea38f9a65456f1e7e08630201c5e8caea72ed2 (patch)
tree4720e07f647ded89ec9b7c384c67376eeb119e97 /main/djbdns/dnscache.monthly
parent236a35ddd6048ddff7f05c47777840973141369d (diff)
downloadaports-fbea38f9a65456f1e7e08630201c5e8caea72ed2.tar.bz2
aports-fbea38f9a65456f1e7e08630201c5e8caea72ed2.tar.xz
main/djbdns: periodic script to update zone hints
This also splits the djbdns to djbdns-common that contains the few utilities needed by the periodic script. Minor fix to init.d script included also. Signed-off-by: Timo Teras <timo.teras@iki.fi> Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Diffstat (limited to 'main/djbdns/dnscache.monthly')
-rwxr-xr-xmain/djbdns/dnscache.monthly48
1 files changed, 48 insertions, 0 deletions
diff --git a/main/djbdns/dnscache.monthly b/main/djbdns/dnscache.monthly
new file mode 100755
index 000000000..0bd5a8539
--- /dev/null
+++ b/main/djbdns/dnscache.monthly
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+if [ -f ./etc/conf.d/dnscache ]; then
+ . /etc/conf.d/dnscache
+fi
+
+if [ -z "$UPDATEHINTS" ]; then
+ exit 0
+fi
+
+cd /etc/dnscache/servers
+NEEDRESTART=
+ZONES=`ls /etc/dnscache/servers`
+for ZONEFILE in $ZONES; do
+ # Convert symlinks to copies, so we can update it
+ ZONE="$ZONEFILE"
+ if [ -L $ZONEFILE ]; then
+ DST="`readlink "$ZONEFILE"`"
+ cp -f "$DST" "$ZONEFILE"
+ fi
+
+ if [ "$ZONE" == "@" ]; then
+ ZONE="."
+ fi
+
+ if [ "$ZONE" != "." -o "$FORWARDONLY" = "" ]; then
+ TMPF=`mktemp -t`
+
+ # Refresh zone info
+ dnsqr ns $ZONE | awk '/^answer: ./ { print $5 }' | sort -u | xargs dnsip > $TMPF
+
+ grep "^$" $TMPF 1> /dev/null
+ if [ $? != 0 ]; then
+ cmp -s $ZONEFILE $TMPF
+ if [ "$?" != 0 ]; then
+ NEEDRESTART=yes
+ cat $TMPF > $ZONEFILE
+ fi
+ fi
+ rm $TMPF
+ fi
+done
+
+if [ "$NEEDRESTART" ] && /etc/init.d/dnscache --quiet status; then
+ /etc/init.d/dnscache restart
+fi
+
+exit 0