update-blocklist-2.shon commit improve webp-convert.sh (b8ae487)
   1#!/bin/sh
   2
   3#
   4#   update-blocklist-2.sh
   5#   Download a list of blocked domains and pass to dnsmasq
   6#
   7
   8target='blank'  # IP to resolve blocked domains to
   9configfile=/etc/dnsmasq.conf
  10
  11
  12# List server specification
  13listurl="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0"
  14extrasfile='/etc/blacklist' # Add additional entries here
  15reloadcmd='/etc/init.d/dnsmasq restart'  
  16tmpfile="/tmp/.adlist.$$"
  17tmpconf="/tmp/.dnsmasq.conf.$$"
  18fetchcmd="/usr/bin/curl "$listurl" -o "$tmpfile""
  19
  20$fetchcmd
  21
  22# Add additional entries 
  23[ -f "$extrasfile" ]  && cat $extrasfile >> $tmpfile
  24
  25# Check temp file
  26if  [ ! -s $tmpfile ]; then
  27  echo "temp file '$tmpfile' either doesn't exist or is empty; quitting"
  28  exit
  29fi
  30
  31# save old config (excluding address entries)
  32if [ -f "$configfile" ]; then
  33  cat $configfile | grep -v "address=" > $tmpconf
  34fi
  35
  36while read line; do
  37    echo "address=/${line}/${target}" >> $tmpconf
  38done < $tmpfile 
  39
  40mv $tmpconf $configfile
  41$reloadcmd
  42rm $tmpfile
  43exit