create_unbound_ad_servers.sh revision 356345
1#!/bin/sh 2# 3# Convert the Yoyo.org anti-ad server listing 4# into an unbound dns spoof redirection list. 5# Modified by Y.Voinov (c) 2014 6 7# Note: Wget required! 8 9# Variables 10dst_dir="/etc/opt/csw/unbound" 11work_dir="/tmp" 12list_addr="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=1&startdate%5Bday%5D=&startdate%5Bmonth%5D=&startdate%5Byear%5D=" 13 14# OS commands 15CAT=`which cat` 16ECHO=`which echo` 17WGET=`which wget` 18TR=`which tr` 19 20# Check Wget installed 21if [ ! -f $WGET ]; then 22 echo "Wget not found. Exiting..." 23 exit 1 24fi 25 26# remove special characters with tr to protect unbound.conf 27$WGET -O $work_dir/yoyo_ad_servers "$list_addr" && \ 28$CAT $work_dir/yoyo_ad_servers | \ 29$TR -d '";$\\' | \ 30while read line ; \ 31 do \ 32 $ECHO "local-zone: \"$line\" redirect" ;\ 33 $ECHO "local-data: \"$line A 127.0.0.1\"" ;\ 34 done > \ 35$dst_dir/unbound_ad_servers 36 37echo "Done." 38# then add an include line to your unbound.conf pointing to the full path of 39# the unbound_ad_servers file: 40# 41# include: $dst_dir/unbound_ad_servers 42# 43