Fix unbound reload issue (twas a file permission issue) and add basic ad blocking

This commit is contained in:
Tony Blyler 2021-05-10 19:40:02 -04:00
parent 084e07cb44
commit 407bc6f0d6
4 changed files with 31 additions and 7 deletions

23
unbound/blocklist-updater Executable file
View file

@ -0,0 +1,23 @@
#!/usr/local/bin/bash
set -euo pipefail
if ! command -v curl &> /dev/null; then
>&2 echo 'curl is missing from PATH'
exit 1
fi
readonly OUTPUT_FILE='/var/unbound/etc/blocklist.conf'
curl -LSsf 'https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts' | awk '/^0\.0\.0\.0/{
# there is no need for a "0.0.0.0 0.0.0.0" line
if ($2 == "0.0.0.0") {
next
}
print "local-zone: \"" $2 "\" redirect"
print "local-data: \"" $2 " A 0.0.0.0\""
}' > "${OUTPUT_FILE}"
chmod 644 "${OUTPUT_FILE}"
rcctl reload unbound

View file

@ -1,6 +1,6 @@
#!/bin/sh
#!/usr/local/bin/bash
set -eu
set -euo pipefail
AWK_SCRIPT=$(cat << 'EOF'
/^[ \t]*[^ \t]+[ \t]+([0-9]{1,3}\.){3}[0-9]{1,3}[ \t]*$/ {