#!/bin/sh ### short script that downloads a list of ad servers for use with ### squid to block ads. ### ### details on configuring squid itself can be found here: ### ### http://pgl.yoyo.org/adservers/#withsquid ### ### - originally by Stephen Patterson ### - butchered by Peter Lowe ### ## set things ## # URL of the ad server list to download listurl='http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml' # location of the list of ad servers used by Squid targetfile='/etc/squid.adservers' # location of a file where hostnames not listed can be added extrasfile='/etc/squid-extra.adservers' # command to reload squid - change according to your system reloadcmd='/etc/init.d/squid reload' # temp file to use tmpfile="/tmp/.adlist.$$" # command to fetch the list (alternatives commented out) fetchcmd="wget -q $listurl -O $tmpfile" #fetchcmd="lynx -dump $listurl > $tmpfile" #fetchcmd="fetch -qo $tmpfile $listurl" ## do things ## # get a fresh list of ad server addresses for squid to refuse $fetchcmd # add the extras [ -f "$extrasfile" ] && cat $extrasfile >> $tmpfile # check the temp file exists OK before overwriting the existing list if [ ! -s $tmpfile ] then echo "temp file '$tmpfile' either doesn't exist or is empty; quitting" exit fi # sort and filter out duplicates sort $tmpfile > $targetfile # clean up rm $tmpfile # restart Squid $reloadcmd