From 5f3cb2e569479d4f6d1d716311f1c221d60cd747 Mon Sep 17 00:00:00 2001 From: Mospaeda Date: Thu, 19 Mar 2015 22:59:55 +0100 Subject: [PATCH 01/25] Update gravity-adv.sh --- gravity-adv.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index 5de6c4d1..77646ae5 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -7,6 +7,10 @@ piholeIP="127.0.0.1" # Config file to hold URL rules eventHorizion="/etc/dnsmasq.d/adList.conf" + + + + whitelist=/etc/pihole/whitelist.txt # Create the pihole resource directory if it doesn't exist. Future files will be stored here @@ -54,4 +58,4 @@ echo "$numberOfAdsBlocked ad domains blocked." sudo mv /tmp/andLight.txt $eventHorizion # Restart DNS -sudo service dnsmasq restart \ No newline at end of file +sudo service dnsmasq restart From 185969b137119f8c01e54bc91bc3eacbb5b46db9 Mon Sep 17 00:00:00 2001 From: Mospaeda Date: Thu, 19 Mar 2015 23:09:36 +0100 Subject: [PATCH 02/25] Update gravity-adv.sh Add a local blacklist file --- gravity-adv.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index 77646ae5..0df27ef8 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -7,10 +7,7 @@ piholeIP="127.0.0.1" # 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 @@ -38,6 +35,14 @@ curl -s http://someonewhocares.org/hosts/hosts | grep -v "#" | sed '/^$/d' | sed 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 /etc/pihole/blacklist.txt >> /tmp/matter.txt +else + echo "No local blacklist.txt file available on /etc/pihole directory" +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 From 0ae816835149b8719f2d6653895d25022ee32c74 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 20 Mar 2015 12:50:49 -0500 Subject: [PATCH 03/25] Giving the README some much needed love --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0b98d116..5c9b6b17 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,23 @@ -pi-hole -======= +# Raspberry Pi Ad Blocker +**A black hole for ads, hence Pi-hole** -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) + +The Pi-hole is a DNS/Web server that will **block ads for any device**. + +## Automated Install +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/). + +## Whitelist and blacklist +You can add a whitelist or blacklist 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. From 7809ee386edeaca7976ca6f57684ac33426166e6 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Fri, 20 Mar 2015 23:37:04 +0100 Subject: [PATCH 04/25] Update gravity-adv.sh --- gravity-adv.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index 0df27ef8..2b9431bf 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -38,9 +38,9 @@ curl -A 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' - # 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 /etc/pihole/blacklist.txt >> /tmp/matter.txt + cat $blacklist >> /tmp/matter.txt else - echo "No local blacklist.txt file available on /etc/pihole directory" + : fi # Sort the aggregated results and remove any duplicates From d586ba312611daa440d1f663d123e708716682a9 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Sat, 21 Mar 2015 00:00:09 +0100 Subject: [PATCH 05/25] Automatic IP detection with all locale --- gravity-adv.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gravity-adv.sh b/gravity-adv.sh index 2b9431bf..e89e1e4f 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -4,6 +4,11 @@ piholeIP="127.0.0.1" # Optionally, uncomment to automatically detect the address. Thanks Gregg #piholeIP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}') +# Below code allows to automatically detect the address with all locale +langsys=$LANG +LANG=en_US.utf8 +piholeIP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}') +LANG=$langsys # Config file to hold URL rules eventHorizion="/etc/dnsmasq.d/adList.conf" From 5d37b597682a8f830acd1bc82c026182bbe7896b Mon Sep 17 00:00:00 2001 From: mospaeda Date: Mon, 23 Mar 2015 19:43:13 +0100 Subject: [PATCH 06/25] Blacklist and automatic detection of IP address detection is valid for all languages --- gravity-adv.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index e89e1e4f..41fbf7ad 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -2,13 +2,8 @@ # 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 address. Thanks Gregg -#piholeIP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}') -# Below code allows to automatically detect the address with all locale -langsys=$LANG -LANG=en_US.utf8 -piholeIP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}') -LANG=$langsys +# Optionally, uncomment to automatically detect the local IP address. +# piholeIP=$(hostname -I) # Config file to hold URL rules eventHorizion="/etc/dnsmasq.d/adList.conf" From a11fe15d1ba822ec951cdf62fcfe7e5dd4571b32 Mon Sep 17 00:00:00 2001 From: mospaeda Date: Mon, 23 Mar 2015 19:47:35 +0100 Subject: [PATCH 07/25] Automatic detection via hostname command --- gravity-adv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity-adv.sh b/gravity-adv.sh index 41fbf7ad..4b62817e 100755 --- a/gravity-adv.sh +++ b/gravity-adv.sh @@ -3,7 +3,7 @@ # Address to send ads to (the RPi) piholeIP="127.0.0.1" # Optionally, uncomment to automatically detect the local IP address. -# piholeIP=$(hostname -I) +#piholeIP=$(hostname -I) # Config file to hold URL rules eventHorizion="/etc/dnsmasq.d/adList.conf" From 33692df4a953d3e1bd105d9440127e0973f2ee6b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 27 Mar 2015 19:20:39 -0500 Subject: [PATCH 08/25] featured on tech blogs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5c9b6b17..0d99acf4 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ The Pi-hole is a DNS/Web server that will **block ads for any device**. +## 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 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. From 56c776af220b26e37d30bb756dd239846b5a93e2 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 19 May 2015 13:31:37 -0500 Subject: [PATCH 09/25] 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 | 130 ++++++++++++++++++++++++----- index.html | 6 -- lighttpd.conf | 48 ----------- pihole.png | Bin 68 -> 0 bytes resolv.conf | 3 - 19 files changed, 109 insertions(+), 434 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 - -# 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 +# Create the pihole resource directory if it doesn't exist. Future files will be stored here +if [[ -d /etc/pihole/ ]];then + : else - echo "Error building the ad list, please try again." - exit 1 + echo "** Creating pihole directory..." + sudo mkdir /etc/pihole fi -service dnsmasq restart \ No newline at end of file + +# 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 + +# 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 + : +fi + +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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] 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 18/25] 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 19/25] 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 20/25] 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 21/25] 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 22/25] 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 23/25] 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 24/25] 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 25/25] 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