1
0
mirror of https://github.com/moparisthebest/pi-hole synced 2024-12-23 07:38:50 -05:00
pi-hole/gravity-adv.sh

44 lines
2.0 KiB
Bash
Raw Normal View History

2014-09-26 10:28:44 -04:00
#!/bin/bash
# Address to send ads to (the RPi)
piholeIP="192.168.1.101"
# Config file to hold URL rules
eventHorizion="/etc/dnsmasq.d/adList.conf"
# Download the original URL to a text file for easier parsing
echo "Getting yoyo ad list..."
2014-09-26 10:28:44 -04:00
curl -o /tmp/yoyo.txt -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=unixhosts&mimetype=plaintext
2014-10-17 19:46:15 -04:00
sleep 10
2014-10-11 16:55:23 -04: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 10:28:44 -04:00
# Download and append other ad URLs from different sources
echo "Getting winhelp2002 ad list..."
2014-09-26 10:28:44 -04: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
echo "Getting adaway ad list..."
2014-09-26 10:28:44 -04: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
echo "Getting hosts-file ad list..."
2014-09-26 10:28:44 -04: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
echo "Getting malwaredomainlist ad list..."
2014-09-26 10:28:44 -04:00
curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
echo "Getting adblock.gjtech ad list..."
2014-09-26 10:28:44 -04:00
curl -s http://adblock.gjtech.net/?format=unix-hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> /tmp/matter.txt
# Sort the aggregated results and remove any duplicates
echo "Sorting and removing duplicates..."
2014-09-26 10:28:44 -04:00
cat /tmp/matter.txt | sort | uniq | sed '/^$/d' > /tmp/andLight.txt
2014-10-11 16:55:23 -04:00
# Read the file, prepend "address=/", and append the IP of the Raspberry Pi
# This creates a correctly-formatted config file
2014-09-26 10:28:44 -04:00
while read fermion
do
boson=$(echo "$fermion" | tr -d '\r')
echo "address=/$boson/$piholeIP" >> $eventHorizion
echo "Added $boson..."
2014-09-26 10:28:44 -04:00
done </tmp/andLight.txt
# Restart DNS
service dnsmasq restart