Benutzer-Werkzeuge

Action disabled: source

Shell Script zum Updaten der DNSmasq Files

#!/bin/ash
 
### short script that downloads a list of ad servers for use with
### dnsmasq to block ads.
###
 
# the ipaddress where we want to send the requests to, instead of the
# bannerservers
 
addcatcherip='127.0.0.1'
configfile=/opt/etc/dnsmasq.more.conf
 
# the args to add to the request to the yoyo server, to tell it that we want
# a hosts file and that we want to redirect to the addcatcher
listurlargs="hostformat=nohtml&showintro=0&mimetype=plaintext"
 
# URL of the ad server list to download
listurl="http://pgl.yoyo.org/adservers/serverlist.php?${listurlargs}"
 
# location of a file where hostnames not listed can be added
extrasfile='/opt/etc/add_hosts_t'
 
## command to reload dnsmasq - change according to your system
## not sure if we need this for dnsmasq
reloadcmd='/opt/etc/init.d/S56dnsmasq restart'
 
# temp files to use
tmpfile="/tmp/.adlist.$$"
tmpconffile="/tmp/.dnsmasq.conf.$$"
 
# command to fetch the list (alternatives commented out)
fetchcmd="/opt/bin/wget -q -O $tmpfile $listurl"
 
$fetchcmd
 
# add the extras
 [ -f "$extrasfile" ]  && cat $extrasfile >> $tmpfile
 
# check the temp file exists OK before overwriting the existing list
if  [ ! -s $tmpfile ]
then
echo "temp file '$tmpfile' either doesn't exist or is empty; quitting"
exit
fi
 
# get a fresh list of ad server addresses for dnsmasq to refuse
cat $configfile | grep -v "address=" > $tmpconffile
 
while read line; do
    ADDRESS="/${line}/${addcatcherip}"
    echo "address=\"${ADDRESS}\"" >> $tmpconffile
done < $tmpfile
 
mv $tmpconffile $configfile
$reloadcmd
rm $tmpfile
exit
Melden Sie sich an, um einen Kommentar zu erstellen.

Seiten-Werkzeuge