From 56c776af220b26e37d30bb756dd239846b5a93e2 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 19 May 2015 13:31:37 -0500 Subject: [PATCH 01/50] hosts format script --- advanced/dnsmasq.conf | 9 -- advanced/enable-dns.sh | 8 -- advanced/gravity.sh | 29 ------- advanced/lighttpd.conf | 35 -------- automated install/basic-install.sh | 66 --------------- block hulu ads/dnsmasq.conf | 12 --- block hulu ads/hulAdList.conf | 2 - block hulu ads/index.html | 8 -- block hulu ads/lighttpd.conf | 32 -------- block hulu ads/minidlna.conf | 6 -- block hulu ads/setup-resolv.sh | 6 -- block hulu ads/setup.sh | 71 ---------------- dnsmasq.conf | 6 -- gravity-adv.sh | 66 --------------- gravity.sh | 128 ++++++++++++++++++++++++----- index.html | 6 -- lighttpd.conf | 48 ----------- pihole.png | Bin 68 -> 0 bytes resolv.conf | 3 - 19 files changed, 108 insertions(+), 433 deletions(-) delete mode 100644 advanced/dnsmasq.conf delete mode 100644 advanced/enable-dns.sh delete mode 100755 advanced/gravity.sh delete mode 100644 advanced/lighttpd.conf delete mode 100755 automated install/basic-install.sh delete mode 100644 block hulu ads/dnsmasq.conf delete mode 100644 block hulu ads/hulAdList.conf delete mode 100644 block hulu ads/index.html delete mode 100644 block hulu ads/lighttpd.conf delete mode 100644 block hulu ads/minidlna.conf delete mode 100644 block hulu ads/setup-resolv.sh delete mode 100755 block hulu ads/setup.sh delete mode 100644 dnsmasq.conf delete mode 100755 gravity-adv.sh mode change 100644 => 100755 gravity.sh delete mode 100644 index.html delete mode 100644 lighttpd.conf delete mode 100644 pihole.png delete mode 100644 resolv.conf diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf deleted file mode 100644 index 70d062f6..00000000 --- a/advanced/dnsmasq.conf +++ /dev/null @@ -1,9 +0,0 @@ -domain-needed -bogus-priv -no-resolv -server=127.0.0.1 -server=8.8.8.8 -server=8.8.4.4 -interface=eth0 -cache-size=10000 -log-queries \ No newline at end of file diff --git a/advanced/enable-dns.sh b/advanced/enable-dns.sh deleted file mode 100644 index 0d04ed0f..00000000 --- a/advanced/enable-dns.sh +++ /dev/null @@ -1,8 +0,0 @@ -# !/bin/bash -# Download the ad list -sudo /usr/local/bin/gravity.sh - -# Enable DNS and start blocking ads -sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -sudo mv /etc/dnsmasq.conf.pihole /etc/dnsmasq.conf -sudo service dnsmasq start diff --git a/advanced/gravity.sh b/advanced/gravity.sh deleted file mode 100755 index e9fa14bc..00000000 --- a/advanced/gravity.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# /usr/local/bin/gravity.sh - -# URL to pull list of known ad servers from -adListURL="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext" - -# Address to send ads to -piholeIP="127.0.0.1" - -# Where the list of ad servers are stored once downloaded -# Any file in /etc/dnsmasq.d is loaded automatically when the service starts -adFile="/etc/dnsmasq.d/adList.conf" - -# The temporary file for holding -eventHorizion="/etc/dnsmasq.d/adList.conf.tmp" - -# Parses out the default 127.0.0.1 address and replaces it with the IP where ads will be sent -curl $adListURL | sed "s/127\.0\.0\.1/$piholeIP/" > $eventHorizion - -sleep 10 - -# If the temporary list of ad servers already exists (the eventHorizion) -if [ -f "$eventHorizion" ];then - # Then replace it as the new ad file - mv -f $eventHorizion $adFile -else - echo "Error building the ad list, please try again." - exit 1 -fi \ No newline at end of file diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf deleted file mode 100644 index 3c23a2b9..00000000 --- a/advanced/lighttpd.conf +++ /dev/null @@ -1,35 +0,0 @@ -server.modules = ( - "mod_access", - "mod_alias", - "mod_compress", - "mod_redirect", - "mod_auth", - "mod_rewrite" -) - -server.document-root = "/var/www" -server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) -server.errorlog = "/var/log/lighttpd/error.log" -server.pid-file = "/var/run/lighttpd.pid" -server.username = "www-data" -server.groupname = "www-data" -server.port = 80 - - -index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) -url.access-deny = ( "~", ".inc" ) -static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) - -compress.cache-dir = "/var/cache/lighttpd/compress/" -compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) - -# default listening port for IPv6 falls back to the IPv4 port -include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port -include_shell "/usr/share/lighttpd/create-mime.assign.pl" -include_shell "/usr/share/lighttpd/include-conf-enabled.pl" - -# Rewrites all URLs to the /var/www/pihole/index.html -# This should be a blank file (for speed) -$HTTP["host"] =~ ".*" { - url.rewrite = (".*" => "pihole/index.html") -} \ No newline at end of file diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh deleted file mode 100755 index 9068d674..00000000 --- a/automated install/basic-install.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# Pi-hole automated install -# Raspberry Pi Ad-blocker -# -# Install with this command (from the Pi): -# -# curl -s "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/automated%20install/basic-install.sh" | bash -# -# Or run the commands below in order - -clear -echo " _____ _ _ _ " -echo " | __ (_) | | | | " -echo " | |__) | __ | |__ ___ | | ___ " -echo " | ___/ | |__| | '_ \ / _ \| |/ _ \ " -echo " | | | | | | | | (_) | | __/ " -echo " |_| |_| |_| |_|\___/|_|\___| " -echo " " -echo " Raspberry Pi Ad-blocker " -echo " " -echo " Automated install " -echo " --Advanced-- " -echo " " -echo " " -sleep 2 - -echo "Updating the Pi..." -sudo apt-get update -sudo apt-get -y upgrade - -echo "Installing DNS..." -sudo apt-get -y install dnsutils dnsmasq - -echo "Installing a Web server" -sudo apt-get -y install lighttpd -sudo chown www-data:www-data /var/www -sudo chmod 775 /var/www -sudo usermod -a -G www-data pi - -echo "Stopping services to modify them..." -sudo service dnsmasq stop -sudo service lighttpd stop - -echo "Backing up original config files and downloading Pi-hole ones..." -sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig -sudo mv /var/www/index.lighttpd.html /var/www/index.lighttpd.orig -sudo curl -o /etc/dnsmasq.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf" -sudo curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf" -sudo mkdir /var/www/pihole -sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/index.html" - -echo "Turning services back on..." -sudo service dnsmasq start -sudo service lighttpd start - -echo "Locating the Pi-hole..." -sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity-adv.sh" -sudo chmod 755 /usr/local/bin/gravity.sh -echo "Entering the event horizon..." -sudo /usr/local/bin/gravity.sh - -echo "Restarting services..." -sudo service dnsmasq restart -sudo service lighttpd restart - diff --git a/block hulu ads/dnsmasq.conf b/block hulu ads/dnsmasq.conf deleted file mode 100644 index 74dc2f18..00000000 --- a/block hulu ads/dnsmasq.conf +++ /dev/null @@ -1,12 +0,0 @@ -no-resolv -no-poll -server=/localnet/192.168.0.1 -server=/localnet/8.8.8.8 -server=/localnet/8.8.4.4 -domain-needed -interface=eth0 -strict-order -min-port=4096 -cache-size=10000 -log-queries -bogus-priv diff --git a/block hulu ads/hulAdList.conf b/block hulu ads/hulAdList.conf deleted file mode 100644 index 90e6cc4e..00000000 --- a/block hulu ads/hulAdList.conf +++ /dev/null @@ -1,2 +0,0 @@ -address=/ads.hulu.com/192.168.1.101 -address=/ads-v-darwin.hulu.com/192.168.1.101 \ No newline at end of file diff --git a/block hulu ads/index.html b/block hulu ads/index.html deleted file mode 100644 index ecf9666b..00000000 --- a/block hulu ads/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - -Pi-hole blocked an ad - - -

No ads here

- - \ No newline at end of file diff --git a/block hulu ads/lighttpd.conf b/block hulu ads/lighttpd.conf deleted file mode 100644 index 354a2d6d..00000000 --- a/block hulu ads/lighttpd.conf +++ /dev/null @@ -1,32 +0,0 @@ -server.modules = ( - "mod_access", - "mod_alias", - "mod_compress", - "mod_redirect", -# "mod_rewrite" -) - -server.document-root = "/var/www" -server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) -server.errorlog = "/var/log/lighttpd/error.log" -server.pid-file = "/var/run/lighttpd.pid" -server.username = "www-data" -server.groupname = "www-data" -server.port = 80 - - -index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) -url.access-deny = ( "~", ".inc" ) -static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) - -compress.cache-dir = "/var/cache/lighttpd/compress/" -compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) - -# default listening port for IPv6 falls back to the IPv4 port -include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port -include_shell "/usr/share/lighttpd/create-mime.assign.pl" -include_shell "/usr/share/lighttpd/include-conf-enabled.pl" - -$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com|" { - url.redirect = ( "^/(.*)" => "http://192.168.1.101:8200/MediaItems/19.mov") -} diff --git a/block hulu ads/minidlna.conf b/block hulu ads/minidlna.conf deleted file mode 100644 index 9eccc7b6..00000000 --- a/block hulu ads/minidlna.conf +++ /dev/null @@ -1,6 +0,0 @@ -media_dir=V,/var/lib/minidlna/videos/ -port=8200 -friendly_name=pihole -serial=12345678 -model_number=1 -inotify=yes \ No newline at end of file diff --git a/block hulu ads/setup-resolv.sh b/block hulu ads/setup-resolv.sh deleted file mode 100644 index d894f12f..00000000 --- a/block hulu ads/setup-resolv.sh +++ /dev/null @@ -1,6 +0,0 @@ -# !/bin/bash -# DNS config file -# Run as a local script since modifying it will disconnect the Internet connection -sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -sudo mv /etc/dnsmasq.conf.pihole /etc/dnsmasq.conf -sudo service dnsmasq start diff --git a/block hulu ads/setup.sh b/block hulu ads/setup.sh deleted file mode 100755 index 450fd43d..00000000 --- a/block hulu ads/setup.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# Block Hulu Plus ads using a Raspberry Pi - -# Install with this command (from the Pi): -# -# curl -s https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/block%20hulu%20ads/setup.sh | bash -# -# Or run the commands below in order - -# Update the Pi -sudo apt-get update -#sudo apt-get -y upgrade - -# Install DNS -sudo apt-get -y install dnsutils dnsmasq -sudo service dnsmasq stop - -# Install Web server -sudo apt-get -y install lighttpd -sudo service lighttpd stop - -# Install streaming software -sudo apt-get -y install minidlna -sudo service minidlna stop - -# Configure Web server -#sudo lighty-enable-mod fastcgi-php -sudo chown www-data:www-data /var/www -sudo chmod 775 /var/www -sudo usermod -a -G www-data pi -sudo mv /var/www/index.lighttpd.html /var/www/index.lighttpd.orig -sudo curl -o /var/www/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/block%20hulu%20ads/index.html" -sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig -sudo curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/block%20hulu%20ads/lighttpd.conf" - -# Configure streaming service -sudo mv /etc/minidlna.conf /etc/minidlna.conf.orig -sudo mkdir /var/lib/minidlna/videos/ -sudo curl -o /etc/minidlna.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/block%20hulu%20ads/minidlna.conf" -sudo service minidlna start -sudo curl -o /var/lib/minidlna/videos/pi-hole.mov "https://dl.dropboxusercontent.com/u/16366947/Documents/Videos/pi-hole.mov" -sudo service minidlna force-reload -tail /var/log/minidlna.log - -# Configure DNS -sudo curl -o /etc/dnsmasq.conf.pihole "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/dnsmasq.conf" -sudo curl -o /tmp/piholedns.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/block%20hulu%20ads/setup-resolv.sh" -sudo chmod 755 /tmp/piholedns.sh - -# Download [advanced] ad-blocking script and then run it -# http://jacobsalmela.com/raspberry-pi-ad-blocker-advanced-setup/ -sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity-adv.sh" -sudo chmod 755 /usr/local/bin/gravity.sh -clear -echo "" -echo "" -echo "" -echo "" -echo "Go get some coffee--this will take a while" -echo "" -echo "" -echo "" -echo "" -sleep 5 -sudo /usr/local/bin/gravity.sh -sudo service dnsmasq stop - -# Restart everything to apply all the changes -sudo service lighttpd start -sudo service minidlna start -sudo /tmp/piholedns.sh \ No newline at end of file diff --git a/dnsmasq.conf b/dnsmasq.conf deleted file mode 100644 index 39987b90..00000000 --- a/dnsmasq.conf +++ /dev/null @@ -1,6 +0,0 @@ -domain-needed -interface=eth0 -min-port=4096 -cache-size=10000 -log-queries -bogus-priv diff --git a/gravity-adv.sh b/gravity-adv.sh deleted file mode 100755 index 4b62817e..00000000 --- a/gravity-adv.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# The Pi-hole now blocks over 120,000 ad domains -# Address to send ads to (the RPi) -piholeIP="127.0.0.1" -# Optionally, uncomment to automatically detect the local IP address. -#piholeIP=$(hostname -I) - -# Config file to hold URL rules -eventHorizion="/etc/dnsmasq.d/adList.conf" -blacklist=/etc/pihole/blacklist.txt -whitelist=/etc/pihole/whitelist.txt - -# Create the pihole resource directory if it doesn't exist. Future files will be stored here -if [[ -d /etc/pihole/ ]];then - : -else - echo "Forming pihole directory..." - sudo mkdir /etc/pihole -fi - -echo "Getting yoyo ad list..." # Approximately 2452 domains at the time of writing -curl -s -d mimetype=plaintext -d hostformat=unixhosts http://pgl.yoyo.org/adservers/serverlist.php? | sort > /tmp/matter.txt -echo "Getting winhelp2002 ad list..." # 12985 domains -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..." # 445 domains -curl -s https://adaway.org/hosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> /tmp/matter.txt -echo "Getting hosts-file ad list..." # 28050 domains -curl -s http://hosts-file.net/.%5Cad_servers.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> /tmp/matter.txt -echo "Getting malwaredomainlist ad list..." # 1352 domains -curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $3}' | grep -v '^\\' | grep -v '\\$' | sort >> /tmp/matter.txt -echo "Getting adblock.gjtech ad list..." # 696 domains -curl -s http://adblock.gjtech.net/?format=unix-hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> /tmp/matter.txt -echo "Getting someone who cares ad list..." # 10600 -curl -s http://someonewhocares.org/hosts/hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | grep -v '^\\' | grep -v '\\$' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> /tmp/matter.txt -echo "Getting Mother of All Ad Blocks list..." # 102168 domains!! Thanks Kacy -curl -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ http://adblock.mahakala.is/ | grep -v "#" | awk '{print $2}' | sort >> /tmp/matter.txt - -# Add entries from the local blacklist file if it exists in /etc/pihole directory -if [[ -f $blacklist ]];then - echo "Getting the local blacklist from /etc/pihole directory" - cat $blacklist >> /tmp/matter.txt -else - : -fi - -# Sort the aggregated results and remove any duplicates -# Remove entries from the whitelist file if it exists at the root of the current user's home folder -if [[ -f $whitelist ]];then - echo "Removing duplicates, whitelisting, and formatting the list of domains..." - cat /tmp/matter.txt | sed $'s/\r$//' | sort | uniq | sed '/^$/d' | grep -v -x -f $whitelist | awk -v "IP=$piholeIP" '{sub(/\r$/,""); print "address=/"$0"/"IP}' > /tmp/andLight.txt - numberOfSitesWhitelisted=$(cat $whitelist | wc -l | sed 's/^[ \t]*//') - echo "$numberOfSitesWhitelisted domains whitelisted." -else - echo "Removing duplicates and formatting the list of domains..." - cat /tmp/matter.txt | sed $'s/\r$//' | sort | uniq | sed '/^$/d' | awk -v "IP=$piholeIP" '{sub(/\r$/,""); print "address=/"$0"/"IP}' > /tmp/andLight.txt -fi - -# Count how many domains/whitelists were added so it can be displayed to the user -numberOfAdsBlocked=$(cat /tmp/andLight.txt | wc -l | sed 's/^[ \t]*//') -echo "$numberOfAdsBlocked ad domains blocked." - -# Turn the file into a dnsmasq config file -sudo mv /tmp/andLight.txt $eventHorizion - -# Restart DNS -sudo service dnsmasq restart diff --git a/gravity.sh b/gravity.sh old mode 100644 new mode 100755 index c3c766b0..325eb824 --- a/gravity.sh +++ b/gravity.sh @@ -1,28 +1,116 @@ #!/bin/bash -# /usr/local/bin/gravity.sh +# http://pi-hole.net -# URL to pull list of known ad servers from -adListURL="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext" +# Ad-list sources--one per line in single quotes +sources=('https://adaway.org/hosts.txt' +'http://adblock.gjtech.net/?format=unix-hosts' +'http://adblock.mahakala.is/' +'http://hosts-file.net/.%5Cad_servers.txt' +'http://www.malwaredomainlist.com/hostslist/hosts.txt' +'http://pgl.yoyo.org/adservers/serverlist.php?' +'http://someonewhocares.org/hosts/hosts' +'http://winhelp2002.mvps.org/hosts.txt') -# Address to send ads to -piholeIP="127.0.0.1" +# Variables for various stages of downloading and formatting the list +origin=~/Desktop/pihole +piholeDir=/etc/pihole +justDomainsExtension=domains +matter=pihole.0.matter.txt +andLight=pihole.1.andLight.txt +supernova=pihole.2.supernova.txt +eventHorizon=pihole.3.eventHorizon.txt +accretionDisc=pihole.4.accretionDisc.txt +eyeOfTheNeedle=pihole.5.wormhole.txt +adList=/etc/hosts +blacklist=$piholeDir/blacklist.txt +latentBlacklist=$origin/latentBlacklist.txt +whitelist=$piholeDir/whitelist.txt +latentWhitelist=$origin/latentWhitelist.txt -# Where the list of ad servers are stored once downloaded -# Any file in /etc/dnsmasq.d is loaded automatically when the service starts -adFile="/etc/dnsmasq.d/adList.conf" +echo "** Neutrino emissions detected..." -# The temporary file for holding -eventHorizion="/etc/dnsmasq.d/adList.conf.tmp" - -# Parses out the default 127.0.0.1 address and replaces it with the IP where ads will be sent -curl $adListURL | sed "s/127\.0\.0\.1/$piholeIP/" > $eventHorizion +# Create the pihole resource directory if it doesn't exist. Future files will be stored here +if [[ -d /etc/pihole/ ]];then + : +else + echo "** Creating pihole directory..." + sudo mkdir /etc/pihole +fi + +# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines +for ((i = 0; i < "${#sources[@]}"; i++)) +do + # Get just the domain from the URL + domain=$(echo "${sources[$i]}" | cut -d'/' -f3) + + # Save the file as list.#.domain + saveLocation=$origin/"list"."$i"."$domain" + + # Use a case statement to download lists that need special cURL commands to complete properly + case "$domain" in + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + + "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + + *) data=$(curl -s -z $saveLocation."$justDomainsExtension" -A "Mozilla/10.0" "${sources[$i]}");; + esac + + if [[ -n "$data" ]];then + echo "Getting $domain list..." + # Remove comments and print only the domain name + echo "$data" | awk 'NF {if ($1 !~ "#") print $2}' > $saveLocation."$justDomainsExtension" + else + echo "Skipping $domain list because it does not have any new entries..." + fi +done -# If the temporary list of ad servers already exists (the eventHorizion) -if [ -f "$eventHorizion" ];then - # Then replace it as the new ad file - mv -f $eventHorizion $adFile +# Find all files with the .domains extension and compile them into one file +echo "** Aggregating list of domains..." +find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; > $origin/$matter + +# Append blacklist entries if they exist +if [[ -f $blacklist ]];then + numberOf=$(cat $blacklist | wc -l | sed 's/^[ \t]*//') + echo "** Blacklisting $numberOf domain(s)..." + cat $blacklist >> /tmp/matter.txt else - echo "Error building the ad list, please try again." - exit 1 + : fi -service dnsmasq restart \ No newline at end of file + +function gravity_advanced() +########################### + { + numberOf=$(cat $origin/$andLight | wc -l | sed 's/^[ \t]*//') + echo "** $numberOf domains being pulled in by gravity..." + # Remove carriage returns and preceding whitespace + cat $origin/$andLight | sed $'s/\r$//' | sed '/^\s*$/d' > $origin/$supernova + # Sort and remove duplicates + 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" + echo "** Formatting domains into a HOSTS file..." + cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "127.0.0.1 "$0}' > $origin/$accretionDisc + # Put the default 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 + sudo cp $adList $adList.orig + sudo cp $origin/$accretionDisc $adList + } + +# Whitelist (if applicable) then remove duplicates and format for dnsmasq +if [[ -f $whitelist ]];then + # Remove whitelist entries + numberOf=$(cat $whitelist | wc -l | sed 's/^[ \t]*//') + echo "** Whitelisting $numberOf domain(s)..." + # Append a "$" to the end of each line so it can be parsed out with grep -w + echo -n "^$" > $latentWhitelist + awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist + cat $origin/$matter | grep -vwf $latentWhitelist > $origin/$andLight + gravity_advanced + +else + cat $origin/$matter > $origin/$andLight + gravity_advanced +fi \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index aa7b9c93..00000000 --- a/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/lighttpd.conf b/lighttpd.conf deleted file mode 100644 index 16e4c8a2..00000000 --- a/lighttpd.conf +++ /dev/null @@ -1,48 +0,0 @@ -# /etc/lighttpd/lighttpd.conf -server.modules = ( - "mod_access", - "mod_alias", - "mod_compress", - "mod_redirect", - "mod_auth", - "mod_rewrite", -) - -server.document-root = "/var/www" -server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) -server.errorlog = "/var/log/lighttpd/error.log" -server.pid-file = "/var/run/lighttpd.pid" -server.username = "www-data" -server.groupname = "www-data" -server.port = 80 - - -index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) -url.access-deny = ( "~", ".inc" ) -static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) - -compress.cache-dir = "/var/cache/lighttpd/compress/" -compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) - -# default listening port for IPv6 falls back to the IPv4 port -include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port -include_shell "/usr/share/lighttpd/create-mime.assign.pl" -include_shell "/usr/share/lighttpd/include-conf-enabled.pl" - -# Optional if a password protected directory is desired -# See http://jacobsalmela.com/password-protect-a-lighttpd-web-server-on-a-raspberry-pi-using-mod-auth/ -#auth.backend = "htdigest" -#auth.backend.htdigest.userfile = "/etc/lighttpd/.htpasswd/lighttpd-htdigest.user" -#auth.require = ( "/stream/" => -# ( -# "method" => "digest", -# "realm" => "lcars", -# "require" => "valid-user" -# ), -#) - -# Rewrites all URLs to the /var/www/pihole/index.html -# This should be a blank file (for speed) -$HTTP["host"] =~ ".*" { - url.rewrite = (".*" => "pihole/index.html") -} diff --git a/pihole.png b/pihole.png deleted file mode 100644 index 9da19eacad3b03bb08bbddbbf4ac48dd78b3d838..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J Q1PU{Fy85}Sb4q9e0B4a5jsO4v diff --git a/resolv.conf b/resolv.conf deleted file mode 100644 index a605b3f9..00000000 --- a/resolv.conf +++ /dev/null @@ -1,3 +0,0 @@ -nameserver 192.168.1.101 -nameserver 8.8.8.8 -nameserver 8.8.4.4 From 61c99ff145799c3a594523069cba2f2b857e8a5e Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 19 May 2015 13:32:37 -0500 Subject: [PATCH 02/50] forgot to change origin dir --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 325eb824..0966a04d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -12,7 +12,7 @@ sources=('https://adaway.org/hosts.txt' 'http://winhelp2002.mvps.org/hosts.txt') # Variables for various stages of downloading and formatting the list -origin=~/Desktop/pihole +origin=/tmp piholeDir=/etc/pihole justDomainsExtension=domains matter=pihole.0.matter.txt From 457b70f5c5c1f30030b4a4ece619dc61a6f934b4 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Thu, 4 Jun 2015 08:21:44 -0500 Subject: [PATCH 03/50] add IPv6 support in the hosts file Still need to get lighted to use IPv6. I am doing this because some ads can get through using IPv6 if the IPv4 version is blocked. Also, it seems to work fine as far as performance even though it doubles the file size... Also added a few comments for better documentation. --- gravity.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gravity.sh b/gravity.sh index 0966a04d..c7a01f88 100755 --- a/gravity.sh +++ b/gravity.sh @@ -1,5 +1,6 @@ #!/bin/bash # http://pi-hole.net +# Compiles a list of ad-serving domains by downloading them from multiple sources # Ad-list sources--one per line in single quotes sources=('https://adaway.org/hosts.txt' @@ -48,7 +49,7 @@ do # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in - "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; @@ -58,6 +59,9 @@ do if [[ -n "$data" ]];then echo "Getting $domain list..." # Remove comments and print only the domain name + # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious + # This helps with that and makes it easier to read + # It also helps with debugging so each stage of the script can be researched more in depth echo "$data" | awk 'NF {if ($1 !~ "#") print $2}' > $saveLocation."$justDomainsExtension" else echo "Skipping $domain list because it does not have any new entries..." @@ -90,12 +94,12 @@ function gravity_advanced() echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "127.0.0.1 domain.com" echo "** Formatting domains into a HOSTS file..." - cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "127.0.0.1 "$0}' > $origin/$accretionDisc - # Put the default entries at the top of the file + cat $origin/$eventHorizon | awk '{sub(/\r$/,""); print "127.0.0.1 "$0"\n::1 "$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 - sudo cp $adList $adList.orig + # Copy the file so dnsmasq can use it sudo cp $origin/$accretionDisc $adList } @@ -109,7 +113,6 @@ if [[ -f $whitelist ]];then awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist cat $origin/$matter | grep -vwf $latentWhitelist > $origin/$andLight gravity_advanced - else cat $origin/$matter > $origin/$andLight gravity_advanced From 7ed49b07cfe75fe9d14e038bea27eeec27bb4112 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:27:10 -0500 Subject: [PATCH 04/50] Enabling IPv6 --- advanced/modules | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 advanced/modules diff --git a/advanced/modules b/advanced/modules new file mode 100644 index 00000000..47fae9ee --- /dev/null +++ b/advanced/modules @@ -0,0 +1,8 @@ +# /etc/modules: kernel modules to load at boot time. +# +# This file contains the names of kernel modules that should be loaded +# at boot time, one per line. Lines beginning with "#" are ignored. +# Parameters can be specified after the module name. + +snd-bcm2835 +ipv6 \ No newline at end of file From 1ef3ab5af85ec224428001c4715af576eaf45fc2 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:27:43 -0500 Subject: [PATCH 05/50] very similar lighttpd conf --- advanced/lighttpd.conf | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 advanced/lighttpd.conf diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf new file mode 100644 index 00000000..e875897e --- /dev/null +++ b/advanced/lighttpd.conf @@ -0,0 +1,41 @@ +server.modules = ( + "mod_expire", + "mod_access", + "mod_alias", + "mod_compress", + "mod_redirect", + "mod_auth", + "mod_rewrite" +) + +server.document-root = "/var/www" +server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) +server.errorlog = "/var/log/lighttpd/error.log" +server.pid-file = "/var/run/lighttpd.pid" +server.username = "www-data" +server.groupname = "www-data" +server.port = 80 + + +index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) +url.access-deny = ( "~", ".inc" ) +static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) + +compress.cache-dir = "/var/cache/lighttpd/compress/" +compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) + +# default listening port for IPv6 falls back to the IPv4 port +include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port +include_shell "/usr/share/lighttpd/create-mime.assign.pl" +include_shell "/usr/share/lighttpd/include-conf-enabled.pl" + +# Set access to 1 day for better query performance when the list gets so large +# http://jacobsalmela.com/raspberry-pi-block-ads-adtrap/#comment-2013820434 +$HTTP["url"] =~ "^/pihole/" { + expire.url = ("" => "access plus 1 days") +} + +# Rewrites all URLs to the /var/www/pihole/index.html +$HTTP["host"] =~ ".*" { + url.rewrite = (".*" => "pihole/index.html") +} \ No newline at end of file From 1637e9fe58a53c40b14369d4294a6fa4c363ae1b Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:27:57 -0500 Subject: [PATCH 06/50] Enabling IPv6 on the Pi itself --- advanced/interfaces | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 advanced/interfaces diff --git a/advanced/interfaces b/advanced/interfaces new file mode 100644 index 00000000..806a6820 --- /dev/null +++ b/advanced/interfaces @@ -0,0 +1,10 @@ +auto lo + +iface lo inet loopback +iface eth0 inet dhcp +iface eth0 inet6 dhcp + +allow-hotplug wlan0 +iface wlan0 inet manual +wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf +iface default inet dhcp \ No newline at end of file From 857c1e6edf90e309215b3efe4571b9ad26bd884f Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:28:41 -0500 Subject: [PATCH 07/50] new index to display tiny gif The GIF is only 25 Bytes. Thanks to http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever --- advanced/index.html | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 advanced/index.html diff --git a/advanced/index.html b/advanced/index.html new file mode 100644 index 00000000..2049cfe9 --- /dev/null +++ b/advanced/index.html @@ -0,0 +1,5 @@ + + +
+ + \ No newline at end of file From 68ff6b02f92e3d8e3da8ca2ed75c0acc34361ee0 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:29:13 -0500 Subject: [PATCH 08/50] listening on IPv6, too Removed server=127.0.0.1 because it listens there by default --- advanced/dnsmasq.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 advanced/dnsmasq.conf diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf new file mode 100644 index 00000000..68b210e7 --- /dev/null +++ b/advanced/dnsmasq.conf @@ -0,0 +1,10 @@ +domain-needed +bogus-priv +no-resolv +server=8.8.8.8 +server=8.8.4.4 +interface=eth0 +listen-address=::1 +listen-address=127.0.0.1 +cache-size=10000 +log-queries \ No newline at end of file From 7290f7f9501857e5dd00f1950bcbcc0028937c32 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:29:54 -0500 Subject: [PATCH 09/50] Multiple gif files to choose from 25Bytes is the smallest, but can sometimes display weird on different browser/systems. Pick the one that works the best for you. --- advanced/GIFs/25Bytes.gif | Bin 0 -> 35 bytes advanced/GIFs/26Bytes.gif | Bin 0 -> 26 bytes advanced/GIFs/37Bytes.gif | Bin 0 -> 37 bytes advanced/GIFs/43Bytes.gif | Bin 0 -> 43 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 advanced/GIFs/25Bytes.gif create mode 100644 advanced/GIFs/26Bytes.gif create mode 100644 advanced/GIFs/37Bytes.gif create mode 100644 advanced/GIFs/43Bytes.gif diff --git a/advanced/GIFs/25Bytes.gif b/advanced/GIFs/25Bytes.gif new file mode 100644 index 0000000000000000000000000000000000000000..472727f293859cf3859f33a6bfbb0de9b609c4fb GIT binary patch literal 35 ncmZ?wbhEHbWMp7uXkcXc|NlP&1A`6_1Nn>$3`|Tej11NQg`Nf5 literal 0 HcmV?d00001 diff --git a/advanced/GIFs/26Bytes.gif b/advanced/GIFs/26Bytes.gif new file mode 100644 index 0000000000000000000000000000000000000000..264e471abd04356be068ad9cc24fc181fde8ae7a GIT binary patch literal 26 ccmZ?wbhEHbWMp7uVEE6V!vF+eHWPz2062yN6#xJL literal 0 HcmV?d00001 diff --git a/advanced/GIFs/37Bytes.gif b/advanced/GIFs/37Bytes.gif new file mode 100644 index 0000000000000000000000000000000000000000..b3aa80d843a929ce4e5af18912072ba4157c115b GIT binary patch literal 37 kcmZ?wbhEHbWMp7u00PCIER0-0rVfY$7Gq-aVPvod09bhgj{pDw literal 0 HcmV?d00001 diff --git a/advanced/GIFs/43Bytes.gif b/advanced/GIFs/43Bytes.gif new file mode 100644 index 0000000000000000000000000000000000000000..9884f476b9c7cec495c94005574d7eb7a39475fa GIT binary patch literal 43 ucmZ?wbhEHbWMp7uXkcXc|NlP&1B2pE7Dg_hfDVuiq!<|(n3#MR8LR=x#0L!k literal 0 HcmV?d00001 From c5638417141d6313695aa76930dd79f69181ffe4 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 6 Jun 2015 23:34:32 -0500 Subject: [PATCH 10/50] changing the origin folder Originally, I had this set to /run/shm (in RAM) but ran into errors when the list reached 900,000 entries. Then I moved it to /tmp. Finally, I decided to just put the files in the pihole dir so they are available after reboots. This will help with only downloading the lists when absolutely needed--respecting the bandwidth of the people serving the lists. It is also possible to add addn-hosts=/path/to/hosts.conf within the dnsmasq.conf file if you don't want to use hosts. For simplicity and speed, I just use the regular hosts file. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c7a01f88..e1dad2bb 100755 --- a/gravity.sh +++ b/gravity.sh @@ -13,7 +13,7 @@ sources=('https://adaway.org/hosts.txt' 'http://winhelp2002.mvps.org/hosts.txt') # Variables for various stages of downloading and formatting the list -origin=/tmp +origin=/etc/pihole piholeDir=/etc/pihole justDomainsExtension=domains matter=pihole.0.matter.txt From 01ac3c1dd3b7c1659e53b916f33f842bad14444a Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:01:12 -0500 Subject: [PATCH 11/50] 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 } From e6b17ae8e900296e6a981d3808cb41f542a4e27f Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:02:17 -0500 Subject: [PATCH 12/50] Removing IPv6 support for now I'm not fully up on my IPv6, and using the loopback doesn't work for clients anyway as described in the latest commit to gravity.sh --- advanced/dnsmasq.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf index 68b210e7..4340f83a 100644 --- a/advanced/dnsmasq.conf +++ b/advanced/dnsmasq.conf @@ -4,7 +4,6 @@ no-resolv server=8.8.8.8 server=8.8.4.4 interface=eth0 -listen-address=::1 listen-address=127.0.0.1 cache-size=10000 log-queries \ No newline at end of file From 9d5a7531cad2ab74a56d654659ca5c2d2ebcfdc9 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:04:30 -0500 Subject: [PATCH 13/50] Testing script for a mini LCD This script is for use with an Adafruit LCD so that you can peek at the domains as they are blocked in real time. It's not necessary for the Pi-hole to function, but something fun I am working on. There will be a video in the next article I post. --- advanced/chronometer.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 advanced/chronometer.sh diff --git a/advanced/chronometer.sh b/advanced/chronometer.sh new file mode 100755 index 00000000..a57038ec --- /dev/null +++ b/advanced/chronometer.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Infinite loop that can be used to display ad domains on a Pi touch screen +# It will continually display ads that are blocked in real time on the screen +# Set the pi user to log in automatically and add run this script from .bashrc +clear +echo "" +echo " +-+-+-+-+-+-+-+ " +echo " Pi-hole " +echo " +-+-+-+-+-+-+-+ " +echo "" +echo " A black hole for" +echo " Internet Ads " +echo "" +echo " http://pi-hole.net" +echo "" +echo " Pi-hole IP: $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" +echo "" +echo "Ads blocked will show up once" +echo "you set your DNS server." +echo "" +sleep 7 +tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}' \ No newline at end of file From 294cf6d595df02897caaeac65da6375fe047f1f7 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:13:59 -0500 Subject: [PATCH 14/50] Removing since not using IPv6 right now --- advanced/interfaces | 10 ---------- advanced/modules | 8 -------- 2 files changed, 18 deletions(-) delete mode 100644 advanced/interfaces delete mode 100644 advanced/modules diff --git a/advanced/interfaces b/advanced/interfaces deleted file mode 100644 index 806a6820..00000000 --- a/advanced/interfaces +++ /dev/null @@ -1,10 +0,0 @@ -auto lo - -iface lo inet loopback -iface eth0 inet dhcp -iface eth0 inet6 dhcp - -allow-hotplug wlan0 -iface wlan0 inet manual -wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf -iface default inet dhcp \ No newline at end of file diff --git a/advanced/modules b/advanced/modules deleted file mode 100644 index 47fae9ee..00000000 --- a/advanced/modules +++ /dev/null @@ -1,8 +0,0 @@ -# /etc/modules: kernel modules to load at boot time. -# -# This file contains the names of kernel modules that should be loaded -# at boot time, one per line. Lines beginning with "#" are ignored. -# Parameters can be specified after the module name. - -snd-bcm2835 -ipv6 \ No newline at end of file From e8b33ec8eef4631bab75a3ce07b4c231bc395f2c Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:14:21 -0500 Subject: [PATCH 15/50] Automated installer test --- advanced/automated instal/basic-install.sh | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 advanced/automated instal/basic-install.sh diff --git a/advanced/automated instal/basic-install.sh b/advanced/automated instal/basic-install.sh new file mode 100755 index 00000000..3eee116c --- /dev/null +++ b/advanced/automated instal/basic-install.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Pi-hole automated install +# Raspberry Pi Ad-blocker +# +# Install with this command (from the Pi): +# +# curl -s "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/automated%20install/basic-install.sh" | bash +# +# Or run the commands below in order + +clear +echo " _____ _ _ _ " +echo " | __ (_) | | | | " +echo " | |__) | __ | |__ ___ | | ___ " +echo " | ___/ | |__| | '_ \ / _ \| |/ _ \ " +echo " | | | | | | | | (_) | | __/ " +echo " |_| |_| |_| |_|\___/|_|\___| " +echo " " +echo " Raspberry Pi Ad-blocker " +echo " " +echo "Set a static IP before running this!" +echo " " +echo " Press Enter when ready " +echo " " +read + +echo "Updating the Pi..." +sudo apt-get update +sudo apt-get -y upgrade + +echo "Installing DNS..." +sudo apt-get -y install dnsmasq +sudo update-rc.d dnsmasq enable + +echo "Installing a Web server" +sudo apt-get -y install lighttpd +sudo chown www-data:www-data /var/www +sudo chmod 775 /var/www +sudo usermod -a -G www-data pi + +echo "Stopping services to modify them..." +sudo service dnsmasq stop +sudo service lighttpd stop + +echo "Backing up original config files and downloading Pi-hole ones..." +sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig +sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig +sudo mv /var/www/index.lighttpd.html /var/www/index.lighttpd.orig +sudo curl -o /etc/dnsmasq.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf" +sudo curl -o /etc/lighttpd/lighttpd.conf "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf" +sudo mkdir /var/www/pihole +sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html" + +echo "Locating the Pi-hole..." +sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh" +sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/chronometer.sh" +sudo chmod 755 /usr/local/bin/gravity.sh +sudo chmod 755 /usr/local/bin/chronometer.sh + +echo "Entering the event horizon..." +sudo /usr/local/bin/gravity.sh + +echo "Restarting..." +sudo shutdown -r now \ No newline at end of file From 655a58494192dddac21326167384b445c2c26c7b Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 13 Jun 2015 22:26:19 -0500 Subject: [PATCH 16/50] Updated README to reflect changes --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0d99acf4..a2c6af7a 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,27 @@ # Raspberry Pi Ad Blocker **A black hole for ads, hence Pi-hole** -![Pi-hole](http://www.hdwallpapersimages.com/wp-content/uploads/2014/03/Black-Hole-Images-540x303.jpg) +![Pi-hole](http://i.imgur.com/wd5ltCU.png) -The Pi-hole is a DNS/Web server that will **block ads for any device**. +The Pi-hole is a DNS/Web server that will **block ads for any device on your network**. ## Coverage Featured on [MakeUseOf](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) and [Lifehacker](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)! ## Automated Install +### Make sure to set a **static** IP address before running this!! On a clean installation of Raspbian, you can run this command to **auto-install the Pi-hole**. Once installed, configure any device to use the Raspberry Pi as your DNS server and the ads will be blocked. ```curl -s "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/automated%20install/basic-install.sh" | bash``` ## Gravity -The [gravity-adv.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity-adv.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 120,000 entries](http://jacobsalmela.com/blocking-ads-from-120000-domains/). +The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/blocking-ads-from-120000-domains/). + +### How It Works +A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)! ## Whitelist and blacklist -You can add a whitelist or blacklist in ```/etc/pihole/``` and the script will apply those files automatically. +You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. ## Other Operating Systems -This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install dnsmasq and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. - -## Optimizations -I am working on some great optimizations to allow the script to run much faster. I also have a bunch of new sources for ad domains but I still need to see if the lists are OK. +This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. \ No newline at end of file From fd2b24f2a01dab7177777658243c9797fde82dc8 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 16 Jun 2015 11:15:15 -0500 Subject: [PATCH 17/50] preparing files for merge and for testing automated install I haven't merged anything before, so hopefully, I won't mess it up too bad! --- README.md | 8 ++--- advanced/{ => Scripts}/chronometer.sh | 9 ++---- advanced/index.html | 1 - advanced/lighttpd.conf | 17 ++++------ .../basic-install.sh | 2 +- block hulu ads/lighttpd.conf | 32 +++++++++++++++++++ block hulu ads/minidlna.conf | 6 ++++ 7 files changed, 53 insertions(+), 22 deletions(-) rename advanced/{ => Scripts}/chronometer.sh (58%) rename {advanced/automated instal => automated instal}/basic-install.sh (95%) create mode 100644 block hulu ads/lighttpd.conf create mode 100644 block hulu ads/minidlna.conf diff --git a/README.md b/README.md index a2c6af7a..9a0a9ed6 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ On a clean installation of Raspbian, you can run this command to **auto-install ```curl -s "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/automated%20install/basic-install.sh" | bash``` ## Gravity -The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/blocking-ads-from-120000-domains/). - -### How It Works -A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)! +The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). ## Whitelist and blacklist You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. +### How It Works +A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)! + ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. \ No newline at end of file diff --git a/advanced/chronometer.sh b/advanced/Scripts/chronometer.sh similarity index 58% rename from advanced/chronometer.sh rename to advanced/Scripts/chronometer.sh index a57038ec..353fc125 100755 --- a/advanced/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -1,6 +1,6 @@ #!/bin/bash # Infinite loop that can be used to display ad domains on a Pi touch screen -# It will continually display ads that are blocked in real time on the screen +# Continually watch the log file and display ad domains that are blocked being blocked # Set the pi user to log in automatically and add run this script from .bashrc clear echo "" @@ -13,10 +13,7 @@ echo " Internet Ads " echo "" echo " http://pi-hole.net" echo "" -echo " Pi-hole IP: $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" -echo "" -echo "Ads blocked will show up once" -echo "you set your DNS server." -echo "" +echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" sleep 7 +# Look for only the entries that contain /etc/hosts, indicating the domain was found to be an advertisement tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}' \ No newline at end of file diff --git a/advanced/index.html b/advanced/index.html index 2049cfe9..6bfc7988 100644 --- a/advanced/index.html +++ b/advanced/index.html @@ -1,5 +1,4 @@ -
\ No newline at end of file diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf index e875897e..1c3ed076 100644 --- a/advanced/lighttpd.conf +++ b/advanced/lighttpd.conf @@ -1,13 +1,10 @@ server.modules = ( "mod_expire", - "mod_access", - "mod_alias", "mod_compress", "mod_redirect", - "mod_auth", "mod_rewrite" ) - + server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" @@ -15,26 +12,26 @@ server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 - - + + index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) - + compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) - + # default listening port for IPv6 falls back to the IPv4 port include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" - + # Set access to 1 day for better query performance when the list gets so large # http://jacobsalmela.com/raspberry-pi-block-ads-adtrap/#comment-2013820434 $HTTP["url"] =~ "^/pihole/" { expire.url = ("" => "access plus 1 days") } - + # Rewrites all URLs to the /var/www/pihole/index.html $HTTP["host"] =~ ".*" { url.rewrite = (".*" => "pihole/index.html") diff --git a/advanced/automated instal/basic-install.sh b/automated instal/basic-install.sh similarity index 95% rename from advanced/automated instal/basic-install.sh rename to automated instal/basic-install.sh index 3eee116c..43f9d663 100755 --- a/advanced/automated instal/basic-install.sh +++ b/automated instal/basic-install.sh @@ -53,7 +53,7 @@ sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacob echo "Locating the Pi-hole..." sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh" -sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/chronometer.sh" +sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/scripts/chronometer.sh" sudo chmod 755 /usr/local/bin/gravity.sh sudo chmod 755 /usr/local/bin/chronometer.sh diff --git a/block hulu ads/lighttpd.conf b/block hulu ads/lighttpd.conf new file mode 100644 index 00000000..b22f599e --- /dev/null +++ b/block hulu ads/lighttpd.conf @@ -0,0 +1,32 @@ +server.modules = ( + "mod_access", + "mod_alias", + "mod_compress", + "mod_redirect", + "mod_rewrite" +) + +server.document-root = "/var/www" +server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) +server.errorlog = "/var/log/lighttpd/error.log" +server.pid-file = "/var/run/lighttpd.pid" +server.username = "www-data" +server.groupname = "www-data" +server.port = 80 + + +index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) +url.access-deny = ( "~", ".inc" ) +static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) + +compress.cache-dir = "/var/cache/lighttpd/compress/" +compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) + +# default listening port for IPv6 falls back to the IPv4 port +include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port +include_shell "/usr/share/lighttpd/create-mime.assign.pl" +include_shell "/usr/share/lighttpd/include-conf-enabled.pl" + +$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com" { + url.redirect = ( ".*" => "http://192.168.1.101:8200/MediaItems/19.mov") +} diff --git a/block hulu ads/minidlna.conf b/block hulu ads/minidlna.conf new file mode 100644 index 00000000..9eccc7b6 --- /dev/null +++ b/block hulu ads/minidlna.conf @@ -0,0 +1,6 @@ +media_dir=V,/var/lib/minidlna/videos/ +port=8200 +friendly_name=pihole +serial=12345678 +model_number=1 +inotify=yes \ No newline at end of file From a2350ba8809fe842ed28a2429286726c3aa347b8 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 16 Jun 2015 17:23:48 -0500 Subject: [PATCH 18/50] misspelled "install" --- {automated instal => automated install}/basic-install.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {automated instal => automated install}/basic-install.sh (100%) diff --git a/automated instal/basic-install.sh b/automated install/basic-install.sh similarity index 100% rename from automated instal/basic-install.sh rename to automated install/basic-install.sh From 67aba8c49684ef3d643bf893da49245136f59d02 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Fri, 19 Jun 2015 13:31:51 -0700 Subject: [PATCH 19/50] If exists, import a config file to allow for overriding script variables. --- gravity.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 36ab544f..2f8993e4 100755 --- a/gravity.sh +++ b/gravity.sh @@ -16,8 +16,13 @@ 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 origin=/etc/pihole piholeDir=/etc/pihole +if [ -f $piholeDir/pihole.conf ]; then + . $piholeDir/pihole.conf +fi + justDomainsExtension=domains matter=pihole.0.matter.txt andLight=pihole.1.andLight.txt @@ -25,7 +30,6 @@ supernova=pihole.2.supernova.txt eventHorizon=pihole.3.eventHorizon.txt accretionDisc=pihole.4.accretionDisc.txt eyeOfTheNeedle=pihole.5.wormhole.txt -adList=/etc/hosts blacklist=$piholeDir/blacklist.txt latentBlacklist=$origin/latentBlacklist.txt whitelist=$piholeDir/whitelist.txt @@ -120,4 +124,4 @@ if [[ -f $whitelist ]];then else cat $origin/$matter > $origin/$andLight gravity_advanced -fi \ No newline at end of file +fi From b7e2c8053b5b8935738f0b6cab17fd67242c27f3 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Fri, 19 Jun 2015 14:10:48 -0700 Subject: [PATCH 20/50] Add local-ttl to dnsmasq config so that queries are cached by the requesting device. --- advanced/dnsmasq.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf index 4340f83a..d310b41b 100644 --- a/advanced/dnsmasq.conf +++ b/advanced/dnsmasq.conf @@ -6,4 +6,5 @@ server=8.8.4.4 interface=eth0 listen-address=127.0.0.1 cache-size=10000 -log-queries \ No newline at end of file +log-queries +local-ttl=300 From e9324f8316e3d3cfd6f67eceae846e9c82550f72 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Fri, 19 Jun 2015 17:54:12 -0700 Subject: [PATCH 21/50] Use double brackets for the test. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 2f8993e4..11b4a217 100755 --- a/gravity.sh +++ b/gravity.sh @@ -19,7 +19,7 @@ sources=('https://adaway.org/hosts.txt' adList=/etc/hosts origin=/etc/pihole piholeDir=/etc/pihole -if [ -f $piholeDir/pihole.conf ]; then +if [[ -f $piholeDir/pihole.conf ]]; then . $piholeDir/pihole.conf fi From 9d700d75b67fb16f98cf14df4049730120de99c6 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sun, 21 Jun 2015 07:48:14 -0500 Subject: [PATCH 22/50] Update to reflect #20 You can add your own config file to permanently set variables used in the gravity script. If the file exists, gravity.sh will detect it and apply your custom variables. This is useful so when there is an update to the gravity script, you do not need to adjust the variables every time. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 9a0a9ed6..e7f2f9ba 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,16 @@ On a clean installation of Raspbian, you can run this command to **auto-install ## Gravity The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). +## Custom Config File +If you want to use your own variables for the gravity script (i.e. storing the files in a different location) and don't want to have to change them every time there is an update to the script, create a file called `/etc/pihole/pihole.conf`. In it, you should add your own variables in a similar fashion as shown below: + +``` +origin=/var/run/pihole +adList=/etc/dnsmasq.d/adList +``` + +See [this PR](https://github.com/jacobsalmela/pi-hole/pull/20) for more details. + ## Whitelist and blacklist You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. From 6953c02402919e05460e080664ee5c76d284b110 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sun, 21 Jun 2015 07:50:02 -0500 Subject: [PATCH 23/50] detect original pihole and backup Detects if the Pi had an original Pi-hole by looking for adList.conf. If it exists, it backs up all the files to /etc/pihole/original. Then, the script continues as normal and creates the new files. This helps ensure that /etc/hosts and /etc/dnsmasq.d/adList.conf are not being used simultaneously. --- automated install/basic-install.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43f9d663..87f48ce6 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -24,6 +24,19 @@ echo " Press Enter when ready " echo " " read +if [[ -f /etc/dnsmasq.d/adList.conf ]];then + echo "Original Pi-hole detected. Initiating sub space transport..." + sudo mkdir -p /etc/pihole/original/ + mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") + mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") + mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") + mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") + mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") + mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") +else + : +fi + echo "Updating the Pi..." sudo apt-get update sudo apt-get -y upgrade From 66bb0e7bb3173d462ddcb9193f408e8123568a9b Mon Sep 17 00:00:00 2001 From: rmceoin Date: Mon, 22 Jun 2015 13:03:15 -0700 Subject: [PATCH 24/50] Strip carriage returns on matter so that whitelists work correctly. Lines that had \r would not match. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 11b4a217..834a60c1 100755 --- a/gravity.sh +++ b/gravity.sh @@ -77,7 +77,7 @@ done # Find all files with the .domains extension and compile them into one file echo "** Aggregating list of domains..." -find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; > $origin/$matter +find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\r' > $origin/$matter # Append blacklist entries if they exist if [[ -f $blacklist ]];then From 552f980430aa89ece656d7c3fda3e355410e65e6 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Mon, 22 Jun 2015 13:33:02 -0700 Subject: [PATCH 25/50] blacklist was being concatenated with wrong matter --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 834a60c1..4734991a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -83,7 +83,7 @@ find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\ if [[ -f $blacklist ]];then numberOf=$(cat $blacklist | wc -l | sed 's/^[ \t]*//') echo "** Blacklisting $numberOf domain(s)..." - cat $blacklist >> /tmp/matter.txt + cat $blacklist >> $origin/$matter else : fi From 5c4bfb84b0fed95b92f5311ace01dc2dfe23a519 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Mon, 13 Jul 2015 06:59:22 -0500 Subject: [PATCH 26/50] uses a variable for hostname instead of raspberrypi Some people use a hostname other than raspberrypi, so their hostname did not resolve to 127.0.0.1. I replaced that hardcoded value with a variable so that does not happen. I also added a few comments and minor formatting adjustments,. --- gravity.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gravity.sh b/gravity.sh index 4734991a..fd0e7cbe 100755 --- a/gravity.sh +++ b/gravity.sh @@ -19,10 +19,9 @@ sources=('https://adaway.org/hosts.txt' adList=/etc/hosts origin=/etc/pihole piholeDir=/etc/pihole -if [[ -f $piholeDir/pihole.conf ]]; then +if [[ -f $piholeDir/pihole.conf ]];then . $piholeDir/pihole.conf fi - justDomainsExtension=domains matter=pihole.0.matter.txt andLight=pihole.1.andLight.txt @@ -55,7 +54,7 @@ do saveLocation=$origin/"list"."$i"."$domain" # Use a case statement to download lists that need special cURL commands to complete properly - case "$domain" in + case "$domain" in "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; @@ -75,7 +74,7 @@ do fi done -# Find all files with the .domains extension and compile them into one file +# Find all files with the .domains extension and compile them into one file and remove CRs echo "** Aggregating list of domains..." find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\r' > $origin/$matter @@ -106,7 +105,7 @@ function gravity_advanced() 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 + echo "127.0.0.1 $(hostname)" | 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 } From 37e926ce843b13764c5dc87e7f90337b83dad858 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Mon, 13 Jul 2015 09:28:45 -0700 Subject: [PATCH 27/50] Parses host only file formats now. Previously only handled hosts file format. Specifically, it can now handle the following list: 'http://mirror1.malwaredomains.com/files/justdomains' --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 4734991a..635ddb95 100755 --- a/gravity.sh +++ b/gravity.sh @@ -69,7 +69,7 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") print $2}' > $saveLocation."$justDomainsExtension" + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation."$justDomainsExtension" else echo "Skipping $domain list because it does not have any new entries..." fi From 8f961c1aaa5eb370af6d5a7dd1d0f4dc66d35b62 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Fri, 17 Jul 2015 13:05:38 -0500 Subject: [PATCH 28/50] resolves #22 This lets dnsmasq re-read the hosts file without disturbing the daemon. So any new entries can be used as soon as gravity.sh is finished running --- gravity.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 5ecd19db..919ebac9 100755 --- a/gravity.sh +++ b/gravity.sh @@ -106,8 +106,9 @@ function gravity_advanced() 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 so dnsmasq can use it + # Copy the file over as /etc/hosts so dnsmasq can use it sudo cp $origin/$accretionDisc $adList + kill -HUP $(pidof dnsmasq) } # Whitelist (if applicable) then remove duplicates and format for dnsmasq From 563db80b6d6867b922783e13dda57198e5d29304 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Fri, 17 Jul 2015 20:49:03 -0500 Subject: [PATCH 29/50] resolves #25 Will not count blank lines if they happen to exist. --- gravity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 919ebac9..f4ef9d9c 100755 --- a/gravity.sh +++ b/gravity.sh @@ -80,7 +80,7 @@ find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\ # Append blacklist entries if they exist if [[ -f $blacklist ]];then - numberOf=$(cat $blacklist | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) echo "** Blacklisting $numberOf domain(s)..." cat $blacklist >> $origin/$matter else @@ -90,13 +90,13 @@ fi function gravity_advanced() ########################### { - numberOf=$(cat $origin/$andLight | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $origin/$andLight | sed '/^\s*$/d' | wc -l) echo "** $numberOf domains being pulled in by gravity..." # Remove carriage returns and preceding whitespace cat $origin/$andLight | sed $'s/\r$//' | sed '/^\s*$/d' > $origin/$supernova # Sort and remove duplicates cat $origin/$supernova | sort | uniq > $origin/$eventHorizon - numberOf=$(cat $origin/$eventHorizon | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $origin/$eventHorizon | sed '/^\s*$/d' | wc -l) echo "** $numberOf unique domains trapped in the event horizon." # Format domain list as "192.168.x.x domain.com" echo "** Formatting domains into a HOSTS file..." @@ -114,7 +114,7 @@ function gravity_advanced() # Whitelist (if applicable) then remove duplicates and format for dnsmasq if [[ -f $whitelist ]];then # Remove whitelist entries - numberOf=$(cat $whitelist | wc -l | sed 's/^[ \t]*//') + numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) echo "** Whitelisting $numberOf domain(s)..." # Append a "$" to the end of each line so it can be parsed out with grep -w echo -n "^$" > $latentWhitelist From 9a2862de62578b22e9c7292b995ba798b5cb27aa Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 18 Jul 2015 09:39:18 -0500 Subject: [PATCH 30/50] closes #24 whitelist without running gravity.sh It's pretty slow because /etc/hosts is so large, but it works. You can add any number of domains as arguments and it will search for and remove each one. Maybe someone smarter knows how to make it faster... --- advanced/Scripts/whitelist.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 advanced/Scripts/whitelist.sh diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh new file mode 100755 index 00000000..947e798c --- /dev/null +++ b/advanced/Scripts/whitelist.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# For each argument passed to this script +for var in "$@" +do + echo "Whitelisting $var..." + # Use sed to search for the domain in /etc/hosts and remove it using an in-place edit + sed -i "/$var/d" /etc/hosts + # Also add the domain to the whitelist.txt in /etc/pihole + echo "$var" >> /etc/pihole/whitelist.txt +done +echo "** $# domain(s) whitelisted." +# Force dnsmasq to reload /etc/hosts +kill -HUP $(pidof dnsmasq) \ No newline at end of file From 11614263b8579943c39c595daa86496d4e8af1c5 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 25 Jul 2015 13:05:13 -0500 Subject: [PATCH 31/50] better version of LCD display stats --- advanced/Scripts/chronometer.sh | 45 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 353fc125..07cbbc00 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -1,19 +1,28 @@ #!/bin/bash -# Infinite loop that can be used to display ad domains on a Pi touch screen -# Continually watch the log file and display ad domains that are blocked being blocked -# Set the pi user to log in automatically and add run this script from .bashrc -clear -echo "" -echo " +-+-+-+-+-+-+-+ " -echo " Pi-hole " -echo " +-+-+-+-+-+-+-+ " -echo "" -echo " A black hole for" -echo " Internet Ads " -echo "" -echo " http://pi-hole.net" -echo "" -echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" -sleep 7 -# Look for only the entries that contain /etc/hosts, indicating the domain was found to be an advertisement -tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}' \ No newline at end of file +# Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen +# Set the pi user to log in automatically and run this script from /etc/profile +for (( ; ; )) +do + clear + # Displays a colorful Pi-hole logo + toilet -f small -F gay Pi-hole + echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" + echo "" + uptime | cut -d' ' -f11- + echo "-------------------------------" + # Uncomment to continually read the log file and display the current domain being blocked + #tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}' + + today=$(date "+%b %e") + todaysQueryCount=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ {print $7}' | wc -l) + todaysQueryCountV4=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l) + todaysQueryCountV6=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l) + todaysAdsEliminated=$(cat /var/log/daemon.log | grep "$today" | awk '/\/etc\/hosts/ {print $7}' | wc -l) + dividend=$(echo "$todaysAdsEliminated/$todaysQueryCount" | bc -l) + fp=$(echo "$dividend*100" | bc -l) + percentAds=$(echo ${fp:0:4}) + + echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6" + echo "Pi-holed: $todaysAdsEliminated ($percentAds%)" + sleep 5 +done \ No newline at end of file From 1ee2d087038bdfa825398532a6941b3ee6fe780b Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sun, 26 Jul 2015 18:36:01 -0500 Subject: [PATCH 32/50] donate buttons and link to Web interface --- README.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e7f2f9ba..3e5e9253 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,28 @@ The Pi-hole is a DNS/Web server that will **block ads for any device on your net Featured on [MakeUseOf](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) and [Lifehacker](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)! ## Automated Install -### Make sure to set a **static** IP address before running this!! -On a clean installation of Raspbian, you can run this command to **auto-install the Pi-hole**. Once installed, configure any device to use the Raspberry Pi as your DNS server and the ads will be blocked. + +1. Install Raspbian +2. Set a **static** IP address +3. Run the command below ```curl -s "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/automated%20install/basic-install.sh" | bash``` +Once installed, **configure any device to use the Raspberry Pi as its DNS server and the ads will be blocked**. You can also configure your router's DHCP options to assign the Pi as clients DNS server so they do not need to do it manually. + +A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). + +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") + ## Gravity The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). +## Whitelist and blacklist +You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. + +## Web Interface +I am also working on a [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) so you can view stats and change settings. + ## Custom Config File If you want to use your own variables for the gravity script (i.e. storing the files in a different location) and don't want to have to change them every time there is an update to the script, create a file called `/etc/pihole/pihole.conf`. In it, you should add your own variables in a similar fashion as shown below: @@ -27,11 +41,10 @@ adList=/etc/dnsmasq.d/adList See [this PR](https://github.com/jacobsalmela/pi-hole/pull/20) for more details. -## Whitelist and blacklist -You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. - ### How It Works A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)! ## Other Operating Systems -This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. \ No newline at end of file +This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. + +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") \ No newline at end of file From e20f948e491b47ccfe7beaa29ddda0ad1c855648 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 28 Jul 2015 19:34:36 +0100 Subject: [PATCH 33/50] Log PiHole dns stats to /var/log/pihole Log PiHole dns stats to /var/log/pihole Removes the requirement for rsyslog and reading the shared logfile /var/log/daemon.log --- advanced/dnsmasq.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf index d310b41b..73e926d8 100644 --- a/advanced/dnsmasq.conf +++ b/advanced/dnsmasq.conf @@ -7,4 +7,5 @@ interface=eth0 listen-address=127.0.0.1 cache-size=10000 log-queries +log-facility=/var/log/pihole local-ttl=300 From 9230be63d5a28688d6bc2f1517cf910e0dc9735c Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Jul 2015 12:20:39 +0100 Subject: [PATCH 34/50] .log extension --- advanced/dnsmasq.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/dnsmasq.conf b/advanced/dnsmasq.conf index 73e926d8..d8d2b261 100644 --- a/advanced/dnsmasq.conf +++ b/advanced/dnsmasq.conf @@ -7,5 +7,5 @@ interface=eth0 listen-address=127.0.0.1 cache-size=10000 log-queries -log-facility=/var/log/pihole +log-facility=/var/log/pihole.log local-ttl=300 From 9627b27f1586707e514b23929d69627ee32034b9 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 29 Jul 2015 12:22:28 +0100 Subject: [PATCH 35/50] pihole logfile changes https://github.com/jacobsalmela/pi-hole/pull/27 --- advanced/Scripts/chronometer.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 07cbbc00..74d08326 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -11,13 +11,13 @@ do uptime | cut -d' ' -f11- echo "-------------------------------" # Uncomment to continually read the log file and display the current domain being blocked - #tail -f /var/log/daemon.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/hosts") print $7; else;}' today=$(date "+%b %e") - todaysQueryCount=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ {print $7}' | wc -l) - todaysQueryCountV4=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l) - todaysQueryCountV6=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l) - todaysAdsEliminated=$(cat /var/log/daemon.log | grep "$today" | awk '/\/etc\/hosts/ {print $7}' | wc -l) + todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l) + todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l) + todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l) + todaysAdsEliminated=$(cat /var/log/pihole.log | grep "$today" | awk '/\/etc\/hosts/ {print $7}' | wc -l) dividend=$(echo "$todaysAdsEliminated/$todaysQueryCount" | bc -l) fp=$(echo "$dividend*100" | bc -l) percentAds=$(echo ${fp:0:4}) @@ -25,4 +25,4 @@ do echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6" echo "Pi-holed: $todaysAdsEliminated ($percentAds%)" sleep 5 -done \ No newline at end of file +done From 9d99a4ef362401579ee5599fac32716556392fc6 Mon Sep 17 00:00:00 2001 From: Fourdee Date: Thu, 30 Jul 2015 17:24:24 +0100 Subject: [PATCH 36/50] 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 74d08326..f595b09b 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 d8d2b261..25b2138e 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 f4ef9d9c..f1e70a63 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) } From 024395b73be05415ddf23bf227baa586099c10e8 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 30 Jul 2015 18:01:10 +0100 Subject: [PATCH 37/50] Update chronometer.sh Missed a change todaysAdsEliminated to /\/etc\/pihole\/gravity.list/ --- advanced/Scripts/chronometer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index f595b09b..816722da 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -17,7 +17,7 @@ do todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l) todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l) todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l) - todaysAdsEliminated=$(cat /var/log/pihole.log | grep "$today" | awk '/\/etc\/hosts/ {print $7}' | wc -l) + todaysAdsEliminated=$(cat /var/log/pihole.log | grep "$today" | awk '/\/etc\/pihole\/gravity.list/ {print $7}' | wc -l) dividend=$(echo "$todaysAdsEliminated/$todaysQueryCount" | bc -l) fp=$(echo "$dividend*100" | bc -l) percentAds=$(echo ${fp:0:4}) From 52ef76d71700f33717e93cf34e7ef1014f833b5c Mon Sep 17 00:00:00 2001 From: Fourdee Date: Thu, 30 Jul 2015 18:10:26 +0100 Subject: [PATCH 38/50] missed a few more /etc/host changes --- advanced/Scripts/chronometer.sh | 2 +- advanced/Scripts/whitelist.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 816722da..73219760 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/pihole/gravity.list") print $7; else;}' + #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {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/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 947e798c..aed6bd0f 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -3,11 +3,11 @@ for var in "$@" do echo "Whitelisting $var..." - # Use sed to search for the domain in /etc/hosts and remove it using an in-place edit - sed -i "/$var/d" /etc/hosts + # Use sed to search for the domain in /etc/pihole/gravity.list and remove it using an in-place edit + sed -i "/$var/d" /etc/pihole/gravity.list # Also add the domain to the whitelist.txt in /etc/pihole echo "$var" >> /etc/pihole/whitelist.txt done echo "** $# domain(s) whitelisted." -# Force dnsmasq to reload /etc/hosts +# Force dnsmasq to reload /etc/pihole/gravity.list kill -HUP $(pidof dnsmasq) \ No newline at end of file From 46bda342a917573d218746a2b5f9a639b76bbb1a Mon Sep 17 00:00:00 2001 From: Mathias Date: Mon, 10 Aug 2015 22:50:06 +0200 Subject: [PATCH 39/50] Fix URL of chronometer.sh Github URLs seems to be case-sensitive. Now the chronometer.sh souldn't contain "Not Found" anymore. ;) --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 87f48ce6..c745c502 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -66,7 +66,7 @@ sudo curl -o /var/www/pihole/index.html "https://raw.githubusercontent.com/jacob echo "Locating the Pi-hole..." sudo curl -o /usr/local/bin/gravity.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh" -sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/scripts/chronometer.sh" +sudo curl -o /usr/local/bin/chronometer.sh "https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh" sudo chmod 755 /usr/local/bin/gravity.sh sudo chmod 755 /usr/local/bin/chronometer.sh @@ -74,4 +74,4 @@ echo "Entering the event horizon..." sudo /usr/local/bin/gravity.sh echo "Restarting..." -sudo shutdown -r now \ No newline at end of file +sudo shutdown -r now From 159b29b80b801ae0ab58bdd189a84858afd87ac5 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 15:56:32 -0700 Subject: [PATCH 40/50] Replace spaces with tabs to make indentation consistent within the file. --- gravity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index f1e70a63..e2126693 100755 --- a/gravity.sh +++ b/gravity.sh @@ -80,11 +80,11 @@ find $origin/ -type f -name "*.$justDomainsExtension" -exec cat {} \; | tr -d '\ # Append blacklist entries if they exist if [[ -f $blacklist ]];then - numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) - echo "** Blacklisting $numberOf domain(s)..." - cat $blacklist >> $origin/$matter + numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) + echo "** Blacklisting $numberOf domain(s)..." + cat $blacklist >> $origin/$matter else - : + : fi function gravity_advanced() From 0ec6eab683c02254ca32331c8aeb532e54097ee7 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 16:04:54 -0700 Subject: [PATCH 41/50] Appending ".$justDomainsExtension" to $saveLocation variable. Every use of $saveLocation was adding this and making lines longer. --- gravity.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gravity.sh b/gravity.sh index e2126693..058e72e7 100755 --- a/gravity.sh +++ b/gravity.sh @@ -51,15 +51,15 @@ do domain=$(echo "${sources[$i]}" | cut -d'/' -f3) # Save the file as list.#.domain - saveLocation=$origin/"list"."$i"."$domain" + saveLocation=$origin/list.$i.$domain.$justDomainsExtension # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in - "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation "${sources[$i]}");; - "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation."$justDomainsExtension" "${sources[$i]}");; + "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation "${sources[$i]}");; - *) data=$(curl -s -z $saveLocation."$justDomainsExtension" -A "Mozilla/10.0" "${sources[$i]}");; + *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" "${sources[$i]}");; esac if [[ -n "$data" ]];then @@ -68,7 +68,7 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation."$justDomainsExtension" + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation else echo "Skipping $domain list because it does not have any new entries..." fi From d6d192cb0a1a2adc9f2be31388d4e47c2f196728 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 16:22:07 -0700 Subject: [PATCH 42/50] Use `url` variable to store `${sources[$i]}` value to improve readability. I also wanted to replace the for loop iterating over indices with something like: `for url in $sources[@]}` It made the use of `$i` in the save location more annoying though. --- gravity.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 058e72e7..934581e8 100755 --- a/gravity.sh +++ b/gravity.sh @@ -47,19 +47,20 @@ fi # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do + url=${sources[$i]} # Get just the domain from the URL - domain=$(echo "${sources[$i]}" | cut -d'/' -f3) + domain=$(echo "$url" | cut -d'/' -f3) # Save the file as list.#.domain saveLocation=$origin/list.$i.$domain.$justDomainsExtension # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in - "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation "${sources[$i]}");; + "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation $url);; - "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation "${sources[$i]}");; + "pgl.yoyo.org") data=$(curl -s -d mimetype=plaintext -d hostformat=hosts -z $saveLocation $url);; - *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" "${sources[$i]}");; + *) data=$(curl -s -z $saveLocation -A "Mozilla/10.0" $url);; esac if [[ -n "$data" ]];then From 1f29d01694a293685feacd7abb4a2639e5cbcc6f Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:05:19 -0700 Subject: [PATCH 43/50] Remove leading and trailing whitespace and `.` characters and duplicate `.` characters as each list is stored. Should fix #32. --- gravity.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 934581e8..3dc9b8df 100755 --- a/gravity.sh +++ b/gravity.sh @@ -69,7 +69,8 @@ do # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' > $saveLocation + echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ + sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation else echo "Skipping $domain list because it does not have any new entries..." fi From bb7db1121465ede2909e3ee79244ad884a3cb372 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:33:30 -0700 Subject: [PATCH 44/50] Changing printouts when updating sources to tell what is going on when manually running gravity.sh This will print "Getting $domain list... " for each domain, followed by either "Done" if data was received and validated, or "Skipping list because it does not have any new entries" if no updates were needed. --- gravity.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 3dc9b8df..c6cd6b29 100755 --- a/gravity.sh +++ b/gravity.sh @@ -54,6 +54,7 @@ do # Save the file as list.#.domain saveLocation=$origin/list.$i.$domain.$justDomainsExtension + echo -n "Getting $domain list... " # Use a case statement to download lists that need special cURL commands to complete properly case "$domain" in "adblock.mahakala.is") data=$(curl -s -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' -e http://forum.xda-developers.com/ -z $saveLocation $url);; @@ -64,15 +65,15 @@ do esac if [[ -n "$data" ]];then - echo "Getting $domain list..." # Remove comments and print only the domain name # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation + echo "Done." else - echo "Skipping $domain list because it does not have any new entries..." + echo "Skipping list because it does not have any new entries." fi done From e464c04490c4f3e336a26af09a9794ed1b9bd70a Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 17:47:22 -0700 Subject: [PATCH 45/50] Ignore domains in ad lists that do not contain `.` characters. This will skip entries such as `localhost`, `android`, `debian` and empty lines as listed in #35. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c6cd6b29..40f87ccf 100755 --- a/gravity.sh +++ b/gravity.sh @@ -70,7 +70,7 @@ do # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo "$data" | awk 'NF {if ($1 !~ "#") { if (NF>1) {print $2} else {print $1}}}' | \ - sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' > $saveLocation + sed -e 's/^[. \t]*//' -e 's/\.\.\+/./g' -e 's/[. \t]*$//' | grep "\." > $saveLocation echo "Done." else echo "Skipping list because it does not have any new entries." From a26377d2298fabb88aedd331b0fcabfac8066ef6 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 21:44:41 -0700 Subject: [PATCH 46/50] Append ad list sources to latentWhitelist.txt to prevent them from being filtered. Additional fixes for #35. This will prevent our own sources from being filtered out by competing source lists. --- gravity.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gravity.sh b/gravity.sh index 40f87ccf..8a6f22da 100755 --- a/gravity.sh +++ b/gravity.sh @@ -113,13 +113,21 @@ function gravity_advanced() if [[ -f $whitelist ]];then # Remove whitelist entries numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) - echo "** Whitelisting $numberOf domain(s)..." + plural=; [[ "$numberOf" != "1" ]] && plural=s + echo "** Whitelisting $numberOf domain${plural}..." # Append a "$" to the end of each line so it can be parsed out with grep -w - echo -n "^$" > $latentWhitelist awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist - cat $origin/$matter | grep -vwf $latentWhitelist > $origin/$andLight - gravity_advanced else - cat $origin/$matter > $origin/$andLight - gravity_advanced + rm $latentWhitelist fi + +# Prevent our sources from being pulled into the hole +plural=; [[ "${#sources[@]}" != "1" ]] && plural=s +echo "** Whitelisting ${#sources[@]} ad list source${plural}..." +for url in ${sources[@]} +do + echo "$url" | awk -F '/' '{print $3"$"}' >> $latentWhitelist +done +grep -vwf $latentWhitelist $origin/$matter > $origin/$andLight + +gravity_advanced From 98c94912e185babc6ba6e949c5fa1f30b5a2c1d2 Mon Sep 17 00:00:00 2001 From: korhadris Date: Sat, 22 Aug 2015 23:37:01 -0700 Subject: [PATCH 47/50] Replace use of grep -w with grep -x. Prepend "^" to start of latentWhitelist.txt lines. The -x switch requires a full line match of the regexp, where as -w will try to find the match somewhere in the line, looking for work breaks. Combined with turning the whitelist lines into full regexps, this results in significantly faster parsing. Having "^" prepended to the lines also keeps false whitelisting from occuring, such as the following example: If whitelist.txt contains "google.com" it would whitelist many other sites that end in "google.com" as long as there is a non-word character preceeding the google (such as "-", or "."). --- gravity.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 8a6f22da..9bad747d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -115,8 +115,10 @@ if [[ -f $whitelist ]];then numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo "** Whitelisting $numberOf domain${plural}..." - # Append a "$" to the end of each line so it can be parsed out with grep -w - awk -F '[# \t]' 'NF>0&&$1!="" {print $1"$"}' $whitelist > $latentWhitelist + # Append a "$" to the end, prepend a "^" to the beginning, and + # replace "." with "\." of each line to turn each entry into a + # regexp so it can be parsed out with grep -x + awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist else rm $latentWhitelist fi @@ -126,8 +128,9 @@ plural=; [[ "${#sources[@]}" != "1" ]] && plural=s echo "** Whitelisting ${#sources[@]} ad list source${plural}..." for url in ${sources[@]} do - echo "$url" | awk -F '/' '{print $3"$"}' >> $latentWhitelist + echo "$url" | awk -F '/' '{print "^"$3"$"}' | sed 's/\./\\./g' >> $latentWhitelist done -grep -vwf $latentWhitelist $origin/$matter > $origin/$andLight + +grep -vxf $latentWhitelist $origin/$matter > $origin/$andLight gravity_advanced From d68c262b967e0d6003cbec34bf56cd8c2230140e Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Mon, 24 Aug 2015 16:30:00 -0500 Subject: [PATCH 48/50] swap file to eliminate memory allocation error --- advanced/dphys-swapfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 advanced/dphys-swapfile diff --git a/advanced/dphys-swapfile b/advanced/dphys-swapfile new file mode 100644 index 00000000..229f00e6 --- /dev/null +++ b/advanced/dphys-swapfile @@ -0,0 +1 @@ +CONF_SWAPSIZE=500 From fa77b7b69da4aaea1f349a015ceeba92514cefac Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 25 Aug 2015 18:01:54 -0500 Subject: [PATCH 49/50] increase swap to fix #37 memory error This will increase the swap file to 500MB before downloading the lists. Most of the issue comes from the mahakala list, which is so large. If no swap file is found, one is created. --- gravity.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gravity.sh b/gravity.sh index f1e70a63..71b194dd 100755 --- a/gravity.sh +++ b/gravity.sh @@ -44,6 +44,31 @@ else sudo mkdir $piholeDir fi +# Add additional swap to prevent the "Error fork: unable to allocate memory" message: https://github.com/jacobsalmela/pi-hole/issues/37 +function createSwapFile() +######################### + { + echo "** Creating more swap space to accomodate large solar masses..." + sudo dphys-swapfile swapoff + sudo curl -s -o /etc/dphys-swapfile https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dphys-swapfile + sudo dphys-swapfile setup + sudo dphys-swapfile swapon + } + +if [[ -f /etc/dphys-swapfile ]];then + swapSize=$(cat /etc/dphys-swapfile | grep -m1 CONF_SWAPSIZE | cut -d'=' -f2) + if [[ $swapSize != 500 ]];then + mv /etc/dphys-swapfile /etc/dphys-swapfile.orig + echo "** Current swap size is $swapSize" + createSwapFile + else + : + fi +else + echo "** No swap file found. Creating one..." + createSwapFile +fi + # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do From 23713d82a0b96874811e23fc3e7f7bb01409969b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 6 Sep 2015 10:16:11 -0500 Subject: [PATCH 50/50] 1.6 million instead of 900,000 Updating to reflect the latest amount of domains the Pi-hole blocks. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e5e9253..be0d4369 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A more detailed explanation of the installation can be found [here](http://jacob [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") ## Gravity -The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 900,000 entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). +The [gravity.sh](https://github.com/jacobsalmela/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). ## Whitelist and blacklist You can add a `whitelist.txt` or `blacklist.txt` in `/etc/pihole/` and the script will apply those files automatically. @@ -47,4 +47,4 @@ A technical and detailed description can be found [here](http://jacobsalmela.com ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. -[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") \ No newline at end of file +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")