dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

gen-adblock (2138B)


      1 #!/bin/sh
      2 
      3 _HOSTS_FILE="/etc/hosts.ads"
      4 _TEMP_FILE="$(mktemp /tmp/blocklist.XXXXXX)"
      5 
      6 set -- $(
      7 printf '%s'                                                                 \
      8 ' https://adaway.org/hosts.txt'                                             \
      9 ' http://adblock.mahakala.is/'                                              \
     10 ' http://hosts-file.net/.%5Cad_servers.txt'                                 \
     11 ' https://mirror1.malwaredomains.com/files/justdomains'                     \
     12 ' http://pgl.yoyo.org/adservers/serverlist.php'                             \
     13     '?mimetype=plaintext&hostformat=hosts'                                  \
     14 ' https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts'         \
     15 ' https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt'         \
     16 ' https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt'               \
     17 ' http://someonewhocares.org/hosts/hosts'                                   \
     18 ' http://sysctl.org/cameleon/hosts'                                         \
     19 ' http://winhelp2002.mvps.org/hosts.txt'                                    \
     20 ' http://www.malwaredomainlist.com/hostslist/hosts.txt'                     \
     21 | sed -e 's/^$//g'); for x
     22 do
     23 	printf "Getting '%s' domain list...\n" "$(echo $x | cut -d / -f 3)" 1>&2
     24 	curl -L -s "$x"                                                         \
     25 	| sed -e 's/\r//'                                                       \
     26 	| grep -v '#\|^::1\|[[:space:]]localhost$'                              \
     27 	| tr '\t' ' '                                                           \
     28 	| sed -e '/^[\s]*$/d' -e 's/^[^\s]*\s//'                                \
     29 	| sort >> $_TEMP_FILE
     30 done
     31 
     32 cat $_TEMP_FILE                                                             \
     33 | sort                                                                      \
     34 | uniq                                                                      \
     35 | sed -e '/^[\s]*$/d'                                                       \
     36 | awk -v "IP=0.0.0.0" '{print IP" "$0}'                                     \
     37 | sudo tee $_HOSTS_FILE > /dev/null
     38 
     39 rm $_TEMP_FILE