Skip to content

Instantly share code, notes, and snippets.

@Jacajack
Last active June 27, 2019 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jacajack/9fd6796e53c39ccf114f75924c7cfbeb to your computer and use it in GitHub Desktop.
Save Jacajack/9fd6796e53c39ccf114f75924c7cfbeb to your computer and use it in GitHub Desktop.
/etc/hosts patch generator (based on StevenBlack repo)
#!/bin/bash
BLOCK="gambling porn fakenews social"
EXCEPT=""
cp hosts hosts.new
# Base
echo "blocking adware + malware..."
curl -s "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" | sed -ne '/# Start StevenBlack/,$p' >> hosts.new
# More
for v in $BLOCK; do
echo "blocking $v..."
curl -s "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/$v/hosts" | sed -ne '/# Start StevenBlack/,$p' >> hosts.new
done;
# Exceptions
for v in $EXCEPT; do
echo "adding exception - $v..."
grep -v "$v" hosts.new | sponge hosts.new
done;
diff -u hosts hosts.new > hosts.patch
echo "use hosts.patch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment