]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts: add utility script to check for newer root.hints
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 30 Jan 2019 12:51:32 +0000 (13:51 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:41:52 +0000 (10:41 +0100)
scripts/update-root-hints.sh [new file with mode: 0755]

diff --git a/scripts/update-root-hints.sh b/scripts/update-root-hints.sh
new file mode 100755 (executable)
index 0000000..9f3e61f
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -o nounset -o xtrace
+
+TEMP_FILE=/tmp/root.hints
+HINTS_FILE=etc/root.hints
+
+# download latest root hints
+wget -O ${TEMP_FILE} https://www.internic.net/domain/named.root
+
+# strip comments for diff
+sed '/^;/d' ${TEMP_FILE} > ${TEMP_FILE}.clean
+sed '/^;/d' ${HINTS_FILE} > ${HINTS_FILE}.clean
+
+# check for changes
+diff ${TEMP_FILE}.clean ${HINTS_FILE}.clean >/dev/null
+CHANGED=$?
+
+if [ $CHANGED -ne 0 ]; then
+    # update root.hints
+    mv ${TEMP_FILE} ${HINTS_FILE}
+fi
+
+# cleanup
+rm -f ${TEMP_FILE} ${TEMP_FILE}.clean ${HINTS_FILE}.clean
+
+# signal change with exit code
+exit $CHANGED