From 9d99a4ef362401579ee5599fac32716556392fc6 Mon Sep 17 00:00:00 2001 From: Fourdee Date: Thu, 30 Jul 2015 17:24:24 +0100 Subject: [PATCH] Patch 3 - Dont use /etc/hosts /etc/pihole/gravity.list now stores the block list. Ensures the /etc/hosts file is left untouched. --- advanced/Scripts/chronometer.sh | 2 +- advanced/dnsmasq.conf | 1 + gravity.sh | 9 ++------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 74d0832..f595b09 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -11,7 +11,7 @@ do uptime | cut -d' ' -f11- echo "-------------------------------" # Uncomment to continually read the log file and display the current domain being blocked - #tail -f /var/log/pihole.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}' + #tail -f /var/log/pihole.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}' today=$(date "+%b %e") todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l) diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf index d8d2b26..25b2138 100644 --- a/advanced/dnsmasq.conf +++ b/advanced/dnsmasq.conf @@ -1,3 +1,4 @@ +addn-hosts=/etc/pihole/gravity.list domain-needed bogus-priv no-resolv diff --git a/gravity.sh b/gravity.sh index f4ef9d9..f1e70a6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -16,7 +16,7 @@ sources=('https://adaway.org/hosts.txt' 'http://winhelp2002.mvps.org/hosts.txt') # Variables for various stages of downloading and formatting the list -adList=/etc/hosts +adList=/etc/pihole/gravity.list origin=/etc/pihole piholeDir=/etc/pihole if [[ -f $piholeDir/pihole.conf ]];then @@ -101,12 +101,7 @@ function gravity_advanced() # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"'" $0}' > $origin/$accretionDisc - # Put the default host entries at the top of the file - echo "::1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc - echo "255.255.255.255 broadcasthost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc - echo "127.0.0.1 localhost" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc - echo "127.0.0.1 $(hostname)" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc - # Copy the file over as /etc/hosts so dnsmasq can use it + # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it sudo cp $origin/$accretionDisc $adList kill -HUP $(pidof dnsmasq) }