2014-09-26 14:28:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Address to send ads to (the RPi)
|
2015-02-08 22:58:47 +00:00
|
|
|
piholeIP="127.0.0.1"
|
2014-09-26 14:28:44 +00:00
|
|
|
# Config file to hold URL rules
|
|
|
|
eventHorizion="/etc/dnsmasq.d/adList.conf"
|
|
|
|
|
|
|
|
# Download the original URL to a text file for easier parsing
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting yoyo ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -o /tmp/yoyo.txt -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=unixhosts&mimetype=plaintext
|
2014-10-17 23:46:15 +00:00
|
|
|
sleep 10
|
2014-10-11 20:55:23 +00:00
|
|
|
if [ -f /tmp/yoyo.txt ];then
|
|
|
|
cat /tmp/yoyo.txt | grep -v "<" | sed '/^$/d' | sed 's/\ /\\ /g' | sort > /tmp/matter.txt
|
|
|
|
else
|
|
|
|
echo "Unable to get yoyo ad list"
|
|
|
|
fi
|
2014-09-26 14:28:44 +00:00
|
|
|
|
|
|
|
# Download and append other ad URLs from different sources
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting winhelp2002 ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -s http://winhelp2002.mvps.org/hosts.txt | grep -v "#" | grep -v "127.0.0.1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting adaway ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -s https://adaway.org/hosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting hosts-file ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -s http://hosts-file.net/.%5Cad_servers.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting malwaredomainlist ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
|
2014-10-12 16:56:43 +00:00
|
|
|
echo "Getting adblock.gjtech ad list..."
|
2014-09-26 14:28:44 +00:00
|
|
|
curl -s http://adblock.gjtech.net/?format=unix-hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
|
2014-11-12 20:18:05 +00:00
|
|
|
echo "Getting someone who cares ad list..."
|
|
|
|
curl -s http://someonewhocares.org/hosts/hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' >> /tmp/matter.txt
|
2014-09-26 14:28:44 +00:00
|
|
|
|
|
|
|
# Sort the aggregated results and remove any duplicates
|
2015-01-25 01:11:28 +00:00
|
|
|
echo "removing duplicates and formatting to address=/<ad domain>/"$piholeIP
|
|
|
|
cat /tmp/matter.txt | sort | uniq | sed '/^$/d' | awk -v "IP=$piholeIP" '{sub(/\r$/,""); print "address=/"$0"/"IP}' > /tmp/andLight.txt
|
|
|
|
mv /tmp/andLight.txt $eventHorizion
|
2014-09-26 14:28:44 +00:00
|
|
|
|
|
|
|
# Restart DNS
|
2015-02-08 23:06:43 +00:00
|
|
|
service dnsmasq restart
|