Skip to content

Instantly share code, notes, and snippets.

@jansroka
Last active May 14, 2023 14:27
Show Gist options
  • Save jansroka/b49495d38713d1dab8a55095a9bb37f0 to your computer and use it in GitHub Desktop.
Save jansroka/b49495d38713d1dab8a55095a9bb37f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Upate your hosts file - Jan Sroka <github@jansroka.com>
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
# comment this out to remove debug output
set -x
# Ask for sudo password upfront
sudo -v
# make sure we start clean
rm --recursive --force ./hosts
# shallow clone the hosts repo
git clone --depth=1 https://github.com/StevenBlack/hosts
# install deps
pip3 install --user -r ./hosts/requirements.txt
# update the hosts file
python3 ./hosts/updateHostsFile.py --auto --noupdate --nogendata --replace --flush-dns-cache --blacklist ./blacklist --whitelist ./whitelist --extensions Unified hosts + fakenews + gambling + porn + social
# cleanup after ourselves
rm --recursive --force ./hosts
# if we reached this far, exit cleanly
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment