Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Update Ad-Free /etc/hosts file from public lists
- # Original found on http://korovamilky.tumblr.com/
- readonly TMP_FILE="/tmp/hosts"
- readonly HOSTS_FILE="/etc/hosts"
- # WINDOWS HOSTS FILE: %systemroot%\system32\drivers\etc\hosts
- touch ${TMP_FILE}
- for URL in http://adaway.org/hosts.txt \
- http://winhelp2002.mvps.org/hosts.txt \
- http://someonewhocares.org/hosts/hosts \
- http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts\&showintro=0\&mimetype=plaintext
- do curl -s ${URL} | egrep "^127.0.0.1|^0.0.0.0" >> ${TMP_FILE}
- done
- # remember to add here your custom known hosts:
- echo "127.0.0.1 localhost
- 127.0.0.1 localhost.localdomain
- fe80::1%lo0 localhost
- 255.255.255.255 broadcasthost
- " > ${HOSTS_FILE}
- # use 0.0.0.0 instead of 127.0.0.1 (faster but not 100% compatible)
- awk '!/ localhost/'{'print "0.0.0.0 "$2'} ${TMP_FILE} | sort | uniq >> ${HOSTS_FILE}
- rm -f ${TMP_FILE}
- exit 0
Add Comment
Please, Sign In to add comment