#!/bin/sh GLOBALROOTS="/etc/dnsroots.global" GLOBALBK="/etc/dnsroots.global.`date +%Y%m%d`.bk" TEMPROOTS="`mktemp -p /etc '.dnsroots.XXXXXX'`" NAMEDROOT="http://www.internic.net/zones/named.root" # Use curl or wget in path CURLOPTS="--silent" CURL="`which curl 2>/dev/null`" if [ $? -ne 0 ]; then CURLOPTS="--quiet -O -" CURL="`which wget 2>/dev/null`" if [ $? -ne 0 ]; then echo "Neither wget nor curl found in path." exit 1 fi fi # Download and process update file "$CURL" $CURLOPTS "$NAMEDROOT" \ | grep ' A ' | tr -s ' ' | cut -d ' ' -f4 \ | sort > "$TEMPROOTS" # Make sure our new file isn't blank if [ -s "$TEMPROOTS" ]; then mv "$GLOBALROOTS" "$GLOBALBK" mv "$TEMPROOTS" "$GLOBALROOTS" diff -u "$GLOBALBK" "$GLOBALROOTS" > "$GLOBALBK.diff" if [ $? -ne 0 ]; then echo "Root DNS servers have been updated." echo "Changes listed below. Please update dnscache instances." cat "$GLOBALBK.diff" else # No point keeping empty files rm -f "$GLOBALBK.diff" fi else echo "We seem to have received a blank root server update." fi