Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- # Back up current hosts file:
- cat /etc/hosts > /etc/hosts.old
- ########## Fetch & Update ##########
- # hphosts
- echo "Downloading hphosts file...";
- w3m -dump "http://hosts-file.net/ad_servers.txt" > /etc/.hphosts.txt
- echo "Formatting... "
- sed -i 's/127.0.0.1/0.0.0.0/g' /etc/.hphosts.txt # Replace 127.0.0.1 with 0.0.0.0
- sed -i 's/ / /g' /etc/.hphosts.txt # Remove ugly tabulation
- sed -i -e '/localhost/d' /etc/.hphosts.txt # Remove any localhost entry
- echo "Updating... "
- cat /etc/hosts.factory > /etc/.hosts # Restore original entries
- cat /etc/.hphosts.txt >> /etc/.hosts
- rm /etc/.hphosts.txt
- # Pete Lowe's Ad Servers
- echo "Downloading Pete Lowe's file...";
- w3m -dump "http://pgl.yoyo.org/as/serverlist.php?showintro=0;hostformat=hosts" > /etc/.Pete.txt
- echo "Formatting... "
- sed -i 's/127.0.0.1/0.0.0.0/g' /etc/.Pete.txt # Replace 127.0.0.1 with 0.0.0.0
- sed -i -e '/localhost/d' /etc/.Pete.txt # Remove any localhost entry
- echo "Updating... "
- cat /etc/.Pete.txt >> /etc/.hosts
- rm /etc/.Pete.txt
- # Exclude some servers
- echo "Removing useful domains.."
- grep -vwE "(ssl.google-analytics.com|safelinking.net|0.0.0.0 adf.ly|www.adf.ly|cdn.adf.ly|pixel.solvemedia.com|ebayrtm.com|banners.ebay.com|ilapi.ebay.com|l.deals.ebay.com|lapi.ebay.com|stats.ebay.com|banners.ebay.com|ebayobjects.com|images.paypal.com|t.paypal.com|bdv.bidvertiser.com|0.0.0.0 bidvertiser.com|www.bidvertiser.com|cdn.bidvertiser.com|secure.bidvertiser.com|diff.smartadserver.com|diff2.smartadserver.com|diff3.smartadserver.com|dox.abv.bg|leagueoflegends.com|stats.unity3d.com|cdn.shorte.st|collector.shorte.st|www.shorte.st|0.0.0.0 shorte.st|jwpltx.com)" /etc/.hosts > /etc/hosts
- rm /etc/.hosts
- # Append date of update
- UPDATED="Last updated $(date) by cron"
- echo $UPDATED >> /etc/hosts
- echo "All done!"
Add Comment
Please, Sign In to add comment