SHOW:
|
|
- or go back to the newest paste.
| 1 | - | !/bin/bash |
| 1 | + | #!/bin/bash |
| 2 | # This script downloads bluetack blocklists, then merges them. | |
| 3 | # | |
| 4 | # For descriptions of each list, see | |
| 5 | # http://www.bluetack.co.uk/forums/index.php?autocom=faq&CODE=02&qid=17 | |
| 6 | # | |
| 7 | # If using rtorrent with ipfilter enhancement patch from trac located at | |
| 8 | # http://libtorrent.rakshasa.no/ticket/239 , | |
| 9 | # then remember to add the following 2 lines to your .rtorrent.rc: | |
| 10 | # ip_filter=path/to/ipfilter/blocklist | |
| 11 | # schedule = filter,18:30:00,24:00:00,reload_ip_filter= | |
| 12 | # Remember to change "path/to/ipfilter" above to the same path as below, | |
| 13 | # and then set cron to run this script daily. | |
| 14 | ||
| 15 | # Edit the following to the desired parent folder for the blocklist. | |
| 16 | # This folder should only be used for this script. | |
| 17 | # Choose either a writable nonexistant path, or an empty existing path. | |
| 18 | - | dir=/path/to/ipfilter |
| 18 | + | dir=/opt/etc/transmission/blocklists |
| 19 | ||
| 20 | # This sets the name of the blocklist to "blocklist". | |
| 21 | # Change this if you need it to match your ip_filter= setting. | |
| 22 | - | bl=$dir/blocklist |
| 22 | + | bl=$dir/ips |
| 23 | ||
| 24 | # Directory and blocklist check | |
| 25 | if [ -d $dir ]; then | |
| 26 | if [ -f $bl ]; then | |
| 27 | echo Blocklist exists. | |
| 28 | else | |
| 29 | touch $bl | |
| 30 | if [ $? = 0 ]; then | |
| 31 | echo Empty blocklist created. | |
| 32 | else | |
| 33 | echo -e "Error creating file.\nPlease repair permissions in $dir.\nExiting." | |
| 34 | exit 0 | |
| 35 | fi | |
| 36 | fi | |
| 37 | else | |
| 38 | mkdir $dir | |
| 39 | touch $bl | |
| 40 | if [ $? = 0 ]; then | |
| 41 | echo Directory and empty blocklist created. | |
| 42 | else | |
| 43 | echo -e "Error writing to directory.\nPlease repair permissions in parent directory.\nExiting." | |
| 44 | exit 0 | |
| 45 | fi | |
| 46 | fi | |
| 47 | ||
| 48 | cd $dir | |
| 49 | ||
| 50 | # Backup current blocklist | |
| 51 | - | mv -f blocklist blocklist.backup |
| 51 | + | #mv -f $bl $dir2/$bl.backup |
| 52 | if [ $? = 0 ] | |
| 53 | then | |
| 54 | echo Downloading blocklists... | |
| 55 | else | |
| 56 | echo -e "Error backing up current blocklist.\nPlease repair permissions in $dir.\nExiting." | |
| 57 | exit 0 | |
| 58 | fi | |
| 59 | ||
| 60 | # Uncomment each file you want included in the final blocklist | |
| 61 | # | |
| 62 | #wget -q -t 3 http://www.bluetack.co.uk/config/ads-trackers-and-bad-pr0n.gz | |
| 63 | #wget -q -t 3 http://www.bluetack.co.uk/config/badpeers.gz | |
| 64 | wget -q -t 3 http://www.bluetack.co.uk/config/bogon.gz | |
| 65 | wget -q -t 3 http://www.bluetack.co.uk/config/dshield.gz | |
| 66 | #wget -q -t 3 http://www.bluetack.co.uk/config/edu.gz | |
| 67 | #wget -q -t 3 http://www.bluetack.co.uk/config/exclusions.gz | |
| 68 | #wget -q -t 3 http://www.bluetack.co.uk/config/fornonlancomputers.gz | |
| 69 | #wget -q -t 3 http://www.bluetack.co.uk/config/gnutella.gz | |
| 70 | #wget -q -t 3 http://www.bluetack.co.uk/config/hijacked.gz | |
| 71 | #wget -q -t 3 http://www.bluetack.co.uk/config/HOSTS.gz | |
| 72 | #wget -q -t 3 http://www.bluetack.co.uk/config/iana-multicast.gz | |
| 73 | #wget -q -t 3 http://www.bluetack.co.uk/config/iana-private.gz | |
| 74 | #wget -q -t 3 http://www.bluetack.co.uk/config/iana-reserved.gz | |
| 75 | wget -q -t 3 http://www.bluetack.co.uk/config/level1.gz | |
| 76 | wget -q -t 3 http://www.bluetack.co.uk/config/level2.gz | |
| 77 | #wget -q -t 3 http://www.bluetack.co.uk/config/level3.gz | |
| 78 | wget -q -t 3 http://www.bluetack.co.uk/config/Microsoft.gz | |
| 79 | #wget -q -t 3 http://www.bluetack.co.uk/config/proxy.gz | |
| 80 | #wget -q -t 3 http://www.bluetack.co.uk/config/rangetest.gz | |
| 81 | #wget -q -t 3 http://www.bluetack.co.uk/config/spider.gz | |
| 82 | #wget -q -t 3 http://www.bluetack.co.uk/config/spyware.gz | |
| 83 | #wget -q -t 3 http://www.bluetack.co.uk/config/webexploit-forumspam.gz | |
| 84 | ||
| 85 | # Extract blocklists (blocklist.backup is ignored) | |
| 86 | - | gunzip -r $dir |
| 86 | + | #gunzip $dir |
| 87 | gunzip $dir/*.gz | |
| 88 | ||
| 89 | - | shopt -s extglob |
| 89 | + | |
| 90 | - | cat !(blocklist.backup) > blocklist |
| 90 | + | #shopt -s extglob |
| 91 | #cat !(blocklist.backup) > blocklist | |
| 92 | cat bogon > $bl | |
| 93 | - | rm !(bl*) |
| 93 | + | cat dshield >> $bl |
| 94 | cat level1 >> $bl | |
| 95 | cat level2 >> $bl | |
| 96 | cat Microsoft >> $bl | |
| 97 | ||
| 98 | # Cleanup individual blocklists | |
| 99 | #rm !(bl*) | |
| 100 | rm bogon | |
| 101 | rm dshield | |
| 102 | rm level1 | |
| 103 | rm level2 | |
| 104 | rm Microsoft | |
| 105 | ||
| 106 | echo Done. | |
| 107 | ||
| 108 | exit 0 |