Skip to content

Instantly share code, notes, and snippets.

@lyjacky11
Created August 20, 2022 19:26
Show Gist options
  • Save lyjacky11/da4c2acae227a696301a72941892187a to your computer and use it in GitHub Desktop.
Save lyjacky11/da4c2acae227a696301a72941892187a to your computer and use it in GitHub Desktop.
Update root.hints file for Pi-Hole Unbound Service
#!/bin/bash
echo "[i] Backing up root.hints ..."
cd /var/lib/unbound
sudo cp root.hints $(date +%F).root.hints
if [ -s $(date +%F).root.hints ]
then
echo "[✓] Backup root.hints success!"
echo ""
echo "[i] Updating root.hints ..."
sudo wget -nv -O named.root https://www.internic.net/domain/named.root
if [ -s named.root ]
then
sudo mv -f named.root root.hints
echo "[✓] Update root.hints success!"
echo ""
echo "[i] Restarting unbound service ..."
sudo service unbound restart
sudo service unbound status
exit 0
else
echo "[✗] Update failed!"
exit 1
fi
else
echo "[✗] Backup failed!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment