From fcf3b4e4e2625327e27f679c144d315e31193e6e Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 23 Jan 2016 11:48:12 -0600 Subject: [PATCH 01/71] file to set lcd font size --- advanced/console-setup | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 advanced/console-setup diff --git a/advanced/console-setup b/advanced/console-setup new file mode 100644 index 00000000..f12be6eb --- /dev/null +++ b/advanced/console-setup @@ -0,0 +1,17 @@ +# CONFIGURATION FILE FOR SETUPCON + +# Consult the console-setup(5) manual page. + +ACTIVE_CONSOLES="/dev/tty[1-6]" + +CHARMAP="UTF-8" + +# For best results with the Adafruit 2.8 LCD and Pi-hole's chronometer +CODESET="guess" +FONTFACE="Terminus" +FONTSIZE="10x20" + +VIDEOMODE= + +# The following is an example how to use a braille font +# FONT='lat9w-08.psf.gz brl-8x8.psf' From 71fd32b1f4396b34230e975ff6792766ed2d166c Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 23 Jan 2016 12:56:27 -0600 Subject: [PATCH 02/71] script to set everything up --- advanced/Scripts/setupLCD.sh | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 advanced/Scripts/setupLCD.sh diff --git a/advanced/Scripts/setupLCD.sh b/advanced/Scripts/setupLCD.sh new file mode 100644 index 00000000..bfcd0fc5 --- /dev/null +++ b/advanced/Scripts/setupLCD.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Pi-hole: A black hole for Internet advertisements +# by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# pi-hole.net/donate + +getInitSys() { + if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then + SYSTEMD=1 + elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then + SYSTEMD=0 + else + echo "Unrecognised init system" + return 1 + fi +} + +autoLoginPiToConsole() { + if [ -e /etc/init.d/lightdm ]; then + if [ $SYSTEMD -eq 1 ]; then + $SUDO systemctl set-default multi-user.target + $SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service + else + $SUDO update-rc.d lightdm disable 2 + $SUDO sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/" + fi + fi +} + + +getInitSys +# Set pi to log in automatically +autoLoginPiToConsole + +# Set chronomter to run automatically when pi logs in +$SUDO echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc + +# Back up the original file and download the new one +$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig +$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup + +# Instantly apply the font change to the LCD screen +$SUDO setupcon + +$SUDO /usr/local/bin/chronometer.sh From 29c593b8b01c86f31c5b3f5e52f24785003a9af7 Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Mon, 25 Jan 2016 00:28:53 -0500 Subject: [PATCH 03/71] Add user pihole if user does not exsist Check if user pihole exist and add if not. This will give pihole its own system user without a login or home directory that is not system dependent. --- automated install/basic-install.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d9e448a9..b07145b2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -431,6 +431,16 @@ runGravity(){ } +setUser(){ + # Check if user pihole exists and create if not + echo "::: Checking if user 'pihole' exists..." + if id -u pihole > /dev/null 2>&1; then + echo "::: User 'pihole' already exists" + else + echo "::: User 'pihole' doesn't exist. Creating..." + $SUDO useradd -r -s /usr/sbin/nologin pihole + fi +} installPihole(){ checkForDependencies # done @@ -438,7 +448,7 @@ installPihole(){ $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html - $SUDO usermod -a -G www-data pi + $SUDO usermod -a -G www-data pihole $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null getGitFiles From c93c4cc5e61c737a4dc76b79e6eea499506b7c1b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Feb 2016 22:28:35 +0000 Subject: [PATCH 04/71] Update basic-install.sh ahem --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 099cf01c..11bdf0c5 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -331,7 +331,7 @@ versionCheckDNSmasq(){ echo " done." fi - echo "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..." + echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..." $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation From 8a90a47fc286ce036b2fbbff17081ea080dea8ea Mon Sep 17 00:00:00 2001 From: CDeeRON Date: Tue, 2 Feb 2016 12:20:30 -0500 Subject: [PATCH 05/71] ATV Hulu domain add added ads-e-darwin.hulu.com which I found to be used when serving ADs on ATV. --- block hulu ads/lighttpd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block hulu ads/lighttpd.conf b/block hulu ads/lighttpd.conf index 9e8d1f80..636fd07d 100644 --- a/block hulu ads/lighttpd.conf +++ b/block hulu ads/lighttpd.conf @@ -38,6 +38,6 @@ 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" { +$HTTP["host"] =~ "ads.hulu.com|ads-v-darwin.hulu.com|ads-e-darwin.hulu.com" { url.redirect = ( ".*" => "http://192.168.1.101:8200/MediaItems/19.mov") } From 3bf61cce95447a17f103a2dc06d2761d554c03cc Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 3 Feb 2016 10:53:23 -0800 Subject: [PATCH 06/71] Add alternative installation method Add installation method for non-pipe installs --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index a0bf4cc3..b51b2201 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ ### ```curl -L install.pi-hole.net | bash``` +#### Alternative Semi-Automated install #### +``` +wget -O basic-install.sh install.pi-hole.net +chmod +x basic-install.sh +./basic-install.sh +``` + Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/). ## Pi-hole Is Free, But Powered By Your Donations From c18a1c3ecabdfbaa7aaf67091fb05d426c602002 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 4 Feb 2016 01:17:00 -0800 Subject: [PATCH 07/71] Add A+ to Raspberry Pi Platforms A+ Supported --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b51b2201..7e938834 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Automated Install -##### Designed For Raspberry Pi B, B+, 2, and Zero (with an Ethernet adapter) +##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet adapter) 1. Install Raspbian 2. Run the command below From 8e6ec6ef0ca323964d9cb89f0069c2d18dc00cd5 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 Feb 2016 15:50:15 +0000 Subject: [PATCH 08/71] Create CONTRIBUTING.md Initial commit. Basic list, could probably do with some work.... --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8fac7c45 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +This is a basic checklist for now, We will update it in future. + +* Fork the repo and create your new branch based on the `development` branch. +* Submit Pull Requests to the development branch only. +* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!) +* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it.. From 282da1c2b642472d280f3e7f0599fc2549e9beeb Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 5 Feb 2016 12:22:23 -0500 Subject: [PATCH 09/71] Add to contributor info --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fac7c45..1313f599 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,8 @@ -This is a basic checklist for now, We will update it in future. +This is a basic checklist for now, We will update it in the future. * Fork the repo and create your new branch based on the `development` branch. +* Commit Unix line endings +* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission. * Submit Pull Requests to the development branch only. * Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!) * Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it.. From beb6b950f7580a7ca7a1c3ba2354968b26f8bbf0 Mon Sep 17 00:00:00 2001 From: Sergio G Date: Mon, 8 Feb 2016 22:26:41 +0100 Subject: [PATCH 10/71] Replaced 'sudo' with --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 11bdf0c5..abb47886 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -393,7 +393,7 @@ checkForDependencies() { fi echo ":::" echo -n "::: Checking apt-get for upgraded packages...." - updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) + updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) echo " done!" echo ":::" if [[ $updatesToInstall -eq "0" ]]; then From b2fbf46e605c6f316a9e759a6694f23a8332393e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 9 Feb 2016 20:43:45 +0000 Subject: [PATCH 11/71] Added more adlists to the defaults. By default we now block ~ 155,600 ad and tracker domains. Includes NoTrack's tracker list. --- adlists.default | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/adlists.default b/adlists.default index dd391357..c2385f7e 100644 --- a/adlists.default +++ b/adlists.default @@ -6,3 +6,12 @@ http://pgl.yoyo.org/adservers/serverlist.php? http://someonewhocares.org/hosts/hosts http://winhelp2002.mvps.org/hosts.txt http://mirror1.malwaredomains.com/files/justdomains +http://securemecca.com/Downloads/hosts.txt +https://hosts.neocities.org/ +http://sysctl.org/cameleon/hosts +https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist +https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt +https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt +http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt +https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt + From a734927591336cc0ce686fcbcbe19b4cef435a81 Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Tue, 9 Feb 2016 19:51:03 -0600 Subject: [PATCH 12/71] Fixes gravity_transport variable interpretation. Adding (") around Variables passed to function ensures spaces are handled and that missing arguments are accounted for. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 5097e050..c6fbca53 100755 --- a/gravity.sh +++ b/gravity.sh @@ -186,7 +186,7 @@ function gravity_spinup() { # Default is a simple request *) cmd_ext="" esac - gravity_transport $url $cmd_ext $agent + gravity_transport "$url" "$cmd_ext" "$agent" done } From 46d7bfecdb6e2c7c4ab5bf40d0236b768bf10771 Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Wed, 10 Feb 2016 09:34:06 -0600 Subject: [PATCH 13/71] Check for 25mb of free disk space before install Function will check the free space of / (root) If the free space is less than 25MB it will give directions on how to expand the disk. Fixes #163 --- automated install/basic-install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bc027cbd..a0f0ebcb 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -115,6 +115,20 @@ welcomeDialogs() { In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } + +verifyFreeDiskSpace() { + # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) + requiredFreeBytes=25600 + + existingFreeBytes=`df -lkP / | awk '{print $4}' | tail -1` + + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c + exit 1 + fi +} + + chooseInterface() { # Turn the available interfaces into an array so it can be used with a whiptail dialog interfacesArray=() @@ -557,6 +571,9 @@ The install log is in /etc/pihole." $r $c $SUDO mkdir -p /etc/pihole/ welcomeDialogs +# Verify there is enough disk space for the install +verifyFreeDiskSpace + # Just back up the original Pi-hole right away since it won't take long and it gets it out of the way backupLegacyPihole # Find interfaces and let the user choose one From 73bfbba5f75b2f21eaec6fa7c14880f1b1bb21b6 Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Wed, 10 Feb 2016 15:07:31 -0600 Subject: [PATCH 14/71] Set file permisions on /etc/pihole Ensures file permisions on $piholeDir before reload/restart of dnsmasq --- gravity.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gravity.sh b/gravity.sh index 3004b8a2..44131fa3 100755 --- a/gravity.sh +++ b/gravity.sh @@ -321,6 +321,8 @@ function gravity_reload() { echo -n "::: Refresh lists in dnsmasq..." dnsmasqPid=$(pidof dnsmasq) + find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! + if [[ $dnsmasqPid ]]; then # service already running - reload config $SUDO kill -HUP $dnsmasqPid & spinner $! From b5406240c68252c6a6cd8afc2428780b0efe8fb5 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 10 Feb 2016 19:07:48 -0500 Subject: [PATCH 15/71] Fixes IPv6 surviving a reinstall --- automated install/basic-install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bc027cbd..00431c69 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -148,6 +148,12 @@ chooseInterface() { } +cleanupIPv6() { + # Removes IPv6 indicator file if we are not using IPv6 + if [ -f "/etc/pihole/.useIPv6" ] && [ ! $useIPv6 ]; then + rm /etc/pihole/.useIPv6 + fi +} use4andor6() { # Let use select IPv4 and/or IPv6 @@ -187,6 +193,7 @@ use4andor6() { echo "::: Exiting" exit 1 fi + cleanupIPv6 else echo "::: Cancel selected. Exiting..." exit 1 From 4c24186911f01292932228c00b4f73bad4a94c0a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 14 Feb 2016 02:58:09 +0000 Subject: [PATCH 16/71] Fixes divide by zero error. --- advanced/Scripts/chronometer.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 2fe00498..9153d9ba 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -51,9 +51,13 @@ function CalcblockedToday(){ function CalcPercentBlockedToday(){ if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then - #scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros - percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc) - percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday") + if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :) + #scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros + percentBlockedToday=$(echo "scale=4; $blockedToday/$queriesToday*100" | bc) + percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday") + else + percentBlockedToday=0 + fi fi } From ecd46f85601b849734d5bcc512cc2f312d69470f Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Sat, 13 Feb 2016 22:36:24 -0600 Subject: [PATCH 17/71] Allow installer to specify own DNS servers Offers "other" option. Gives Installer chance to review settings before continuing. --- automated install/basic-install.sh | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 00431c69..226f6e41 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -286,9 +286,10 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 3) DNSChooseOptions=(Google "" on - OpenDNS "" off) + OpenDNS "" off + Other "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in @@ -302,6 +303,23 @@ setDNS(){ piholeDNS1="208.67.222.222" piholeDNS2="208.67.220.220" ;; + Other) + until [[ $DNSSettingsCorrect = True ]] + do + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') + piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct? + DNS Server 1: $piholeDNS1 + DNS Server 2: $piholeDNS2" $r $c) then + DNSSettingsCorrect=True + else + # If the settings are wrong, the loop continues + DNSSettingsCorrect=False + fi + done + ;; esac else echo "::: Cancel selected. Exiting..." @@ -342,8 +360,16 @@ versionCheckDNSmasq(){ $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation - $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation - $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation + if [[ "$piholDNS1" != "" ]]; then + $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation + fi + if [[ "$piholDNS2" != "" ]]; then + $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation + fi } installScripts() { From 68a9b88b58ebbe59870f7316f64d386d94529ccd Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 14 Feb 2016 10:20:02 -0600 Subject: [PATCH 18/71] docker container for Pi-hole --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e938834..207375f2 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei [![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) ## Pi-hole Projects +- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) - [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension)) - [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037) - [Sky-Hole](http://dlaa.me/blog/post/skyhole) From 3142992c573e564e4fabeac8ea0c32c04bc14f95 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sun, 14 Feb 2016 10:53:13 -0600 Subject: [PATCH 19/71] update --- advanced/Scripts/setupLCD.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/setupLCD.sh b/advanced/Scripts/setupLCD.sh index bfcd0fc5..00e3a3f8 100644 --- a/advanced/Scripts/setupLCD.sh +++ b/advanced/Scripts/setupLCD.sh @@ -1,17 +1,21 @@ #!/usr/bin/env bash # Pi-hole: A black hole for Internet advertisements -# by Jacob Salmela -# Network-wide ad blocking via your Raspberry Pi -# # (c) 2015 by Jacob Salmela -# This file is part of Pi-hole. +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# Automatically configures the Pi to use the 2.8 LCD screen to display stats on it (also works over ssh) # # Pi-hole is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# pi-hole.net/donate +# Set up the LCD screen based on Adafruits instuctions +curl -SLs https://apt.adafruit.com/add-pin | sudo bash +sudo apt-get -y install raspberrypi-bootloader +sudo apt-get -y install adafruit-pitft-helper + +# Borrowed from somewhere. Will update when I find it. getInitSys() { if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then SYSTEMD=1 @@ -23,6 +27,7 @@ getInitSys() { fi } +# Borrowed from somewhere. Will update when I find it. autoLoginPiToConsole() { if [ -e /etc/init.d/lightdm ]; then if [ $SYSTEMD -eq 1 ]; then @@ -37,6 +42,7 @@ autoLoginPiToConsole() { getInitSys + # Set pi to log in automatically autoLoginPiToConsole @@ -50,4 +56,5 @@ $SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-ho # Instantly apply the font change to the LCD screen $SUDO setupcon +# Start chronometer after the settings are applues $SUDO /usr/local/bin/chronometer.sh From 3a887af513295a03d754edfe13e5070c400e01e1 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 14 Feb 2016 22:24:21 +0000 Subject: [PATCH 20/71] Addresses #313 path to white and blacklist scripts moved to variables and updated to include full path --- gravity.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 948c06f3..6e620d4d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -31,6 +31,8 @@ piholeIPv6file=/etc/pihole/.useIPv6 adListFile=/etc/pihole/adlists.list adListDefault=/etc/pihole/adlists.default +whitelistScript=/usr/local/bin/whitelist.sh +blacklistScript=/usr/local/bin/blacklist.sh if [[ -f $piholeIPfile ]];then # If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script @@ -220,7 +222,7 @@ function gravity_Schwarzchild() { function gravity_Blacklist(){ # Append blacklist entries if they exist echo -n "::: Running blacklist script to update HOSTS file...." - blacklist.sh -f -nr -q > /dev/null & spinner $! + $blacklistScript -f -nr -q > /dev/null & spinner $! numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s @@ -245,7 +247,7 @@ function gravity_Whitelist() { echo " done!" echo -n "::: Running whitelist script to update HOSTS file...." - whitelist.sh -f -nr -q ${urls[@]} > /dev/null & spinner $! + $whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $! numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s From 4d0b4cfb36f0cf5592449323e9c2bfcc1cb71012 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 14 Feb 2016 23:44:23 +0000 Subject: [PATCH 21/71] Update basic-install.sh Do not stop dnsmasq when installing. Instead run `service dnsmasq restart` once installation is complete. This may have been the cause of issues outlined in #218 --- 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 359a1f0d..514ac8e6 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -387,7 +387,7 @@ stopServices() { # Stop dnsmasq and lighttpd $SUDO echo ":::" $SUDO echo -n "::: Stopping services..." - $SUDO service dnsmasq stop & spinner $! || true + #$SUDO service dnsmasq stop & spinner $! || true $SUDO service lighttpd stop & spinner $! || true $SUDO echo " done." } @@ -601,7 +601,7 @@ displayFinalMessage echo -n "::: Restarting services..." # Start services -$SUDO service dnsmasq start +$SUDO service dnsmasq restart $SUDO service lighttpd start echo " done." From f8897942f3e7e13335247af7a7ada666349a000f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 15 Feb 2016 19:26:39 +0000 Subject: [PATCH 22/71] Update adlists.default Remove 'securemecca.com` list, as they block other content, not just ads and malware. Pi-hole is about ad-blocking and privacy, not about censoring content. See :https://www.reddit.com/r/pihole/comments/45xuh8/slug/d00xg02 --- adlists.default | 2 -- 1 file changed, 2 deletions(-) diff --git a/adlists.default b/adlists.default index c2385f7e..b8932eb2 100644 --- a/adlists.default +++ b/adlists.default @@ -6,7 +6,6 @@ http://pgl.yoyo.org/adservers/serverlist.php? http://someonewhocares.org/hosts/hosts http://winhelp2002.mvps.org/hosts.txt http://mirror1.malwaredomains.com/files/justdomains -http://securemecca.com/Downloads/hosts.txt https://hosts.neocities.org/ http://sysctl.org/cameleon/hosts https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist @@ -14,4 +13,3 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt - From 06444c1c27b37f6347b3504559c86139a5faa2bf Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:31:31 -0500 Subject: [PATCH 23/71] Add 3 More DNS Server Choices Durring Install Added Level 3 , Norton, and Comodo DNS Choices --- automated install/basic-install.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 514ac8e6..35bcec41 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -316,6 +316,21 @@ setDNS(){ piholeDNS1="208.67.222.222" piholeDNS2="208.67.220.220" ;; + Level3) + echo "::: Using Level3 servers." + piholeDNS1="4.2.2.1" + piholeDNS2="4.2.2.2" + ;; + Norton) + echo "::: Using Norton ConnectSafe servers." + piholeDNS1="199.85.126.10" + piholeDNS2="199.85.127.10" + ;; + Comodo) + echo "::: Using Comodo Secure servers." + piholeDNS1="8.26.56.26" + piholeDNS2="8.20.247.20" + ;; esac else echo "::: Cancel selected. Exiting..." From c4fc2e089d78daef76a10fb60eb10f568013b956 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 15 Feb 2016 17:36:59 -0500 Subject: [PATCH 24/71] Removed dead list Fixes #316 --- adlists.default | 1 - 1 file changed, 1 deletion(-) diff --git a/adlists.default b/adlists.default index b8932eb2..cf5ca45b 100644 --- a/adlists.default +++ b/adlists.default @@ -6,7 +6,6 @@ http://pgl.yoyo.org/adservers/serverlist.php? http://someonewhocares.org/hosts/hosts http://winhelp2002.mvps.org/hosts.txt http://mirror1.malwaredomains.com/files/justdomains -https://hosts.neocities.org/ http://sysctl.org/cameleon/hosts https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt From 94600c54cbaac14e6e7c0e32b06fce9cddc7b624 Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:54:17 -0500 Subject: [PATCH 25/71] Added Default State for New DNS Options Added default state of off for 3 new DNS options to better match existing code --- automated install/basic-install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 35bcec41..84ba3921 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -302,7 +302,10 @@ setStaticIPv4() { setDNS(){ DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) DNSChooseOptions=(Google "" on - OpenDNS "" off) + OpenDNS "" off + Level3 "" off + Norton "" off + Comodo "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in From da959e1296761c3e70d5ab3b812c649fd4424d2b Mon Sep 17 00:00:00 2001 From: slamanna212 Date: Mon, 15 Feb 2016 17:55:14 -0500 Subject: [PATCH 26/71] Increased Size Of Whiptail Dialog Increased Size of Whiptail Dialog to 5 to show all 5 DNS choices --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 84ba3921..23aa827f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -300,7 +300,7 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 2) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 5) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off From 432e6d539502795117840b36dd5df35bf433c64e Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Tue, 16 Feb 2016 16:47:36 -0600 Subject: [PATCH 27/71] Cleaned up output, Fixed Cancel button --- automated install/basic-install.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 600b8fd8..e85593dd 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -305,7 +305,7 @@ setDNS(){ OpenDNS "" off Level3 "" off Norton "" off - Comodo "" off) + Comodo "" off Other "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then @@ -339,12 +339,15 @@ setDNS(){ until [[ $DNSSettingsCorrect = True ]] do piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) - piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') - piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + if [[ $? = 0 ]];then + piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') + piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + else + echo "::: Cancel selected, exiting...." + exit 1 + fi - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct? - DNS Server 1: $piholeDNS1 - DNS Server 2: $piholeDNS2" $r $c) then + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then DNSSettingsCorrect=True else # If the settings are wrong, the loop continues From 40f541bc31a23e49853f9536b809f4ab403d0baa Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 16 Feb 2016 23:00:48 +0000 Subject: [PATCH 28/71] update verifyFreeDiskSpace()... addresses #322. Will now check free space on the first file system output by 'df- lkP`, as opposed to `/` to make pi-hole more compatible with other distros. --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 514ac8e6..837c3179 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -120,7 +120,7 @@ verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=25600 - existingFreeBytes=`df -lkP / | awk '{print $4}' | tail -1` + existingFreeBytes=`df -lkP | awk '{print $4}' | tail -1` if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c From c396aeed52b844b28e9cbef5ee9a33f932144dae Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 17 Feb 2016 00:07:14 +0000 Subject: [PATCH 29/71] Correct miss-spelled variables on lines 398 and 403 --- 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 e85593dd..a2bf8f7c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -395,12 +395,12 @@ versionCheckDNSmasq(){ $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation - if [[ "$piholDNS1" != "" ]]; then + if [[ "$piholeDNS1" != "" ]]; then $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation else $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation fi - if [[ "$piholDNS2" != "" ]]; then + if [[ "$piholeDNS2" != "" ]]; then $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation else $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation From 21c688a8a8c415ea32e79b3b9ef143d5fbf09e0e Mon Sep 17 00:00:00 2001 From: Hippyjake Date: Tue, 16 Feb 2016 18:06:49 -0700 Subject: [PATCH 30/71] add uptime -p to chrono script --- advanced/Scripts/chronometer.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 9153d9ba..ebed8684 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -88,6 +88,7 @@ function normalChrono(){ echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" echo "" uptime | cut -d' ' -f11- + uptime -p echo "-------------------------------" # Uncomment to continually read the log file and display the current domain being blocked #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}' From c3c051385c6bb8e98d15632e1d4473a558369a71 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 12:42:31 +0000 Subject: [PATCH 31/71] Update basic-install.sh Corrected mistake in previous commit --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 837c3179..5850b27e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -120,7 +120,7 @@ verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=25600 - existingFreeBytes=`df -lkP | awk '{print $4}' | tail -1` + existingFreeBytes=`df -lk | awk '{print $4}' | head -2 | tail -1` if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c From 8e289215b4f937795cfb4b1488895d0353cc7cf3 Mon Sep 17 00:00:00 2001 From: Daniel Fayette Date: Wed, 17 Feb 2016 10:00:36 -0600 Subject: [PATCH 32/71] Account for CHIP pc not having root on '/' --- automated install/basic-install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5850b27e..346b419c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -120,7 +120,10 @@ verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=25600 - existingFreeBytes=`df -lk | awk '{print $4}' | head -2 | tail -1` + existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` + if ! [[ "$existingFreeBytes" =~ ^[0-9]\+$ ]]; then + existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` + fi if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c From 9ad7c12710c75ca50b243585e8a2af5582e97edd Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:15:33 +0000 Subject: [PATCH 33/71] Create PULL_REQUEST_TEMPLATE --- .github/PULL_REQUEST_TEMPLATE | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 00000000..1a2aa1ab --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,6 @@ +Fixes #[issue number] . + +Changes proposed in this pull request: +- +- +- From 6581f119fd1fdf5328ab1f0e20d33fdd21803fed Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:16:04 +0000 Subject: [PATCH 34/71] Update PULL_REQUEST_TEMPLATE --- .github/PULL_REQUEST_TEMPLATE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 1a2aa1ab..c9ec842a 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -4,3 +4,5 @@ Changes proposed in this pull request: - - - + +@pihole/gravity From b1515c5e3fa679edbe4fe77b410baafde073757c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:17:20 +0000 Subject: [PATCH 35/71] Rename PULL_REQUEST_TEMPLATE to PULL_REQUEST_TEMPLATE.md --- .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE rename to .github/PULL_REQUEST_TEMPLATE.md From 6530ec58c7ae117e722ea9c03efcd1c27ba7863e Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:18:43 +0000 Subject: [PATCH 36/71] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c9ec842a..8b924ac2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,12 @@ Fixes #[issue number] . -Changes proposed in this pull request: -- -- + +#####Changes proposed in this pull request: + - +- + +- + @pihole/gravity From 950480bb776f73fd731ece61dd12c02d40e3d166 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:20:01 +0000 Subject: [PATCH 37/71] Update PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8b924ac2..071fdf89 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,9 +1,8 @@ Fixes #[issue number] . +Changes proposed in this pull request: -#####Changes proposed in this pull request: - -- +- - From 5f9e5869e94048488118aaae89c3a37b8a09306b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 17 Feb 2016 22:23:01 +0000 Subject: [PATCH 38/71] Create ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..04303614 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,7 @@ +##### Expected Behaviour: + + +##### Actual Behaviour: + + +##### Steps to reproduce this issue: From 0116b6341c3c4955f2e9f5bb97445219a200112b Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 20 Feb 2016 01:14:48 -0600 Subject: [PATCH 39/71] updated script Added links to where code was borrowed from added reboot at the end also added a few things commented out that might be useful for some people to learn. --- advanced/Scripts/setupLCD.sh | 53 ++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/advanced/Scripts/setupLCD.sh b/advanced/Scripts/setupLCD.sh index 00e3a3f8..df2be704 100644 --- a/advanced/Scripts/setupLCD.sh +++ b/advanced/Scripts/setupLCD.sh @@ -10,12 +10,25 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# Set up the LCD screen based on Adafruits instuctions -curl -SLs https://apt.adafruit.com/add-pin | sudo bash -sudo apt-get -y install raspberrypi-bootloader -sudo apt-get -y install adafruit-pitft-helper +############ FUNCTIONS ########### +# Run this script as root or under sudo +echo ":::" +if [[ $EUID -eq 0 ]];then + echo "::: You are root." +else + echo "::: sudo will be used." + # Check if it is actually installed + # If it isn't, exit because the install cannot complete + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "::: Please install sudo or run this script as root." + exit 1 + fi +fi -# Borrowed from somewhere. Will update when I find it. +# Borrowed from adafruit-pitft-helper < borrowed from raspi-config +# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334 getInitSys() { if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then SYSTEMD=1 @@ -27,7 +40,8 @@ getInitSys() { fi } -# Borrowed from somewhere. Will update when I find it. +# Borrowed from adafruit-pitft-helper: +# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285 autoLoginPiToConsole() { if [ -e /etc/init.d/lightdm ]; then if [ $SYSTEMD -eq 1 ]; then @@ -40,14 +54,26 @@ autoLoginPiToConsole() { fi } - -getInitSys - +######### SCRIPT ########### # Set pi to log in automatically +getInitSys autoLoginPiToConsole # Set chronomter to run automatically when pi logs in -$SUDO echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc +echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc +# OR +#$SUDO echo /usr/local/bin/chronometer.sh >> /etc/profile + +# Set up the LCD screen based on Adafruits instuctions: +# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install +curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash +$SUDO apt-get -y install raspberrypi-bootloader +$SUDO apt-get -y install adafruit-pitft-helper +$SUDO adafruit-pitft-helper -t 28r + +# Download the cmdline.txt file that prevents the screen from going blank after a period of time +$SUDO mv /boot/cmdline.txt /boot/cmdline.orig +$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt # Back up the original file and download the new one $SUDO mv /etc/default/console-setup /etc/default/console-setup.orig @@ -56,5 +82,8 @@ $SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-ho # Instantly apply the font change to the LCD screen $SUDO setupcon -# Start chronometer after the settings are applues -$SUDO /usr/local/bin/chronometer.sh +$SUDO reboot + +# Start showing the stats on the screen by running the command on another tty: +# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty +#setsid sh -c 'exec /usr/local/bin/chronometer.sh <> /dev/tty1 >&0 2>&1' From c5d45edf2d93fcd68a31c80fc44078958e754e76 Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 20 Feb 2016 01:15:14 -0600 Subject: [PATCH 40/71] consoleblank=0 This makes sure the LCD screen does not go blank after a set period of time. --- advanced/cmdline.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 advanced/cmdline.txt diff --git a/advanced/cmdline.txt b/advanced/cmdline.txt new file mode 100644 index 00000000..84d52b79 --- /dev/null +++ b/advanced/cmdline.txt @@ -0,0 +1 @@ +dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=font:VGA8x8 consoleblank=0 From b41608d40b9fb5a7330cd42fba947c4337d412c1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 14:44:56 +0000 Subject: [PATCH 41/71] Include fix for regex in verifyFreeDiskSpace() --- automated install/basic-install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a2bf8f7c..505c843d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,15 +117,19 @@ welcomeDialogs() { verifyFreeDiskSpace() { - # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=25600 - - existingFreeBytes=`df -lkP / | awk '{print $4}' | tail -1` - - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c - exit 1 - fi + # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) + requiredFreeBytes=25600 + + existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` + if ! [[ "$existingFreeBytes" =~ ^([0-9])*$ ]]; then + existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` + fi + + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + echo "$existingFreeBytes is less than $requiredFreeBytes" + echo "Insufficient free space, exiting..." + exit 1 + fi } From 4a1e88f4bf8b11a1dac57075d22c6e1f5331c3a0 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 20 Feb 2016 09:48:06 -0500 Subject: [PATCH 42/71] Fixed Pi-hole user not being created --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index faed1077..ac57db43 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -558,6 +558,7 @@ installPihole() { # Install base files and web interface checkForDependencies # done stopServices + setUser $SUDO mkdir -p /etc/pihole/ $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html @@ -567,7 +568,6 @@ installPihole() { getGitFiles installScripts installConfigs - #installWebAdmin CreateLogFile installPiholeWeb installCron From 7001edcd1df8390315ae6295abfaf6ae0d57dac4 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:00:03 +0000 Subject: [PATCH 43/71] Change 'Other' to 'Custom', add explanation to whiptail. Convert spaces to tabs. --- automated install/basic-install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 505c843d..43cd6c78 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,13 +304,13 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider" $r $c 6) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom" $r $c 6) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off Norton "" off Comodo "" off - Other "" off) + Custom "" off) DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]];then case $DNSchoices in @@ -339,10 +339,10 @@ setDNS(){ piholeDNS1="8.26.56.26" piholeDNS2="8.20.247.20" ;; - Other) - until [[ $DNSSettingsCorrect = True ]] - do - piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + Custom) + until [[ $DNSSettingsCorrect = True ]] + do + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') @@ -351,14 +351,14 @@ setDNS(){ exit 1 fi - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then DNSSettingsCorrect=True else # If the settings are wrong, the loop continues DNSSettingsCorrect=False fi - done - ;; + done + ;; esac else echo "::: Cancel selected. Exiting..." From 8687d25d88cd9772ab7b13b54ad7f89e67e8e88b Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:12:13 +0000 Subject: [PATCH 44/71] make prepopulation of freetext on custom DNS provider a bit more intelligent --- automated install/basic-install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43cd6c78..18531f27 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,7 +304,7 @@ setStaticIPv4() { } setDNS(){ - DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom" $r $c 6) + DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6) DNSChooseOptions=(Google "" on OpenDNS "" off Level3 "" off @@ -342,7 +342,15 @@ setDNS(){ Custom) until [[ $DNSSettingsCorrect = True ]] do - piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s)" $r $c "8.8.8.8, 8.8.4.4" 3>&1 1>&2 2>&3) + if [ ! $piholeDNS1 ]; then + prePopulate="" + elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then + prePopulate="$piholeDNS1" + elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then + prePopulate="$piholeDNS1, $piholeDNS2" + fi + + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') From b14b182084e571fa72e44f9b687bf4da0040ccff Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 15:17:57 +0000 Subject: [PATCH 45/71] change regex to test for one or more numbers, not 0 or more numbers. --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 18531f27..b8834951 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -121,7 +121,7 @@ verifyFreeDiskSpace() { requiredFreeBytes=25600 existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` - if ! [[ "$existingFreeBytes" =~ ^([0-9])*$ ]]; then + if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` fi From f3978446039ccd8ceaaf042aec33c84aa023239d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 16:08:02 +0000 Subject: [PATCH 46/71] Remove conflicted merge markup. Not sure how that got through. --- automated install/basic-install.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1a021089..75f32116 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,7 +117,6 @@ welcomeDialogs() { verifyFreeDiskSpace() { -<<<<<<< HEAD # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=25600 @@ -131,20 +130,6 @@ verifyFreeDiskSpace() { echo "Insufficient free space, exiting..." exit 1 fi -======= - # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=25600 - - existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` - if ! [[ "$existingFreeBytes" =~ ^[0-9]\+$ ]]; then - existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` - fi - - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then - whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c - exit 1 - fi ->>>>>>> development } From 800d2f0859eaa70d8a72607392c3d8c13706472c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 16:17:29 +0000 Subject: [PATCH 47/71] Add back in whiptail dialog to verifyFreeDiskSpace() --- automated install/basic-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 75f32116..c20447c2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -125,7 +125,8 @@ verifyFreeDiskSpace() { existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` fi - if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then + whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c echo "$existingFreeBytes is less than $requiredFreeBytes" echo "Insufficient free space, exiting..." exit 1 From 0ebb7eecdb87f7a74304ac31a489e13cfda74e4c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 17:33:20 +0000 Subject: [PATCH 48/71] Verify Custom DNS IP is a valid IP address --- automated install/basic-install.sh | 61 ++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c20447c2..e6deca29 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -304,6 +304,23 @@ setStaticIPv4() { fi } +function valid_ip() +{ + local ip=$1 + local stat=1 + + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ + && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + stat=$? + fi + return $stat +} + setDNS(){ DNSChoseCmd=(whiptail --separate-output --radiolist "Select Upstream DNS Provider. To use your own, select Custom." $r $c 6) DNSChooseOptions=(Google "" on @@ -343,9 +360,16 @@ setDNS(){ Custom) until [[ $DNSSettingsCorrect = True ]] do + + strInvalid="Invalid" + if [ ! $piholeDNS1 ]; then - prePopulate="" - elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then + if [ ! $piholeDNS2 ]; then + prePopulate="" + else + prePopulate=", $piholeDNS2" + fi + elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then prePopulate="$piholeDNS1" elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then prePopulate="$piholeDNS1, $piholeDNS2" @@ -355,16 +379,39 @@ setDNS(){ if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') + + if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then + piholeDNS1=$strInvalid + fi + + if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then + piholeDNS2=$strInvalid + fi + else echo "::: Cancel selected, exiting...." exit 1 fi - - if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then - DNSSettingsCorrect=True - else - # If the settings are wrong, the loop continues + + if [ $piholeDNS1 == $strInvalid ] || [ $piholeDNS2 == $strInvalid ]; then + whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c + + if [ $piholeDNS1 == $strInvalid ]; then + piholeDNS1="" + fi + + if [ $piholeDNS2 == $strInvalid ]; then + piholeDNS2="" + fi + DNSSettingsCorrect=False + else + if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then + DNSSettingsCorrect=True + else + # If the settings are wrong, the loop continues + DNSSettingsCorrect=False + fi fi done ;; From bffc77e47887f786d814945c71df35ae1f9d98c1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 21 Feb 2016 17:45:25 +0000 Subject: [PATCH 49/71] Add support for comments and blank lines in adlists.default/adlists.list --- gravity.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 66b923b8..83700529 100755 --- a/gravity.sh +++ b/gravity.sh @@ -100,7 +100,12 @@ function gravity_collapse() { echo -n "::: Custom adList file detected. Reading..." sources=() while read -a line; do - sources+=($line) + #Do not read commented out or blank lines + if [[ $line = \#* ]] || [[ ! $line ]]; then + echo "" > /dev/null + else + sources+=($line) + fi done < $adListFile echo " done!" else @@ -108,7 +113,12 @@ function gravity_collapse() { echo -n "::: No custom adlist file detected, reading from default file..." sources=() while read -a line; do - sources+=($line) + #Do not read commented out or blank lines + if [[ $line = \#* ]] || [[ ! $line ]]; then + echo "" > /dev/null + else + sources+=($line) + fi done < $adListDefault echo " done!" fi From 13777cc1aa9e5740552bac2da6b53e48e1f6c85f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 21 Feb 2016 18:12:57 +0000 Subject: [PATCH 50/71] update default list to include StevenBlack's amalgamated list (remove seperate lists included in that list). Take advantage of new support for commenting and blank lines --- adlists.default | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/adlists.default b/adlists.default index cf5ca45b..493ca843 100644 --- a/adlists.default +++ b/adlists.default @@ -1,14 +1,46 @@ -https://adaway.org/hosts.txt +## Pi-hole ad-list default sources. Updated 21/02/2016 ######################### +# # +# To make changes to this file: # +# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list # +# 2. run `nano /etc/pihole/adlists.list` # +# 3. Uncomment or comment any of the below lists # +# # +# Know of any other lists? Feel free to let us know about them, or add them # +# to this file! # +################################################################################ + +# The below list amalgamates several lists we used previously. +# See `https://github.com/StevenBlack/hosts` for details +https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts + +# Other lists we consider safe: http://adblock.gjtech.net/?format=unix-hosts -http://hosts-file.net/ad_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 http://mirror1.malwaredomains.com/files/justdomains http://sysctl.org/cameleon/hosts https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt -http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt + +# hosts-file.net list. Updated frequently, but has been known to block legitimate sites. +http://hosts-file.net/ad_servers.txt + +# Mahakala list. Has been known to block legitimage domains including the entire .com range. +#http://adblock.mahakala.is/ + +# ADZHOSTS list. Has been known to block legitimate domains +#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt + +# Windows 10 telemetry list - warning this one may block windows update +#https://raw.githubusercontent.com/crazy-max/HostsWindowsBlocker/master/hosts.txt + +# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc) +#http://securemecca.com/Downloads/hosts.txt + +# Quidsup's tracker list https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt + + +# Untested Lists: +#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt +#http://spam404bl.com/spam404scamlist.txt +#http://malwaredomains.lehigh.edu/files/domains.txt From ca2d3a192cbefda4b5d50ab38f06cf64d63e25b4 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 21 Feb 2016 18:38:34 +0000 Subject: [PATCH 51/71] add double bracket notation to lines 396, 399, 403 . Fixes error raised by @jacobsalmela --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index e6deca29..c20308ab 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -393,14 +393,14 @@ setDNS(){ exit 1 fi - if [ $piholeDNS1 == $strInvalid ] || [ $piholeDNS2 == $strInvalid ]; then + if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c - if [ $piholeDNS1 == $strInvalid ]; then + if [[ $piholeDNS1 == $strInvalid ]]; then piholeDNS1="" fi - if [ $piholeDNS2 == $strInvalid ]; then + if [[ $piholeDNS2 == $strInvalid ]]; then piholeDNS2="" fi From 592af806599c035f1212fd5460545340b0733dc4 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 21 Feb 2016 14:19:57 -0500 Subject: [PATCH 52/71] Update adlists.default --- adlists.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adlists.default b/adlists.default index 493ca843..81676a3d 100644 --- a/adlists.default +++ b/adlists.default @@ -1,7 +1,7 @@ ## Pi-hole ad-list default sources. Updated 21/02/2016 ######################### # # # To make changes to this file: # -# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list # +# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` # # 2. run `nano /etc/pihole/adlists.list` # # 3. Uncomment or comment any of the below lists # # # From a0673c7028c0e7124d1ebe9f2e68160ee70235a0 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 21 Feb 2016 20:38:05 +0000 Subject: [PATCH 53/71] Update basic-install.sh Increase required free bytes. --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c20308ab..b3e6202f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -118,7 +118,7 @@ welcomeDialogs() { verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=25600 + requiredFreeBytes=51200 existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then From 88674e21cfa5ad0166f6444bf7d442fb4cd03c7c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 21 Feb 2016 20:45:56 +0000 Subject: [PATCH 54/71] Update gravity.sh Clear out `pihole.*` files from `/etc/pihole` as they are no longer needed. --- gravity.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gravity.sh b/gravity.sh index 83700529..321aec27 100755 --- a/gravity.sh +++ b/gravity.sh @@ -328,6 +328,12 @@ function gravity_advanced() { } function gravity_reload() { + #Clear no longer needed files... + echo ":::" + echo -n "::: Cleaning up un-needed files..." + $SUDO rm /etc/pihole/pihole.* + echo " done!" + # Reload hosts file echo ":::" echo -n "::: Refresh lists in dnsmasq..." From 830b287e5ddb6a1e9d5f9d2580432ed556922e0f Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Tue, 23 Feb 2016 00:08:50 -0500 Subject: [PATCH 55/71] Update README.md Add NTC CHIP and Debian based distros --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 207375f2..687cc359 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet adapter) +##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), NTC CHIP, and most Debian based distributions -1. Install Raspbian +1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines 2. Run the command below ### ```curl -L install.pi-hole.net | bash``` From c3b5b97a41465808786500acb479ce84461f06b6 Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Thu, 25 Feb 2016 19:42:43 -0500 Subject: [PATCH 56/71] Update README.md Changed wording per @PromoFaux recommendations. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 687cc359..20b581fa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), NTC CHIP, and most Debian based distributions +##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter) and (also works on most Debian based distros!) 1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines 2. Run the command below From af839360477becd626eef8f9b5df86e3863f3ca8 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 28 Feb 2016 15:18:48 -0500 Subject: [PATCH 57/71] Added password to install Saves in password.txt --- automated install/basic-install.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b3e6202f..9c65467c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -658,6 +658,19 @@ setUser(){ fi } +setPassword() { + # Password needed to authorize changes to lists from admin page + pass = $(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3) + + if [ $? = 0 ]; then + # Entered password + echo pass > /etc/pihole/password.txt + else + echo "::: Cancel selected, exiting...." + exit 1 + fi +} + installPihole() { # Install base files and web interface checkForDependencies # done @@ -708,6 +721,9 @@ use4andor6 # Decide what upstream DNS Servers to use setDNS +# Set the admin page password +setPassword + # Install and log everything to a file installPihole | tee $tmpLog From adcd7f10ee2b43b31a3ec2dd1116e46cb68c3d82 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 28 Feb 2016 15:24:38 -0500 Subject: [PATCH 58/71] Fixed password input --- 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 9c65467c..883e2c61 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -660,11 +660,11 @@ setUser(){ setPassword() { # Password needed to authorize changes to lists from admin page - pass = $(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3) + pass=$(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3) if [ $? = 0 ]; then # Entered password - echo pass > /etc/pihole/password.txt + echo $pass > /etc/pihole/password.txt else echo "::: Cancel selected, exiting...." exit 1 From b07b77c58f8603a95e0dc090e933c4f194ce7801 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 29 Feb 2016 20:09:49 -0500 Subject: [PATCH 59/71] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20b581fa..02e7468f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter) and (also works on most Debian based distros!) +##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), and also works on most Debian based distros! 1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines 2. Run the command below From e92cceecc190a72e7c504589bcfa2b8cbbec9fe9 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:12:58 -0800 Subject: [PATCH 60/71] remove trailing whitespace README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02e7468f..9dc189e4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Automated Install +# Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), and also works on most Debian based distros! 1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines From 613ab9febcf13a3f2e9018c4627a036b9591a21d Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:13:23 -0800 Subject: [PATCH 61/71] remove trailing whitespace adlists.default --- adlists.default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adlists.default b/adlists.default index 81676a3d..99786746 100644 --- a/adlists.default +++ b/adlists.default @@ -5,11 +5,11 @@ # 2. run `nano /etc/pihole/adlists.list` # # 3. Uncomment or comment any of the below lists # # # -# Know of any other lists? Feel free to let us know about them, or add them # +# Know of any other lists? Feel free to let us know about them, or add them # # to this file! # ################################################################################ -# The below list amalgamates several lists we used previously. +# The below list amalgamates several lists we used previously. # See `https://github.com/StevenBlack/hosts` for details https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts From e4ddf8bc338ceb89d3f1a4b5c1f9c02086c15ee9 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:13:43 -0800 Subject: [PATCH 62/71] remove trailing whitespace gravity.sh --- gravity.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gravity.sh b/gravity.sh index 321aec27..33f5d6d5 100755 --- a/gravity.sh +++ b/gravity.sh @@ -107,7 +107,7 @@ function gravity_collapse() { sources+=($line) fi done < $adListFile - echo " done!" + echo " done!" else #no custom file found, use defaults! echo -n "::: No custom adlist file detected, reading from default file..." @@ -120,8 +120,8 @@ function gravity_collapse() { sources+=($line) fi done < $adListDefault - echo " done!" - fi + echo " done!" + fi # Create the pihole resource directory if it doesn't exist. Future files will be stored here if [[ -d $piholeDir ]];then @@ -169,9 +169,9 @@ function gravity_transport() { fi # Silently curl url - curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer + curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer # Check for list updates - gravity_patternCheck $patternBuffer + gravity_patternCheck $patternBuffer # Cleanup rm -f $patternBuffer @@ -219,13 +219,13 @@ function gravity_Schwarzchild() { echo "::: " # Find all active domains and compile them into one file and remove CRs echo -n "::: Aggregating list of domains..." - truncate -s 0 $piholeDir/$matterandlight & spinner $! + truncate -s 0 $piholeDir/$matterandlight & spinner $! for i in "${activeDomains[@]}" do cat $i |tr -d '\r' >> $piholeDir/$matterandlight done echo " done!" - + } @@ -233,12 +233,12 @@ function gravity_Blacklist(){ # Append blacklist entries if they exist echo -n "::: Running blacklist script to update HOSTS file...." $blacklistScript -f -nr -q > /dev/null & spinner $! - + numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s echo " $numBlacklisted domain${plural} blacklisted!" - - + + } @@ -247,7 +247,7 @@ function gravity_Whitelist() { # Prevent our sources from being pulled into the hole plural=; [[ "${sources[@]}" != "1" ]] && plural=s echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..." - + urls=() for url in ${sources[@]} do @@ -255,16 +255,16 @@ function gravity_Whitelist() { urls=("${urls[@]}" $tmp) done echo " done!" - + echo -n "::: Running whitelist script to update HOSTS file...." $whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $! - + numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s echo " $numWhitelisted domain${plural} whitelisted!" - - - + + + } function gravity_unique() { @@ -284,7 +284,7 @@ function gravity_hostFormat() { #Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain! echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc - + else # Otherwise, just create gravity.list as normal using IPv4 #Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain! @@ -319,12 +319,12 @@ function gravity_advanced() { echo -n "::: Formatting list of domains to remove comments...." awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $! echo " done!" - + numberOf=$(wc -l < $piholeDir/$supernova) echo "::: $numberOf domains being pulled in by gravity..." - + gravity_unique - + } function gravity_reload() { @@ -333,7 +333,7 @@ function gravity_reload() { echo -n "::: Cleaning up un-needed files..." $SUDO rm /etc/pihole/pihole.* echo " done!" - + # Reload hosts file echo ":::" echo -n "::: Refresh lists in dnsmasq..." From 4f90b413436c6989ee9e71622cb5f57d1d8b4406 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:14:17 -0800 Subject: [PATCH 63/71] remove trailing whitespace dnsmasq.conf.original --- advanced/dnsmasq.conf.original | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/advanced/dnsmasq.conf.original b/advanced/dnsmasq.conf.original index 598d6390..9e4cc92e 100644 --- a/advanced/dnsmasq.conf.original +++ b/advanced/dnsmasq.conf.original @@ -27,8 +27,8 @@ # Replies which are not DNSSEC signed may be legitimate, because the domain # is unsigned, or may be forgeries. Setting this option tells dnsmasq to -# check that an unsigned reply is OK, by finding a secure proof that a DS -# record somewhere between the root and the domain does not exist. +# check that an unsigned reply is OK, by finding a secure proof that a DS +# record somewhere between the root and the domain does not exist. # The cost of setting this is that even queries in unsigned domains will need # one or more extra DNS queries to verify. #dnssec-check-unsigned @@ -183,11 +183,11 @@ #dhcp-range=1234::2, 1234::500, 64, 12h # Do Router Advertisements, BUT NOT DHCP for this subnet. -#dhcp-range=1234::, ra-only +#dhcp-range=1234::, ra-only # Do Router Advertisements, BUT NOT DHCP for this subnet, also try and -# add names to the DNS for the IPv6 address of SLAAC-configured dual-stack -# hosts. Use the DHCPv4 lease to derive the name, network segment and +# add names to the DNS for the IPv6 address of SLAAC-configured dual-stack +# hosts. Use the DHCPv4 lease to derive the name, network segment and # MAC address and assume that the host will also have an # IPv6 address calculated using the SLAAC alogrithm. #dhcp-range=1234::, ra-names @@ -210,9 +210,9 @@ #dhcp-range=1234::, ra-stateless, ra-names # Do router advertisements for all subnets where we're doing DHCPv6 -# Unless overriden by ra-stateless, ra-names, et al, the router +# Unless overriden by ra-stateless, ra-names, et al, the router # advertisements will have the M and O bits set, so that the clients -# get addresses and configuration from DHCPv6, and the A bit reset, so the +# get addresses and configuration from DHCPv6, and the A bit reset, so the # clients don't use SLAAC addresses. #enable-ra @@ -278,11 +278,11 @@ # any machine with Ethernet address starting 11:22:33: #dhcp-host=11:22:33:*:*:*,set:red -# Give a fixed IPv6 address and name to client with +# Give a fixed IPv6 address and name to client with # DUID 00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2 # Note the MAC addresses CANNOT be used to identify DHCPv6 clients. # Note also the they [] around the IPv6 address are obilgatory. -#dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5] +#dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5] # Ignore any clients which are not specified in dhcp-host lines # or /etc/ethers. Equivalent to ISC "deny unknown-clients". @@ -338,7 +338,7 @@ # Send DHCPv6 option. Note [] around IPv6 addresses. #dhcp-option=option6:dns-server,[1234::77],[1234::88] -# Send DHCPv6 option for namservers as the machine running +# Send DHCPv6 option for namservers as the machine running # dnsmasq and another. #dhcp-option=option6:dns-server,[::],[1234::88] @@ -645,4 +645,4 @@ #conf-dir=/etc/dnsmasq.d,.bak # Include all files in a directory which end in .conf -#conf-dir=/etc/dnsmasq.d/*.conf +#conf-dir=/etc/dnsmasq.d/*.conf From f633d1fa5b6d7bac32019e89ded2a20636d486ca Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:14:56 -0800 Subject: [PATCH 64/71] remove trailing whitespace blacklist.sh --- advanced/Scripts/blacklist.sh | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 70b8131a..0eab679d 100644 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -51,13 +51,13 @@ if [[ -f $piholeIPv6file ]];then fi -function HandleOther(){ +function HandleOther(){ #check validity of domain validDomain=$(echo $1 | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/') - + if [ -z "$validDomain" ]; then echo $1 is not a valid argument or domain name - else + else domList=("${domList[@]}" $validDomain) fi } @@ -66,9 +66,9 @@ function PopBlacklistFile(){ #check blacklist file exists, and if not, create it if [[ ! -f $blacklist ]];then touch $blacklist - fi + fi for dom in "${domList[@]}" - do + do if $addmode; then AddDomain $dom else @@ -97,7 +97,7 @@ function AddDomain(){ } function RemoveDomain(){ - + bool=false grep -Ex -q "$1" $blacklist || bool=true if $bool; then @@ -110,42 +110,42 @@ function RemoveDomain(){ if $versbose; then echo "::: Un-blacklisting $dom..." fi - domToRemoveList=("${domToRemoveList[@]}" $1) - modifyHost=true - fi + domToRemoveList=("${domToRemoveList[@]}" $1) + modifyHost=true + fi } -function ModifyHostFile(){ +function ModifyHostFile(){ if $addmode; then #add domains to the hosts file if [[ -r $blacklist ]];then numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" - echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." - if [[ -n $piholeIPv6 ]];then + echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." + if [[ -n $piholeIPv6 ]];then cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList - else + else cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - fi - + fi + fi else - + echo ":::" for dom in "${domToRemoveList[@]}" - do - #we need to remove the domains from the blacklist file and the host file + do + #we need to remove the domains from the blacklist file and the host file echo "::: $dom" echo -n "::: removing from HOSTS file..." - echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList + echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList echo " done!" echo -n "::: removing from blackist.txt..." echo $dom | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist echo " done!" - done + done fi - + } function Reload() { @@ -170,17 +170,17 @@ function Reload() { for var in "$@" do case "$var" in - "-nr"| "--noreload" ) reload=false;; + "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) versbose=false;; * ) HandleOther $var;; esac done PopBlacklistFile -if $modifyHost || $force; then +if $modifyHost || $force; then ModifyHostFile else if $versbose; then From a6877e7c13211fa31d8d6d4f9daf882eda034155 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:15:11 -0800 Subject: [PATCH 65/71] remove trailing whitespace chronometer.sh --- advanced/Scripts/chronometer.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index ebed8684..75e22e29 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -73,9 +73,9 @@ function outputJSON(){ CalcQueriesToday CalcblockedToday CalcPercentBlockedToday - + CalcBlockedDomains - + printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday" } @@ -92,26 +92,26 @@ function normalChrono(){ echo "-------------------------------" # Uncomment to continually read the log file and display the current domain being blocked #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}' - + #uncomment next 4 lines to use original query count calculation #today=$(date "+%b %e") #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) - - + + CalcQueriesToday CalcblockedToday CalcPercentBlockedToday - + CalcBlockedDomains - + echo "Blocking: $blockedDomainsTotal" #below commented line does not add up to todaysQueryCount #echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6" echo "Queries: $queriesToday" #same total calculation as dashboard echo "Pi-holed: $blockedToday ($percentBlockedToday%)" - + sleep 5 done } @@ -125,7 +125,7 @@ function displayHelp(){ echo "Options:" echo " -j, --json output stats as JSON formatted string" echo " -h, --help display this help text" - + exit 1 } @@ -137,7 +137,7 @@ for var in "$@" do case "$var" in "-j" | "--json" ) outputJSON;; - "-h" | "--help" ) displayHelp;; + "-h" | "--help" ) displayHelp;; * ) exit 1;; esac done From 876c51302adb1db8a3cd4ab294be7f28a4706b77 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:15:36 -0800 Subject: [PATCH 66/71] remove trailing whitespace updateDashboard.sh --- advanced/Scripts/updateDashboard.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/updateDashboard.sh b/advanced/Scripts/updateDashboard.sh index edf04896..6955683d 100644 --- a/advanced/Scripts/updateDashboard.sh +++ b/advanced/Scripts/updateDashboard.sh @@ -63,7 +63,7 @@ make_repo() { update_repo() { # pull the latest commits cd "$WEB_INTERFACE_DIR" - git pull + git pull } main From ced0ae0d65c3ded801d5210265f6d8eccfd22347 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:15:53 -0800 Subject: [PATCH 67/71] remove trailing whitespace whitelist.sh --- advanced/Scripts/whitelist.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 853c3b79..79f71a71 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -50,13 +50,13 @@ if [[ -f $piholeIPv6file ]];then fi -function HandleOther(){ +function HandleOther(){ #check validity of domain validDomain=$(echo $1 | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/') - + if [ -z "$validDomain" ]; then echo "::: $1 is not a valid argument or domain name" - else + else domList=("${domList[@]}" $validDomain) fi } @@ -65,9 +65,9 @@ function PopWhitelistFile(){ #check whitelist file exists, and if not, create it if [[ ! -f $whitelist ]];then touch $whitelist - fi + fi for dom in "${domList[@]}" - do + do if $addmode; then AddDomain $dom else @@ -79,7 +79,7 @@ function PopWhitelistFile(){ function AddDomain(){ #| sed 's/\./\\./g' bool=false - + grep -Ex -q "$1" $whitelist || bool=true if $bool; then #domain not found in the whitelist file, add it! @@ -99,7 +99,7 @@ function AddDomain(){ } function RemoveDomain(){ - + bool=false grep -Ex -q "$1" $whitelist || bool=true if $bool; then @@ -113,11 +113,11 @@ function RemoveDomain(){ #echo "::: Un-whitelisting $dom..." #fi domToRemoveList=("${domToRemoveList[@]}" $1) - modifyHost=true - fi + modifyHost=true + fi } -function ModifyHostFile(){ +function ModifyHostFile(){ if $addmode; then #remove domains in from hosts file if [[ -r $whitelist ]];then @@ -129,19 +129,19 @@ function ModifyHostFile(){ awk -F':' '{print $1}' $whitelist | while read line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp awk -F':' '{print $1}' $whitelist | while read line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp echo "l" >> /etc/pihole/whitelist.tmp - grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp + grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp rm /etc/pihole/gravity.list mv /etc/pihole/gravity.tmp /etc/pihole/gravity.list rm /etc/pihole/whitelist.tmp echo " done!" - + fi else #we need to add the removed domains to the hosts file echo ":::" echo "::: Modifying HOSTS file to un-whitelist domains..." for rdom in "${domToRemoveList[@]}" - do + do if [[ -n $piholeIPv6 ]];then echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..." echo $rdom | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList @@ -155,7 +155,7 @@ function ModifyHostFile(){ echo $rdom| sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist echo " done!" done - fi + fi } function Reload() { @@ -179,10 +179,10 @@ function Reload() { for var in "$@" do case "$var" in - "-nr"| "--noreload" ) reload=false;; + "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) versbose=false;; * ) HandleOther $var;; esac done From 4452f784a8dcc0013d678f2d742abfc2166df60d Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:16:23 -0800 Subject: [PATCH 68/71] remove trailing whitespace basic-install.sh --- automated install/basic-install.sh | 56 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 883e2c61..4e6c74fa 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -111,7 +111,7 @@ welcomeDialogs() { whiptail --msgbox --backtitle "Plea" --title "Free and open source" "The Pi-hole is free, but powered by your donations: http://pi-hole.net/donate" $r $c # Explain the need for a static address - whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly. + whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly. In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } @@ -119,12 +119,12 @@ welcomeDialogs() { verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=51200 - - existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` - if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then - existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` + + existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` + if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then + existingFreeBytes=`df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1` fi - + if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then whiptail --msgbox --backtitle "Insufficient Disk Space" --title "Insufficient Disk Space" "\nYour system appears to be low on disk space. pi-hole recomends a minimum of $requiredFreeBytes Bytes.\nYou only have $existingFreeBytes Free.\n\nIf this is a new install you may need to expand your disk.\n\nTry running:\n 'sudo raspi-config'\nChoose the 'expand file system option'\n\nAfter rebooting, run this installation again.\n\ncurl -L install.pi-hole.net | bash\n" $r $c echo "$existingFreeBytes is less than $requiredFreeBytes" @@ -164,7 +164,7 @@ chooseInterface() { echo "::: Cancel selected, exiting...." exit 1 fi - + } cleanupIPv6() { @@ -188,7 +188,7 @@ use4andor6() { IPv6 ) useIPv6=true;; esac done - + if [ $useIPv4 ] && [ ! $useIPv6 ]; then getStaticIPv4Settings setStaticIPv4 @@ -308,7 +308,7 @@ function valid_ip() { local ip=$1 local stat=1 - + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then OIFS=$IFS IFS='.' @@ -360,9 +360,9 @@ setDNS(){ Custom) until [[ $DNSSettingsCorrect = True ]] do - + strInvalid="Invalid" - + if [ ! $piholeDNS1 ]; then if [ ! $piholeDNS2 ]; then prePopulate="" @@ -374,38 +374,38 @@ setDNS(){ elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then prePopulate="$piholeDNS1, $piholeDNS2" fi - + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\n\nFor example '8.8.8.8, 8.8.4.4'" $r $c "$prePopulate" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then piholeDNS1=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo $piholeDNS | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') - + if ! valid_ip $piholeDNS1 || [ ! $piholeDNS1 ]; then piholeDNS1=$strInvalid fi - + if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then piholeDNS2=$strInvalid fi - + else echo "::: Cancel selected, exiting...." exit 1 fi - + if [[ $piholeDNS1 == $strInvalid ]] || [[ $piholeDNS2 == $strInvalid ]]; then - whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c - + whiptail --msgbox --backtitle "Invalid IP" --title "Invalid IP" "One or both entered IP addresses were invalid. Please try again.\n\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c + if [[ $piholeDNS1 == $strInvalid ]]; then piholeDNS1="" fi - + if [[ $piholeDNS2 == $strInvalid ]]; then piholeDNS2="" fi - + DNSSettingsCorrect=False - else + else if (whiptail --backtitle "Specify Upstream DNS Provider(s)" --title "Upstream DNS Provider(s)" --yesno "Are these settings correct?\n DNS Server 1: $piholeDNS1\n DNS Server 2: $piholeDNS2" $r $c) then DNSSettingsCorrect=True else @@ -427,11 +427,11 @@ versionCheckDNSmasq(){ dnsFile1="/etc/dnsmasq.conf" dnsFile2="/etc/dnsmasq.conf.orig" dnsSearch="addn-hosts=/etc/pihole/gravity.list" - + defaultFile="/etc/.pihole/advanced/dnsmasq.conf.original" newFileToInstall="/etc/.pihole/advanced/01-pihole.conf" newFileFinalLocation="/etc/dnsmasq.d/01-pihole.conf" - + if [ -f $dnsFile1 ]; then echo -n "::: Existing dnsmasq.conf found..." if grep -q $dnsSearch $dnsFile1; then @@ -443,14 +443,14 @@ versionCheckDNSmasq(){ $SUDO cp $defaultFile $dnsFile1 echo " done." else - echo " it is not a pi-hole file, leaving alone!" + echo " it is not a pi-hole file, leaving alone!" fi else echo -n "::: No dnsmasq.conf found.. restoring default dnsmasq.conf..." $SUDO cp $defaultFile $dnsFile1 echo " done." fi - + echo -n "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..." $SUDO cp $newFileToInstall $newFileFinalLocation echo " done." @@ -635,9 +635,9 @@ installCron() { runGravity() { # Rub gravity.sh to build blacklists $SUDO echo ":::" - $SUDO echo "::: Preparing to run gravity.sh to refresh hosts..." + $SUDO echo "::: Preparing to run gravity.sh to refresh hosts..." if ls /etc/pihole/list* 1> /dev/null 2>&1; then - echo "::: Cleaning up previous install (preserving whitelist/blacklist)" + echo "::: Cleaning up previous install (preserving whitelist/blacklist)" $SUDO rm /etc/pihole/list.* fi #Don't run as SUDO, this was causing issues @@ -661,7 +661,7 @@ setUser(){ setPassword() { # Password needed to authorize changes to lists from admin page pass=$(whiptail --passwordbox "Please enter a password to secure your Pi-hole web interface." 10 50 3>&1 1>&2 2>&3) - + if [ $? = 0 ]; then # Entered password echo $pass > /etc/pihole/password.txt From 8cbd9f7f08a05c11833c6804754e14d0d6255fa4 Mon Sep 17 00:00:00 2001 From: James Singleton Date: Mon, 7 Mar 2016 13:31:50 +0000 Subject: [PATCH 69/71] Optionally block the BBC Breaking News banner --- adlists.default | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adlists.default b/adlists.default index 99786746..3d72642e 100644 --- a/adlists.default +++ b/adlists.default @@ -39,6 +39,9 @@ http://hosts-file.net/ad_servers.txt # Quidsup's tracker list https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt +# Block the BBC News website Breaking News banner +#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts + # Untested Lists: #https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt From 122ce11381932d9101a055f8d49220bf95ea980c Mon Sep 17 00:00:00 2001 From: Stefan Joosten Date: Tue, 8 Mar 2016 00:23:39 +0100 Subject: [PATCH 70/71] Fix URL for Windows 10 Telemetry list. --- adlists.default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adlists.default b/adlists.default index 99786746..6ba9678e 100644 --- a/adlists.default +++ b/adlists.default @@ -30,8 +30,8 @@ http://hosts-file.net/ad_servers.txt # ADZHOSTS list. Has been known to block legitimate domains #http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt -# Windows 10 telemetry list - warning this one may block windows update -#https://raw.githubusercontent.com/crazy-max/HostsWindowsBlocker/master/hosts.txt +# Windows 10 telemetry list +#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt # Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc) #http://securemecca.com/Downloads/hosts.txt From d13ae0610e5ed9ff34b5b2182996d22d8571ef5d Mon Sep 17 00:00:00 2001 From: Morlok8k Date: Tue, 8 Mar 2016 10:19:01 -0800 Subject: [PATCH 71/71] fix for older versions of uptime, on development branch. --- advanced/Scripts/chronometer.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 75e22e29..8cd9f042 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -88,7 +88,8 @@ function normalChrono(){ echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" echo "" uptime | cut -d' ' -f11- - uptime -p + #uptime -p #Doesn't work on all versions of uptime + uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}' echo "-------------------------------" # Uncomment to continually read the log file and display the current domain being blocked #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'