Last active
October 27, 2019 11:41
-
-
Save yaredc/0144cfb0d8059362bc92549cac0ed833 to your computer and use it in GitHub Desktop.
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 | |
TARGET='/etc/hosts' | |
SOURCE="$HOME/hosts" | |
BACKUP="$HOME/hosts.$(date +'%Y-%m-%d').bak" | |
#BACKUP | |
cp "$TARGET" "$BACKUP" | |
#DOWNLOAD NEW | |
wget -q -O "$SOURCE" "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" | |
#REFRESH EXISTING TERGET | |
sudo rm "$TARGET" | |
sudo touch "$TARGET" | |
#ADD DEFAULT VALUES | |
echo '127.0.0.1 localhost' | sudo tee -a "$TARGET" >/dev/null | |
echo '127.0.0.1 local' | sudo tee -a "$TARGET" >/dev/null | |
echo '127.0.0.1 dev' | sudo tee -a "$TARGET" >/dev/null | |
echo "127.0.0.1 $(hostname)" | sudo tee -a "$TARGET" >/dev/null | |
echo '::1 ip6-localhost ip6-loopback' | sudo tee -a "$TARGET" >/dev/null | |
echo 'fe00::0 ip6-localnet' | sudo tee -a "$TARGET" >/dev/null | |
echo 'ff00::0 ip6-mcastprefix' | sudo tee -a "$TARGET" >/dev/null | |
echo 'ff02::1 ip6-allnodes' | sudo tee -a "$TARGET" >/dev/null | |
echo 'ff02::2 ip6-allrouters' | sudo tee -a "$TARGET" >/dev/null | |
#ADD NEW STUFF | |
sudo tee -a "$TARGET" >/dev/null <"$SOURCE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment