blob: 793344c88a058785661aee7fac5003753e62bfd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/bin/sh -e
# Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc.
# Custom hosts are preserved.
[ "$USER" = root ] || exec sudo "$0" "$@"
echo "last update: $(date -r /etc/hosts)"
cd /etc
cp -p hosts hosts.old
hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old)
curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts |
awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" }
/^# Custom host / { print hosts; next }
/^# End of custom host / { next }
{print}' "$hosts" > hosts.new
mv hosts.new hosts
[ "$(uname -s)" != Darwin ] || dscacheutil -flushcache
diff -u /etc/hosts.old /etc/hosts | diffstat
|