Created
October 9, 2021 16:11
-
-
Save marcelloinfoweb/fcf417c3cf2c05d4dd426f54740f722d to your computer and use it in GitHub Desktop.
O script baixa as listas, ordena os links, deixa links únicos e salva no arquivo para o padrão do formato do Unbound.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Clean up any stale tempfile | |
echo "Removing old files..." | |
[ -f /tmp/hosts.working ] && rm -f /tmp/hosts.working | |
## Awk regex to be inverse-matched as whitelist | |
# - SolveMedia is needed for captchas on some websites | |
whitelist='/(api.solvemedia.com)/' | |
# All Blacklists | |
blacklist='https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_host http://winhelp2002.mvps.org/hosts.txt https://adaway.org/hosts.txt https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts https://www.stopforumspam.com/downloads/toxic_domains_whole.txt > | |
## Fetch all Blacklist Files | |
echo "Fetching Blacklists..." | |
for url in $blacklist; do | |
curl --silent $url >> "/tmp/hosts.working" | |
done | |
## Process Blacklist, Eliminiating Duplicates, Integrating Whitelist, and Converting to unbound format | |
echo "Processing Blacklist..." | |
awk -v whitelist="$whitelist" '$1 ~ /^127\.|^0\./ && $2 !~ whitelist {gsub("\r",""); print tolower($2)}' /tmp/hosts.working | sort | uniq | \ | |
awk '{print "local-zone: \""$1"\" redirect\nlocal-data: \""$1" A 0.0.0.0\""}' > /etc/unbound/ad-blacklist | |
#awk '{printf "server:\n", $1; printf "local-data: \"%s A 0.0.0.0\"\n", $1}' > /etc/unbound/ad-blacklist | |
# Clean up tempfile | |
echo "Cleaning Up..." | |
rm -f '/tmp/hosts.working' | |
echo "Restarting Unbound ... " | |
systemctl restart unbound.service | |
echo "... Done restart!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment