Code: Select all
#!/bin/sh
[ -z $DISPLAY ] && DIALOG=dialog || DIALOG=Xdialog
[ ! -f /etc/hosts.usr ] && touch /etc/hosts && cp -f /etc/hosts /etc/hosts.usr #back up original
for x in `$DIALOG --stdout --checklist "Choose your ad blocking service(s)" 0 0 6 1 "mvps.org" off 2 "systcl.org" off 3 "technobeta.com" off 4 "yoyo.org" off 5 "turn off adblocking" ON 6 "manually edit" off |tr "/" " " |tr '\"' ' '`; do
case $x in
1)wget -c -4 -t 0 -O /tmp/adlist1 'http://www.mvps.org/winhelp2002/hosts.txt';;
2)wget -c -4 -t 0 -O /tmp/adlist2 'http://sysctl.org/cameleon/hosts';;
3)wget -c -4 -t 0 -O /tmp/adlist3 'http://www.technobeta.com/download/urlfilter.ini';;
4)wget -c -4 -t 0 -O /tmp/adlist4 'http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext';;
5)ln -sf /etc/hosts.usr /etc/hosts && exit;;
6)[ -z $DISPLAY ] && $DIALOG --editbox /etc/hosts 0 0 && exit || vi /etc/hosts && exit;;#dialog has no editbox so try vi which is cli and in busybox
*)echo $x;;
esac
done
touch /tmp/adlist{1,2,3,4} #in case they weren't downloaded
cat /etc/hosts.usr /tmp/adlist{1,2,3,4} |sed 's/^[ \t]*//' |sed 's/\t/ /g' |sed 's/ / /g' |grep ^[1-9] |dos2unix -u |sort |uniq > /etc/hosts.adblock
ln -sf /etc/hosts.adblock /etc/hosts
rm -f /tmp/adlist{1,2,3,4} #need to remove or unwanted lists will be added
#todo add whitelist