From 01ac3c1dd3b7c1659e53b916f33f842bad14444a Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:01:12 -0500 Subject: [PATCH] Ditching the use of the loopback Pushing files so they are available when the new article gets posted. If the Pi's loopback is set in the hosts file, clients using it as a DNS server will try to connect to their own loopback, which does not have a Web server. So the real IP of the Pi is used. It is recommended to use a static IP since this will be acting as a server. Made one small change from some hard coded values to a variable. --- gravity.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index e1dad2bb..36ab544f 100755 --- a/gravity.sh +++ b/gravity.sh @@ -2,6 +2,9 @@ # http://pi-hole.net # Compiles a list of ad-serving domains by downloading them from multiple sources +# This script should only be run after you have a static IP address set on the Pi +piholeIP=$(hostname -I) + # Ad-list sources--one per line in single quotes sources=('https://adaway.org/hosts.txt' 'http://adblock.gjtech.net/?format=unix-hosts' @@ -31,11 +34,11 @@ latentWhitelist=$origin/latentWhitelist.txt echo "** Neutrino emissions detected..." # Create the pihole resource directory if it doesn't exist. Future files will be stored here -if [[ -d /etc/pihole/ ]];then +if [[ -d $piholeDir ]];then : else echo "** Creating pihole directory..." - sudo mkdir /etc/pihole + sudo mkdir $piholeDir fi # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines @@ -92,13 +95,14 @@ function gravity_advanced() cat $origin/$supernova | sort | uniq > $origin/$eventHorizon numberOf=$(cat $origin/$eventHorizon | wc -l | sed 's/^[ \t]*//') echo "** $numberOf unique domains trapped in the event horizon." - # Format domain list as "127.0.0.1 domain.com" + # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." - cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "127.0.0.1 "$0"\n::1 "$0}' > $origin/$accretionDisc + 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 raspberrypi" | cat - $origin/$accretionDisc > $origin/latent.$accretionDisc && mv $origin/latent.$accretionDisc $origin/$accretionDisc # Copy the file so dnsmasq can use it sudo cp $origin/$accretionDisc $adList }