summaryrefslogtreecommitdiffstats
path: root/scripts/update-root-hints.sh
blob: 862d834bd988823810ed7d41453f3350e5753b0f (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
26
27
28
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
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