From fcf3b4e4e2625327e27f679c144d315e31193e6e Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Sat, 23 Jan 2016 11:48:12 -0600 Subject: [PATCH 001/311] 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 002/311] 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 003/311] 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 aa1d3a4c2ea3f490e5079a5d19bb21ef8fdd0c51 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 1 Feb 2016 22:19:17 +0000 Subject: [PATCH 004/311] Fix logic in versionCheckDNSmasq, as dnsmasq.conf was being overwritten every time install was run. Fixes @kmr2319 's concern in #98 --- automated install/basic-install.sh | 62 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3992665d..f3221743 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -303,35 +303,39 @@ setDNS(){ } versionCheckDNSmasq(){ - # Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory - dnsFile1="/etc/dnsmasq.conf" - dnsFile2="/etc/dnsmasq.conf.orig" - dnsSearch="addn-hosts=/etc/pihole/gravity.list" - - # Check if /etc/dnsmasq.conf exists - if [ -d "/etc/dnsmasq.conf" ]; then - # If true, Check dnsmasq.conf for pihole magic - if grep -q $dnsSearch $dnsFile1; then - # If true, Check dnsmasq.conf.orig for pihole magic - if grep -q $dnsSearch $dnsFile2; then - # If true, use advanced/dnsmasq.conf.original - $SUDO mv -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig - $SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf - else - # If false, mv original file back - $SUDO mv -f /etc/dnsmasq.conf.orig /etc/dnsmasq.conf - fi - # If false, This is a fresh install - fi - else - # If false, use advanced/dnsmasq.conf.original - $SUDO cp /etc/.pihole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf - fi - - $SUDO cp /etc/.pihole/advanced/01-pihole.conf /etc/dnsmasq.d/01-pihole.conf - $SUDO sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.d/01-pihole.conf - $SUDO sed -i "s/@DNS1@/$piholeDNS1/" /etc/dnsmasq.d/01-pihole.conf - $SUDO sed -i "s/@DNS2@/$piholeDNS2/" /etc/dnsmasq.d/01-pihole.conf + # Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory + 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 + echo " it is from a previous pi-hole install." + echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..." + $SUDO mv -f $dnsFile1 $dnsFile2 + echo " done." + echo -n "::: Restoring default dnsmasq.conf..." + $SUDO cp $defaultFile $dnsFile1 + echo " done." + else + 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 "::: copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf" + $SUDO cp $newFileToInstall $newFileFinalLocation + $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation + $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation + $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation } installScripts() { From 06cba7defdae776b8bacaf7b3c96f50066a66b45 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 1 Feb 2016 22:25:28 +0000 Subject: [PATCH 005/311] Fix script output around new changes --- 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 516b145d..099cf01c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -331,8 +331,9 @@ versionCheckDNSmasq(){ echo " done." fi - echo "::: copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf" + echo "::: Copying 01-pihole.conf to /etc/dnsmasq.d/01-pihole.conf..." $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 @@ -355,11 +356,10 @@ installScripts() { installConfigs() { # Install the configs from /etc/.pihole to their various locations $SUDO echo ":::" - $SUDO echo -n "::: Installing configs..." + $SUDO echo "::: Installing configs..." versionCheckDNSmasq $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf - $SUDO echo " done." } stopServices() { From c93c4cc5e61c737a4dc76b79e6eea499506b7c1b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Feb 2016 22:28:35 +0000 Subject: [PATCH 006/311] 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 007/311] 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 008/311] 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 009/311] 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 010/311] 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 011/311] 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 b7f6498a5c0d0464fe27b3b70758394201dc3f0b Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 5 Feb 2016 15:50:15 +0000 Subject: [PATCH 012/311] 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 31fda124f306d3f9aa8679a98347357de68d25e6 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 5 Feb 2016 12:22:23 -0500 Subject: [PATCH 013/311] 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 9941651b3c51e61d5b758d12fc9c9ad10b5450a6 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 6 Feb 2016 13:02:21 +0000 Subject: [PATCH 014/311] Addresses changes as requested by @jacobsalmela in #282 --- automated install/basic-install.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5400e683..90fe3221 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -571,6 +571,18 @@ $SUDO mv $tmpLog $instalLogLoc displayFinalMessage +echo -n "::: Restarting services..." # Start services $SUDO service dnsmasq start $SUDO service lighttpd start +echo " done." + +echo ":::" +echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:" +echo "::: $IPv4addr" +echo "::: $piholeIPv6" +echo ":::" +echo "::: If you set a new IP address, you should restart the Pi." +echo "::: " +echo "::: The install log is in /etc/pihole.log" + From 2d1c0be24ece43900944e6a86935b9bb0295eef4 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 6 Feb 2016 13:04:54 +0000 Subject: [PATCH 015/311] fix reference to install log location. #282 --- 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 90fe3221..1cffab76 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -584,5 +584,5 @@ echo "::: $piholeIPv6" echo ":::" echo "::: If you set a new IP address, you should restart the Pi." echo "::: " -echo "::: The install log is in /etc/pihole.log" +echo "::: The install log is located at: /etc/pihole/install.log" From beb6b950f7580a7ca7a1c3ba2354968b26f8bbf0 Mon Sep 17 00:00:00 2001 From: Sergio G Date: Mon, 8 Feb 2016 22:26:41 +0100 Subject: [PATCH 016/311] 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 017/311] 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 018/311] 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 019/311] 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 020/311] 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 021/311] 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 022/311] 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 023/311] 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 024/311] 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 025/311] 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 026/311] 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 027/311] 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 028/311] 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 029/311] 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 030/311] 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 031/311] 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 032/311] 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 033/311] 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 034/311] 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 035/311] 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 036/311] 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 037/311] 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 038/311] 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 039/311] 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 040/311] 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 041/311] 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 042/311] 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 043/311] 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 044/311] 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 045/311] 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 046/311] 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 047/311] 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 048/311] 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 049/311] 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 050/311] 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 051/311] 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 052/311] 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 053/311] 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 99863bb799512b701be969e693693013145b8c6e Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 20 Feb 2016 10:33:04 -0600 Subject: [PATCH 054/311] pihole on ubuntu 14.04 Also moved a link from "coverage" into "projects" as it was more appropriate --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 207375f2..39bb7f23 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ 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 +- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) - [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) +- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) - [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) @@ -34,7 +36,6 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage -- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) - [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) - [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d) From 0ebb7eecdb87f7a74304ac31a489e13cfda74e4c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 20 Feb 2016 17:33:20 +0000 Subject: [PATCH 055/311] 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 056/311] 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 057/311] 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 058/311] 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 059/311] 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 060/311] 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 061/311] 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 52549d51abd90ee0536189e15c0db1fa0771d2fe Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 22 Feb 2016 09:24:17 +0000 Subject: [PATCH 062/311] Update adlists.default Add extra warning regarding mahakala.is list. See comment by @leichterleben in #341 --- adlists.default | 1 + 1 file changed, 1 insertion(+) diff --git a/adlists.default b/adlists.default index 81676a3d..0d99244f 100644 --- a/adlists.default +++ b/adlists.default @@ -25,6 +25,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt http://hosts-file.net/ad_servers.txt # Mahakala list. Has been known to block legitimage domains including the entire .com range. +# Warning: Due to the sheer size of this list, the web admin console will be unresponsive. #http://adblock.mahakala.is/ # ADZHOSTS list. Has been known to block legitimate domains From 830b287e5ddb6a1e9d5f9d2580432ed556922e0f Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Tue, 23 Feb 2016 00:08:50 -0500 Subject: [PATCH 063/311] 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 6c58ea18dc349fcb5a7479c10b60b5ad47b00413 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 24 Feb 2016 12:02:18 -0500 Subject: [PATCH 064/311] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39bb7f23..8df42072 100644 --- a/README.md +++ b/README.md @@ -93,4 +93,4 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - There is also an [FAQ section on pi-hole.net](http://pi-hole.net) ## Other Operating Systems -This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install only works for a clean install of Raspiban right now since that is how the project originated. +This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. From c3b5b97a41465808786500acb479ce84461f06b6 Mon Sep 17 00:00:00 2001 From: Chad Howell Date: Thu, 25 Feb 2016 19:42:43 -0500 Subject: [PATCH 065/311] 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 066/311] 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 067/311] 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 068/311] 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 2182b8339e971f76296ac4c683dbefbe7a1bcc3e Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 4 Mar 2016 04:22:54 -0800 Subject: [PATCH 069/311] Add social addresses --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8df42072..ed8b7e4b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei ## Pi-hole Is Free, But Powered By Your Donations [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") +## Catch us out on the net: +Twitter: @The_Pi_Hole +reddit: /r/pihole + ## How Does It Work? **Watch the 60-second video below to get a quick overview** From 4230b0388461547c5eeed615ad104155d94586bc Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 4 Mar 2016 07:34:17 -0500 Subject: [PATCH 070/311] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed8b7e4b..69ae4c2a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei ## Catch us out on the net: Twitter: @The_Pi_Hole + reddit: /r/pihole ## How Does It Work? From b1554d6a890ced0c6e51d56cd93821c34319186d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 4 Mar 2016 04:38:31 -0800 Subject: [PATCH 071/311] Add links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69ae4c2a..af57dc88 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") ## Catch us out on the net: -Twitter: @The_Pi_Hole +Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) -reddit: /r/pihole +reddit: [/r/pihole](https://www.reddit.com/r/pihole/) ## How Does It Work? **Watch the 60-second video below to get a quick overview** From 0ed30b802d5820bca40a01464e54e86ff796b144 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 4 Mar 2016 11:52:19 -0600 Subject: [PATCH 072/311] adafruit blog mention --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index af57dc88..0e21693c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage +- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) - [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) - [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d) From 3283f3ed7d2ae782ae8b7703849e1cb45aebd615 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 4 Mar 2016 12:07:29 -0600 Subject: [PATCH 073/311] Show off our pretty dashboard --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0e21693c..d250c4d0 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb `http://192.168.1.x/admin/index.php` +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) + ### API A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: From e92cceecc190a72e7c504589bcfa2b8cbbec9fe9 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 5 Mar 2016 21:12:58 -0800 Subject: [PATCH 074/311] 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 075/311] 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 076/311] 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 077/311] 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 078/311] 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 079/311] 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 080/311] 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 081/311] 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 082/311] 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 083/311] 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 084/311] 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 085/311] 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;}' From f09745b4ad963e22811195327299b865a68f1619 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 8 Mar 2016 16:28:45 -0500 Subject: [PATCH 086/311] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d250c4d0..0665b47d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet adapter) +##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet/Wi-Fi adapter) 1. Install Raspbian 2. Run the command below From a44a201f0088a48a4240f380dded8c815ed4411e Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 14 Mar 2016 22:51:16 -0500 Subject: [PATCH 087/311] rewrite js files to a valid stub --- advanced/lighttpd.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf index 5a662ffa..124371a9 100644 --- a/advanced/lighttpd.conf +++ b/advanced/lighttpd.conf @@ -53,4 +53,6 @@ $HTTP["url"] =~ "^/admin/" { $HTTP["url"] =~ "^(?!/admin)/.*" { # Create a response header for debugging using curl -I setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) + # rewrite only js requests + url.rewrite = ("(.*).js" => "pihole/index.js") } From d3971b26e4e278a227f861697c2063acd6bfe9a8 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 14 Mar 2016 22:52:02 -0500 Subject: [PATCH 088/311] add a valid js stub --- advanced/index.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 advanced/index.js diff --git a/advanced/index.js b/advanced/index.js new file mode 100644 index 00000000..6e81b42f --- /dev/null +++ b/advanced/index.js @@ -0,0 +1 @@ +var x = "X-Pi-hole: A black hole for Internet advertisements." From 404ea0ce6daaf61b1e6739d2ae3647d85390b24d Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 14 Mar 2016 22:54:45 -0500 Subject: [PATCH 089/311] copy both the html and js stubs during install --- 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 b3e6202f..35c885e8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -619,7 +619,7 @@ installPiholeWeb() { else $SUDO mkdir /var/www/html/pihole $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig - $SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html + $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. $SUDO echo " done!" fi } From b79db363368310cc47fcea4b4abd2426ce898c5d Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Mon, 14 Mar 2016 22:59:38 -0500 Subject: [PATCH 090/311] no need for the X- header prefix in the string --- advanced/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.js b/advanced/index.js index 6e81b42f..c9da5aff 100644 --- a/advanced/index.js +++ b/advanced/index.js @@ -1 +1 @@ -var x = "X-Pi-hole: A black hole for Internet advertisements." +var x = "Pi-hole: A black hole for Internet advertisements." From eb462955feb3c9da3713b54a80ed07e91eda1f95 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 16 Mar 2016 05:06:03 -0700 Subject: [PATCH 091/311] Secure Pulls now with HTTPS Closes #310 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0665b47d..1a181d6f 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ 1. Install Raspbian 2. Run the command below -### ```curl -L install.pi-hole.net | bash``` +### ```curl -L https://install.pi-hole.net | bash``` #### Alternative Semi-Automated install #### ``` -wget -O basic-install.sh install.pi-hole.net +wget -O basic-install.sh https://install.pi-hole.net chmod +x basic-install.sh ./basic-install.sh ``` From 0b5f005a5d799d0a0a1200061ea668434fa77eaf Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 19 Mar 2016 20:32:11 -0500 Subject: [PATCH 092/311] Added piholeDebug.sh script for advanced debugging Script piholeDebug.sh added to /usr/local/bin to generate a detailed log file for debugging/troubleshooting. --- advanced/Scripts/piholeDebug.sh | 157 +++++++++++++++++++++++++++++ automated install/basic-install.sh | 3 +- 2 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 advanced/Scripts/piholeDebug.sh diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh new file mode 100644 index 00000000..ead75cd9 --- /dev/null +++ b/advanced/Scripts/piholeDebug.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash +# Pi-hole: A black hole for Internet advertisements +# (c) 2015, 2016 by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# Flushes /var/log/pihole.log +# +# 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. + +# Nate Brandeburg +# nate@ubiquisoft.com +# 3/19/2016 + +######## GLOBAL VARS ######## +DEBUG_LOG="/var/log/pihole_debug.log" + +######## FIRST CHECK ######## +# Must be root to debug +if [[ $EUID -eq 0 ]];then + echo "::: You are root... Beginning debug!" +else + echo "::: sudo will be used for debugging." + # Check if sudo is actually installed + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "::: Please install sudo or run this as root." + exit 1 + fi +fi + +# Ensure the file exists, create if not, clear if exists. +if [ ! -f "$DEBUG_LOG" ] +then + $SUDO touch $DEBUG_LOG + $SUDO chmod 644 $DEBUG_LOG + $SUDO chown "$USER":root $DEBUG_LOG +else + truncate -s 0 $DEBUG_LOG +fi + +### Check Pi internet connections ### +# Log the IP addresses of this Pi +IPADDR=$(ifconfig | perl -nle 's/dr:(\S+)/print $1/e') +echo "Writing local IPs to debug log" +echo "IP Addresses of this Pi:" >> $DEBUG_LOG +echo "$IPADDR" >> $DEBUG_LOG +echo >> $DEBUG_LOG + +# Check if we can connect to the local gateway +GATEWAY_CHECK=$(ping -q -w 1 -c 1 "$(ip r | grep default | cut -d ' ' -f 3)" > /dev/null && echo ok || echo error) +echo "Gateway check:" >> $DEBUG_LOG +echo "$GATEWAY_CHECK" >> $DEBUG_LOG +echo >> $DEBUG_LOG + +echo "Writing dnsmasq.conf to debug log..." +echo "############### Dnsmasq ###############" >> $DEBUG_LOG +DNSMASQFILE="/etc/dnsmasq.conf" +if [ -e "$DNSMASQFILE" ] +then + cat $DNSMASQFILE >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No dnsmasq.conf file found!" >> $DEBUG_LOG + echo "No dnsmasq.conf file found!" +fi + +echo "Writing hosts file to debug log..." +echo "############### Hosts ###############" >> $DEBUG_LOG +HOSTSFILE="/etc/hosts" +if [ -e "$HOSTSFILE" ] +then + cat "$HOSTSFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No hosts file found!" >> $DEBUG_LOG + echo "No hosts file found!" +fi + +### PiHole application specific logging ### +# Write Pi-Hole logs to debug log +echo "Writing whitelist to debug log..." +echo "############### Whitelist ###############" >> $DEBUG_LOG +WHITELISTFILE="/etc/pihole/whitelist.txt" +if [ -e "$WHITELISTFILE" ] +then + cat "$WHITELISTFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No whitelist.txt file found!" >> $DEBUG_LOG + echo "No whitelist.txt file found!" +fi + +echo "Writing blacklist to debug log..." +echo "############### Blacklist ###############" >> $DEBUG_LOG +BLACKLISTFILE="/etc/pihole/blacklist.txt" +if [ -e "$BLACKLISTFILE" ] +then + cat "$BLACKLISTFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No blacklist.txt file found!" >> $DEBUG_LOG + echo "No blacklist.txt file found!" +fi + +echo "Writing adlists.list to debug log..." +echo "############### adlists.list ###############" >> $DEBUG_LOG +ADLISTSFILE="/etc/pihole/adlists.list" +if [ -e "$ADLISTSFILE" ] +then + cat "$ADLISTSFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No adlists.list file found!" >> $DEBUG_LOG + echo "No adlists.list file found!" +fi + + +# Continuously append the pihole.log file to the pihole_debug.log file +function dumpPiHoleLog { + trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT + echo -e "Writing current pihole traffic to debug log...\nTry loading any/all sites that you are having trouble with now... (Press ctrl+C to finish)" + echo "############### pihole.log ###############" >> $DEBUG_LOG + PIHOLELOG="/var/log/pihole.log" + if [ -e "$PIHOLELOG" ] + then + while true; do + tail -f "$PIHOLELOG" >> $DEBUG_LOG + echo >> $DEBUG_LOG + done + else + echo "No pihole.log file found!" >> $DEBUG_LOG + echo "No pihole.log file found!" + fi +} + +function finalWrites { + # Write the gravity.list after the user is finished capturing the pihole.log output + echo "Writing gravity.list to debug log..." + echo "############### gravity.list ###############" >> $DEBUG_LOG + GRAVITYFILE="/etc/pihole/gravity.list" + if [ -e "$GRAVITYFILE" ] + then + cat /etc/pihole/gravity.list >> $DEBUG_LOG + echo >> $DEBUG_LOG + else + echo "No gravity.list file found!" >> $DEBUG_LOG + echo "No gravity.list file found" + fi +} +trap finalWrites EXIT + +### Method calls for additinal logging ### +dumpPiHoleLog diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b3e6202f..8068a485 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -477,7 +477,8 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh - $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /usr/local/bin/piholeDebug.sh + $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,piholeDebug}.sh $SUDO echo " done." } From b0dd2310186647afa7e27c0f91aceea49c187b27 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 19 Mar 2016 21:34:02 -0500 Subject: [PATCH 093/311] Modified description in header Removed copied header description from piholeLogFlush.sh and replaced with relevant description. --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index ead75cd9..59ad130e 100644 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -3,7 +3,7 @@ # (c) 2015, 2016 by Jacob Salmela # Network-wide ad blocking via your Raspberry Pi # http://pi-hole.net -# Flushes /var/log/pihole.log +# Generates pihole_debug.log in /var/log/ to be used for troubleshooting. # # 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 From fad5fafa328923f47d1f3a2a04fff49abfe76e43 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 20 Mar 2016 13:26:02 +0000 Subject: [PATCH 094/311] Increase disk space to verify... .. was missing a couple of zeros, and not verifying enough space! Fixes #384 --- 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 b3e6202f..3a53f6dc 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,8 +117,8 @@ welcomeDialogs() { verifyFreeDiskSpace() { - # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) - requiredFreeBytes=51200 + # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) + requiredFreeBytes=5000000 existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then From 02bb5b6742c92426b8677626bc51647fdbec4f59 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 20 Mar 2016 20:50:31 +0000 Subject: [PATCH 095/311] Revert previous change Reopens #384 --- 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 3a53f6dc..7365104d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -118,7 +118,7 @@ welcomeDialogs() { verifyFreeDiskSpace() { # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) - requiredFreeBytes=5000000 + requiredFreeBytes=51200 existingFreeBytes=`df -lk / 2>&1 | awk '{print $4}' | head -2 | tail -1` if ! [[ "$existingFreeBytes" =~ ^([0-9])+$ ]]; then From 04638c90652d56240ab3ac378b5e43b152451417 Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 20 Mar 2016 18:21:35 -0500 Subject: [PATCH 096/311] Added 01-pihole.conf from /etc/dnsmasq.d/ to log Write 01-pihole.conf to debug log --- advanced/Scripts/piholeDebug.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 59ad130e..b47d9755 100644 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -138,13 +138,25 @@ function dumpPiHoleLog { } function finalWrites { + # Write the 01-pihole.conf from /etc/dnsmasq.d/ to the debug log + echo "Writing 01-pihole.conf to debug log..." + echo "############### 01-pihole.conf ###############" >> $DEBUG_LOG + PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" + if [ -e "$PIHOLECONFFILE" ] + then + cat "$PIHOLECONFFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG + else + echo "No 01-pihole.conf file found!" >> $DEBUG_LOG + echo "No 01-pihole.conf file found" + fi # Write the gravity.list after the user is finished capturing the pihole.log output echo "Writing gravity.list to debug log..." echo "############### gravity.list ###############" >> $DEBUG_LOG GRAVITYFILE="/etc/pihole/gravity.list" if [ -e "$GRAVITYFILE" ] then - cat /etc/pihole/gravity.list >> $DEBUG_LOG + cat "$GRAVITYFILE" >> $DEBUG_LOG echo >> $DEBUG_LOG else echo "No gravity.list file found!" >> $DEBUG_LOG From fa2cef639566c5763d6998c4c0afe2915a2b897f Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 21 Mar 2016 08:29:19 -0500 Subject: [PATCH 097/311] link to get LED alerts article added a link to a cool project that makes an LED blink for each ad that gets blocked. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1a181d6f..4ad56250 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) [![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) ## Pi-hole Projects +- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/) - [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) - [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) - [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) From 396c7ab9eebf75e1364056113d50d1c78342d342 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 22 Mar 2016 21:21:08 -0500 Subject: [PATCH 098/311] link to tekthing mention tekthing mentioned us again as one of 5 easy projects for the Raspberry Pi. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4ad56250..28e6791b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage +- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) - [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) - [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) From 00f46dc149ccbec41b690c3af7e59a40a9d6b290 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 23 Mar 2016 14:56:27 -0500 Subject: [PATCH 099/311] Added Pi 3B to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a181d6f..01928cdd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet/Wi-Fi adapter) +##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) 1. Install Raspbian 2. Run the command below From 86eafe7a332f8af6ca6ce5fb4ff32318063715e0 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 24 Mar 2016 16:21:29 -0500 Subject: [PATCH 100/311] Added comparison of gravity.list with Whitelist.txt and Blacklist.txt. Added additional echos to help read the debug file. TODO: testNslookup function --- advanced/Scripts/piholeDebug.sh | 162 +++++++++++++++++++++++--------- 1 file changed, 119 insertions(+), 43 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index b47d9755..8bb741ea 100644 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -12,22 +12,32 @@ # Nate Brandeburg # nate@ubiquisoft.com -# 3/19/2016 +# 3/24/2016 ######## GLOBAL VARS ######## DEBUG_LOG="/var/log/pihole_debug.log" +DNSMASQFILE="/etc/dnsmasq.conf" +PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" +LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf" +GRAVITYFILE="/etc/pihole/gravity.list" +HOSTSFILE="/etc/hosts" +WHITELISTFILE="/etc/pihole/whitelist.txt" +BLACKLISTFILE="/etc/pihole/blacklist.txt" +ADLISTSFILE="/etc/pihole/adlists.list" +PIHOLELOG="/var/log/pihole.log" + ######## FIRST CHECK ######## # Must be root to debug if [[ $EUID -eq 0 ]];then - echo "::: You are root... Beginning debug!" + echo "You are root... Beginning debug!" else - echo "::: sudo will be used for debugging." + echo "sudo will be used for debugging." # Check if sudo is actually installed if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else - echo "::: Please install sudo or run this as root." + echo "Please install sudo or run this as root." exit 1 fi fi @@ -42,6 +52,32 @@ else truncate -s 0 $DEBUG_LOG fi +### Private functions exist here ### +function compareWhitelist { + echo "#######################################" >> $DEBUG_LOG + echo "######## Whitelist Comparison #########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + while read -r line; do + grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG + done < "$WHITELISTFILE" + echo >> $DEBUG_LOG +} + +function compareBlacklist { + echo "#######################################" >> $DEBUG_LOG + echo "######## Blacklist Comparison #########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + while read -r line; do + grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG + done < "$BLACKLISTFILE" + echo >> $DEBUG_LOG +} + +function testNslookup { + # TODO: This will pull a non-matched entry from gravity.list to compare with the nslookup against Google's NS. + echo >> $DEBUG_LOG +} + ### Check Pi internet connections ### # Log the IP addresses of this Pi IPADDR=$(ifconfig | perl -nle 's/dr:(\S+)/print $1/e') @@ -57,20 +93,78 @@ echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG echo "Writing dnsmasq.conf to debug log..." +echo "#######################################" >> $DEBUG_LOG echo "############### Dnsmasq ###############" >> $DEBUG_LOG -DNSMASQFILE="/etc/dnsmasq.conf" +echo "#######################################" >> $DEBUG_LOG if [ -e "$DNSMASQFILE" ] then - cat $DNSMASQFILE >> $DEBUG_LOG + #cat $DNSMASQFILE >> $DEBUG_LOG + while read -r line; do + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + done < "$DNSMASQFILE" echo >> $DEBUG_LOG else echo "No dnsmasq.conf file found!" >> $DEBUG_LOG echo "No dnsmasq.conf file found!" fi +echo "Writing 01-pihole.conf to debug log..." +echo "#######################################" >> $DEBUG_LOG +echo "########### 01-pihole.conf ############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG +if [ -e "$PIHOLECONFFILE" ] +then + #cat "$PIHOLECONFFILE" >> $DEBUG_LOG + while read -r line; do + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + done < "$PIHOLECONFFILE" + echo >> $DEBUG_LOG +else + echo "No 01-pihole.conf file found!" >> $DEBUG_LOG + echo "No 01-pihole.conf file found" +fi + +echo "Writing lighttpd.conf to debug log..." +echo "#######################################" >> $DEBUG_LOG +echo "############ lighttpd.conf ############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG +if [ -e "$LIGHTTPDFILE" ] +then + #cat "$PIHOLECONFFILE" >> $DEBUG_LOG + while read -r line; do + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + done < "$LIGHTTPDFILE" + echo >> $DEBUG_LOG +else + echo "No lighttpd.conf file found!" >> $DEBUG_LOG + echo "No lighttpd.conf file found" +fi + +echo "Writing size of gravity.list to debug log..." +echo "#######################################" >> $DEBUG_LOG +echo "############ gravity.list #############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG +if [ -e "$GRAVITYFILE" ] +then + wc -l "$GRAVITYFILE" >> $DEBUG_LOG + echo >> $DEBUG_LOG +else + echo "No gravity.list file found!" >> $DEBUG_LOG + echo "No gravity.list file found" +fi + +# Write the hostname output to compare against entries in /etc/hosts, which is logged next +echo "Hostname of this pihole is: " >> $DEBUG_LOG +hostname >> $DEBUG_LOG +echo >> $DEBUG_LOG + echo "Writing hosts file to debug log..." -echo "############### Hosts ###############" >> $DEBUG_LOG -HOSTSFILE="/etc/hosts" +echo "#######################################" >> $DEBUG_LOG +echo "################ Hosts ################" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG if [ -e "$HOSTSFILE" ] then cat "$HOSTSFILE" >> $DEBUG_LOG @@ -83,8 +177,9 @@ fi ### PiHole application specific logging ### # Write Pi-Hole logs to debug log echo "Writing whitelist to debug log..." -echo "############### Whitelist ###############" >> $DEBUG_LOG -WHITELISTFILE="/etc/pihole/whitelist.txt" +echo "#######################################" >> $DEBUG_LOG +echo "############## Whitelist ##############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG if [ -e "$WHITELISTFILE" ] then cat "$WHITELISTFILE" >> $DEBUG_LOG @@ -95,8 +190,9 @@ else fi echo "Writing blacklist to debug log..." -echo "############### Blacklist ###############" >> $DEBUG_LOG -BLACKLISTFILE="/etc/pihole/blacklist.txt" +echo "#######################################" >> $DEBUG_LOG +echo "############## Blacklist ##############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG if [ -e "$BLACKLISTFILE" ] then cat "$BLACKLISTFILE" >> $DEBUG_LOG @@ -107,8 +203,9 @@ else fi echo "Writing adlists.list to debug log..." -echo "############### adlists.list ###############" >> $DEBUG_LOG -ADLISTSFILE="/etc/pihole/adlists.list" +echo "#######################################" >> $DEBUG_LOG +echo "############ adlists.list #############" >> $DEBUG_LOG +echo "#######################################" >> $DEBUG_LOG if [ -e "$ADLISTSFILE" ] then cat "$ADLISTSFILE" >> $DEBUG_LOG @@ -123,8 +220,9 @@ fi function dumpPiHoleLog { trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT echo -e "Writing current pihole traffic to debug log...\nTry loading any/all sites that you are having trouble with now... (Press ctrl+C to finish)" - echo "############### pihole.log ###############" >> $DEBUG_LOG - PIHOLELOG="/var/log/pihole.log" + echo "#######################################" >> $DEBUG_LOG + echo "############# pihole.log ##############" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG if [ -e "$PIHOLELOG" ] then while true; do @@ -137,33 +235,11 @@ function dumpPiHoleLog { fi } -function finalWrites { - # Write the 01-pihole.conf from /etc/dnsmasq.d/ to the debug log - echo "Writing 01-pihole.conf to debug log..." - echo "############### 01-pihole.conf ###############" >> $DEBUG_LOG - PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" - if [ -e "$PIHOLECONFFILE" ] - then - cat "$PIHOLECONFFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG - else - echo "No 01-pihole.conf file found!" >> $DEBUG_LOG - echo "No 01-pihole.conf file found" - fi - # Write the gravity.list after the user is finished capturing the pihole.log output - echo "Writing gravity.list to debug log..." - echo "############### gravity.list ###############" >> $DEBUG_LOG - GRAVITYFILE="/etc/pihole/gravity.list" - if [ -e "$GRAVITYFILE" ] - then - cat "$GRAVITYFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG - else - echo "No gravity.list file found!" >> $DEBUG_LOG - echo "No gravity.list file found" - fi +# Anything to be done after capturing of pihole.log terminates +function finalWork { + echo "Finshed debugging!" } -trap finalWrites EXIT +trap finalWork EXIT -### Method calls for additinal logging ### +### Method calls for additional logging ### dumpPiHoleLog From b746250e71e247fc371b9c244d092dd54d28291a Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 24 Mar 2016 18:29:13 -0500 Subject: [PATCH 101/311] Made all advanced/Scripts/ executable for consistency. --- advanced/Scripts/blacklist.sh | 0 advanced/Scripts/piholeDebug.sh | 0 advanced/Scripts/setupLCD.sh | 0 advanced/Scripts/updateDashboard.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 advanced/Scripts/blacklist.sh mode change 100644 => 100755 advanced/Scripts/piholeDebug.sh mode change 100644 => 100755 advanced/Scripts/setupLCD.sh mode change 100644 => 100755 advanced/Scripts/updateDashboard.sh diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh old mode 100644 new mode 100755 diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh old mode 100644 new mode 100755 diff --git a/advanced/Scripts/setupLCD.sh b/advanced/Scripts/setupLCD.sh old mode 100644 new mode 100755 diff --git a/advanced/Scripts/updateDashboard.sh b/advanced/Scripts/updateDashboard.sh old mode 100644 new mode 100755 From 8f8dc66c7052999920d2f83c4f5f1df6d1622646 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 24 Mar 2016 18:50:53 -0500 Subject: [PATCH 102/311] Ignore whitespace when writing config files --- advanced/Scripts/piholeDebug.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 8bb741ea..e84e9319 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -100,8 +100,10 @@ if [ -e "$DNSMASQFILE" ] then #cat $DNSMASQFILE >> $DEBUG_LOG while read -r line; do - [[ "$line" =~ ^#.*$ ]] && continue - echo "$line" >> $DEBUG_LOG + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + fi done < "$DNSMASQFILE" echo >> $DEBUG_LOG else @@ -117,8 +119,10 @@ if [ -e "$PIHOLECONFFILE" ] then #cat "$PIHOLECONFFILE" >> $DEBUG_LOG while read -r line; do - [[ "$line" =~ ^#.*$ ]] && continue - echo "$line" >> $DEBUG_LOG + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + fi done < "$PIHOLECONFFILE" echo >> $DEBUG_LOG else @@ -134,8 +138,10 @@ if [ -e "$LIGHTTPDFILE" ] then #cat "$PIHOLECONFFILE" >> $DEBUG_LOG while read -r line; do - [[ "$line" =~ ^#.*$ ]] && continue - echo "$line" >> $DEBUG_LOG + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + fi done < "$LIGHTTPDFILE" echo >> $DEBUG_LOG else From b4463bf42c2bf10f8d9a885f7f178509784015b1 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 25 Mar 2016 16:42:17 -0500 Subject: [PATCH 103/311] Added test for nslookup Checks the TESTURL for nslookup is not whitelisted --- advanced/Scripts/piholeDebug.sh | 46 ++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index e84e9319..ac7a4262 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -25,16 +25,17 @@ WHITELISTFILE="/etc/pihole/whitelist.txt" BLACKLISTFILE="/etc/pihole/blacklist.txt" ADLISTSFILE="/etc/pihole/adlists.list" PIHOLELOG="/var/log/pihole.log" +WHITELISTMATCHES="/tmp/whitelistmatches.list" ######## FIRST CHECK ######## # Must be root to debug -if [[ $EUID -eq 0 ]];then +if [[ $EUID -eq 0 ]]; then echo "You are root... Beginning debug!" else echo "sudo will be used for debugging." # Check if sudo is actually installed - if [[ $(dpkg-query -s sudo) ]];then + if [[ $(dpkg-query -s sudo) ]]; then export SUDO="sudo" else echo "Please install sudo or run this as root." @@ -43,8 +44,7 @@ else fi # Ensure the file exists, create if not, clear if exists. -if [ ! -f "$DEBUG_LOG" ] -then +if [ ! -f "$DEBUG_LOG" ]; then $SUDO touch $DEBUG_LOG $SUDO chmod 644 $DEBUG_LOG $SUDO chown "$USER":root $DEBUG_LOG @@ -54,11 +54,21 @@ fi ### Private functions exist here ### function compareWhitelist { + if [ ! -f "$WHITELISTMATCHES" ]; then + $SUDO touch $WHITELISTMATCHES + $SUDO chmod 644 $WHITELISTMATCHES + $SUDO chown "$USER":root $WHITELISTMATCHES + else + truncate -s 0 $WHITELISTMATCHES + fi + echo "#######################################" >> $DEBUG_LOG echo "######## Whitelist Comparison #########" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG while read -r line; do - grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG + TMP=$(grep -w ".* $line$" "$GRAVITYFILE") + echo "$TMP" >> $DEBUG_LOG + echo "$TMP" >> $WHITELISTMATCHES done < "$WHITELISTFILE" echo >> $DEBUG_LOG } @@ -74,7 +84,28 @@ function compareBlacklist { } function testNslookup { - # TODO: This will pull a non-matched entry from gravity.list to compare with the nslookup against Google's NS. + TESTURL="" + echo "#######################################" >> $DEBUG_LOG + echo "############ NSLookup Test ############" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + # Find a blocked url that has not been whitelisted. + while read -r line; do + CUTURL=$("$line" | cut -d " " -f2-) + if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then + while read -r line2; do + CUTURL2=$("$line2" | cut -d " " -f2-) + if [ "$CUTURL" != "$CUTURL2" ]; then + TESTURL="$CUTURL" + fi + done < "WHITELISTMATCHES" + fi + done < "GRAVITYFILE" + + echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG + echo nslookup "$TESTURL" >> $DEBUG_LOG + echo >> $DEBUG_LOG + echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG + echo nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG echo >> $DEBUG_LOG } @@ -92,6 +123,9 @@ echo "Gateway check:" >> $DEBUG_LOG echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG +# Test the nslookup here +testNslookup + echo "Writing dnsmasq.conf to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############### Dnsmasq ###############" >> $DEBUG_LOG From a9c24b456d34bf83c1a85287a221be70120b79c8 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 25 Mar 2016 19:04:03 -0500 Subject: [PATCH 104/311] Bug fixes and logging improvements Finalized for production deployment. Next release targeting a tarball of config files plus additional logging. --- advanced/Scripts/piholeDebug.sh | 45 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index ac7a4262..ab417aa6 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -67,8 +67,10 @@ function compareWhitelist { echo "#######################################" >> $DEBUG_LOG while read -r line; do TMP=$(grep -w ".* $line$" "$GRAVITYFILE") - echo "$TMP" >> $DEBUG_LOG - echo "$TMP" >> $WHITELISTMATCHES + if [ ! -z "$TMP" ]; then + echo "$TMP" >> $DEBUG_LOG + echo "$TMP" >> $WHITELISTMATCHES + fi done < "$WHITELISTFILE" echo >> $DEBUG_LOG } @@ -78,34 +80,39 @@ function compareBlacklist { echo "######## Blacklist Comparison #########" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG while read -r line; do - grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG + if [ ! -z "$line" ]; then + grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG + fi done < "$BLACKLISTFILE" echo >> $DEBUG_LOG } function testNslookup { - TESTURL="" + TESTURL="doubleclick.com" echo "#######################################" >> $DEBUG_LOG echo "############ NSLookup Test ############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG # Find a blocked url that has not been whitelisted. - while read -r line; do - CUTURL=$("$line" | cut -d " " -f2-) - if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then - while read -r line2; do - CUTURL2=$("$line2" | cut -d " " -f2-) - if [ "$CUTURL" != "$CUTURL2" ]; then - TESTURL="$CUTURL" - fi - done < "WHITELISTMATCHES" - fi - done < "GRAVITYFILE" + if [ -s "$WHITELISTMATCHES" ]; then + while read -r line; do + CUTURL=${line#*" "} + if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then + while read -r line2; do + CUTURL2=${line2#*" "} + if [ "$CUTURL" != "$CUTURL2" ]; then + TESTURL="$CUTURL" + break 2 + fi + done < "$WHITELISTMATCHES" + fi + done < "$GRAVITYFILE" + fi echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG - echo nslookup "$TESTURL" >> $DEBUG_LOG + nslookup "$TESTURL" >> $DEBUG_LOG echo >> $DEBUG_LOG echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG - echo nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG + nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG echo >> $DEBUG_LOG } @@ -124,6 +131,8 @@ echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG # Test the nslookup here +compareWhitelist +compareBlacklist testNslookup echo "Writing dnsmasq.conf to debug log..." @@ -199,7 +208,6 @@ fi # Write the hostname output to compare against entries in /etc/hosts, which is logged next echo "Hostname of this pihole is: " >> $DEBUG_LOG hostname >> $DEBUG_LOG -echo >> $DEBUG_LOG echo "Writing hosts file to debug log..." echo "#######################################" >> $DEBUG_LOG @@ -215,7 +223,6 @@ else fi ### PiHole application specific logging ### -# Write Pi-Hole logs to debug log echo "Writing whitelist to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############## Whitelist ##############" >> $DEBUG_LOG From 0b9e78df2cf646b372be57d7c8436f42dcc6f4fb Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 26 Mar 2016 14:16:22 -0500 Subject: [PATCH 105/311] Cleaned code and added prompt for purge on uninstall --- advanced/Scripts/blacklist.sh | 30 ++++++------ advanced/Scripts/chronometer.sh | 4 +- advanced/Scripts/whitelist.sh | 27 +++++------ automated install/basic-install.sh | 76 +++++++++++++++--------------- automated install/uninstall.sh | 17 ++++--- gravity.sh | 46 +++++++++--------- 6 files changed, 100 insertions(+), 100 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 70b8131a..cf5e09a7 100644 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -33,13 +33,11 @@ versbose=true domList=() domToRemoveList=() - -piholeIPfile=/tmp/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}') +piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') piholeIP=${piholeIPCIDR%/*} modifyHost=false @@ -53,10 +51,10 @@ fi 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/') + 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 + echo "$1" is not a valid argument or domain name else domList=("${domList[@]}" $validDomain) fi @@ -69,10 +67,10 @@ function PopBlacklistFile(){ fi for dom in "${domList[@]}" do - if $addmode; then - AddDomain $dom + if "$addmode"; then + AddDomain "$dom" else - RemoveDomain $dom + RemoveDomain "$dom" fi done } @@ -86,7 +84,7 @@ function AddDomain(){ if $versbose; then echo -n "::: Adding $1 to blacklist file..." fi - echo $1 >> $blacklist + echo "$1" >> $blacklist modifyHost=true echo " done!" else @@ -119,14 +117,14 @@ function ModifyHostFile(){ if $addmode; then #add domains to the hosts file if [[ -r $blacklist ]];then - numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) + numberOf=$($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 - cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList + $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList else - cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList + $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList fi fi @@ -138,10 +136,10 @@ function ModifyHostFile(){ #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 "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist echo " done!" done fi @@ -157,7 +155,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP $dnsmasqPid + sudo kill -HUP "$dnsmasqPid" else # service not running, start it up sudo service dnsmasq start @@ -174,7 +172,7 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; + * ) HandleOther "$var";; esac done diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index ebed8684..3e5559e0 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -35,7 +35,7 @@ function CalcBlockedDomains(){ function CalcQueriesToday(){ if [ -e "$piLog" ];then - queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l) + queriesToday=$("$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l) else queriesToday="Err." fi @@ -43,7 +43,7 @@ function CalcQueriesToday(){ function CalcblockedToday(){ if [ -e "$piLog" ] && [ -e "$gravity" ];then - blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) + blockedToday=$($piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) else blockedToday="Err." fi diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 853c3b79..0bea10aa 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -33,12 +33,11 @@ versbose=true domList=() domToRemoveList=() -piholeIPfile=/tmp/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}') +piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') piholeIP=${piholeIPCIDR%/*} modifyHost=false @@ -52,7 +51,7 @@ fi 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/') + 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" @@ -69,9 +68,9 @@ function PopWhitelistFile(){ for dom in "${domList[@]}" do if $addmode; then - AddDomain $dom + AddDomain "$dom" else - RemoveDomain $dom + RemoveDomain "$dom" fi done } @@ -86,7 +85,7 @@ function AddDomain(){ if $versbose; then echo -n "::: Adding $1 to whitelist.txt..." fi - echo $1 >> $whitelist + echo "$1" >> $whitelist modifyHost=true if $versbose; then echo " done!" @@ -122,12 +121,12 @@ function ModifyHostFile(){ #remove domains in from hosts file if [[ -r $whitelist ]];then # Remove whitelist entries - numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) + numberOf=$($whitelist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..." - 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 + awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp + awk -F':' '{print $1}' $whitelist | while read -r 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 rm /etc/pihole/gravity.list @@ -144,15 +143,15 @@ function ModifyHostFile(){ 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 + echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList echo " done!" else echo -n "::: Un-whitelisting $rdom on IPv4" - echo $rdom | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList + echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList echo " done!" fi echo -n "::: Removing $rdom from whitelist.txt..." - echo $rdom| sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist + echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist echo " done!" done fi @@ -166,7 +165,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP $dnsmasqPid + sudo kill -HUP "$dnsmasqPid" else # service not running, start it up sudo service dnsmasq start @@ -183,7 +182,7 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; + * ) HandleOther "$var";; esac done diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8068a485..fe385fbb 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -40,7 +40,7 @@ c=$(( columns / 2 )) # Find IP used to route to outside world IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}') +IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1) @@ -63,13 +63,13 @@ else fi fi - -if [ -d "/etc/pihole" ]; then - # Likely an existing install - upgrade=true - else - upgrade=false -fi +### Nate 3/26/2016 - Why are we declaring upgrade here? It isn't global (nor is it used anywhere else) +# if [ -d "/etc/pihole" ]; then + # # Likely an existing install + # upgrade=true + # else + # upgrade=false +# fi ####### FUNCTIONS ########## ###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html @@ -78,10 +78,10 @@ spinner() { spin='-\|/' i=0 - while $SUDO kill -0 $pid 2>/dev/null + while $SUDO kill -0 "$pid" 2>/dev/null do i=$(( (i+1) %4 )) - printf "\b${spin:$i:1}" + printf "\b%s" "{$spin:$i:1}" sleep .1 done printf "\b" @@ -92,12 +92,12 @@ backupLegacyPihole() { if [[ -f /etc/dnsmasq.d/adList.conf ]];then echo "::: Original Pi-hole detected. Initiating sub space transport" $SUDO mkdir -p /etc/pihole/original/ - $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf.$(date "+%Y-%m-%d") - $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf.$(date "+%Y-%m-%d") - $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf.$(date "+%Y-%m-%d") - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf.$(date "+%Y-%m-%d") - $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html.$(date "+%Y-%m-%d") - $SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh.$(date "+%Y-%m-%d") + $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" + $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" + $SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" else : fi @@ -120,9 +120,9 @@ 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` + 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 /dev 2>&1 | awk '{print $4}' | head -2 | tail -1) fi if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then @@ -158,7 +158,7 @@ chooseInterface() { do piholeInterface=$desiredInterface echo "::: Using interface: $piholeInterface" - echo ${piholeInterface} > /tmp/piholeINT + echo "${piholeInterface}" > /tmp/piholeINT done else echo "::: Cancel selected, exiting...." @@ -169,7 +169,7 @@ chooseInterface() { cleanupIPv6() { # Removes IPv6 indicator file if we are not using IPv6 - if [ -f "/etc/pihole/.useIPv6" ] && [ ! $useIPv6 ]; then + if [ -f "/etc/pihole/.useIPv6" ] && [ ! "$useIPv6" ]; then rm /etc/pihole/.useIPv6 fi } @@ -244,11 +244,11 @@ getStaticIPv4Settings() { until [[ $ipSettingsCorrect = True ]] do # Ask for the IPv4 address - IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c $IPv4addr 3>&1 1>&2 2>&3) + IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then echo "::: Your static IPv4 address: $IPv4addr" # Ask for the gateway - IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c $IPv4gw 3>&1 1>&2 2>&3) + IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3) if [[ $? = 0 ]];then echo "::: Your static IPv4 gateway: $IPv4gw" # Give the user a chance to review their settings before moving on @@ -257,8 +257,8 @@ getStaticIPv4Settings() { Gateway: $IPv4gw" $r $c)then # If the settings are correct, then we need to set the piholeIP # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script - echo ${IPv4addr%/*} > /tmp/piholeIP - echo $piholeInterface > /tmp/piholeINT + echo "${IPv4addr%/*}" > /tmp/piholeIP + echo "$piholeInterface" > /tmp/piholeINT # After that's done, the loop ends and we move on ipSettingsCorrect=True else @@ -292,12 +292,12 @@ setDHCPCD() { setStaticIPv4() { # Tries to set the IPv4 address - if grep -q $IPv4addr $dhcpcdFile; then + if grep -q "$IPv4addr" $dhcpcdFile; then # address already set, noop : else setDHCPCD - $SUDO ip addr replace dev $piholeInterface $IPv4addr + $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" echo ":::" echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." echo ":::" @@ -377,14 +377,14 @@ setDNS(){ 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}') + 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 + if ! valid_ip "$piholeDNS1" || [ ! "$piholeDNS1" ]; then piholeDNS1=$strInvalid fi - if ! valid_ip $piholeDNS2 && [ $piholeDNS2 ]; then + if ! valid_ip "$piholeDNS2" && [ "$piholeDNS2" ]; then piholeDNS2=$strInvalid fi @@ -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 @@ -510,7 +510,7 @@ checkForDependencies() { # it needs to have been run at least once on new installs! timestamp=$(stat -c %Y /var/cache/apt/) - timestampAsDate=$(date -d @$timestamp "+%b %e") + timestampAsDate=$(date -d @"$timestamp" "+%b %e") today=$(date "+%b %e") if [ ! "$today" == "$timestampAsDate" ]; then @@ -540,9 +540,9 @@ checkForDependencies() { do : echo -n "::: Checking for $i..." - if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then echo -n " Not found! Installing...." - $SUDO apt-get -y -qq install $i > /dev/null & spinner $! + $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! echo " done!" else echo " already installed!" @@ -583,7 +583,7 @@ is_repo() { make_repo() { # Remove the non-repod interface and clone the interface echo -n "::: Cloning $2 into $1..." - $SUDO rm -rf $1 + $SUDO rm -rf "$1" $SUDO git clone -q "$2" "$1" > /dev/null & spinner $! echo " done!" } @@ -591,7 +591,7 @@ make_repo() { update_repo() { # Pull the latest commits echo -n "::: Updating repo in $1..." - cd "$1" + cd "$1" || exit $SUDO git pull -q > /dev/null & spinner $! echo " done!" } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index ee4e80a0..d116c4e4 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -27,9 +27,16 @@ fi ######### SCRIPT ########### -$SUDO apt-get -y remove --purge dnsutils bc toilet -$SUDO apt-get -y remove --purge dnsmasq -$SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 +read -p "Do you wish to purge PiHole's dependencies from your OS?\n WARNING: This is destructive if run on any non-Debian based OS \n(SAFE TO RUN ON RASPBIAN)" -n 1 -r +echo +if [[ $REPLY =~ ^{Yy]$ ]]; then + $SUDO apt-get -y remove --purge dnsutils bc toilet + $SUDO apt-get -y remove --purge dnsmasq + $SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 + + echo "Removing dnsmasq config files..." + $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig +fi # Only web directories/files that are created by pihole should be removed. echo "Removing the Pi-hole Web server files..." @@ -42,9 +49,6 @@ if [[ ! "$(ls -A /var/www/html)" ]]; then $SUDO rm -rf /var/www/html fi -echo "Removing dnsmasq config files..." -$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig - # Attempt to preserve backwards compatibility with older versions # to guarantee no additional changes were made to /etc/crontab after # the installation of pihole, /etc/crontab.pihole should be permanently @@ -63,7 +67,6 @@ if [[ -f /etc/cron.d/pihole ]];then fi echo "Removing config files and scripts..." -$SUDO rm /etc/dnsmasq.conf $SUDO rm -rf /etc/lighttpd/ $SUDO rm /var/log/pihole.log $SUDO rm /usr/local/bin/gravity.sh diff --git a/gravity.sh b/gravity.sh index 321aec27..4a04f222 100755 --- a/gravity.sh +++ b/gravity.sh @@ -41,7 +41,7 @@ if [[ -f $piholeIPfile ]];then else # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') - piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}') + piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') piholeIP=${piholeIPCIDR%/*} fi @@ -54,18 +54,19 @@ fi # Variables for various stages of downloading and formatting the list +## Nate 3/26/2016 - Commented unused variables basename=pihole piholeDir=/etc/$basename adList=$piholeDir/gravity.list -blacklist=$piholeDir/blacklist.txt -whitelist=$piholeDir/whitelist.txt -latentWhitelist=$piholeDir/latentWhitelist.txt +#blacklist=$piholeDir/blacklist.txt +#whitelist=$piholeDir/whitelist.txt +#latentWhitelist=$piholeDir/latentWhitelist.txt justDomainsExtension=domains matterandlight=$basename.0.matterandlight.txt supernova=$basename.1.supernova.txt eventHorizon=$basename.2.eventHorizon.txt accretionDisc=$basename.3.accretionDisc.txt -eyeOfTheNeedle=$basename.4.wormhole.txt +#eyeOfTheNeedle=$basename.4.wormhole.txt # After setting defaults, check if there's local overrides if [[ -r $piholeDir/pihole.conf ]];then @@ -76,19 +77,18 @@ fi spinner(){ local pid=$1 - local delay=0.001 - local spinstr='/-\|' spin='-\|/' i=0 - while $SUDO kill -0 $pid 2>/dev/null + while $SUDO kill -0 "$pid" 2>/dev/null do i=$(( (i+1) %4 )) - printf "\b${spin:$i:1}" + printf "\b%s" "${spin:$i:1}" sleep .1 done printf "\b" } + ########################### # collapse - begin formation of pihole function gravity_collapse() { @@ -99,7 +99,7 @@ function gravity_collapse() { #custom file found, use this instead of default echo -n "::: Custom adList file detected. Reading..." sources=() - while read -a line; do + while read -r line; do #Do not read commented out or blank lines if [[ $line = \#* ]] || [[ ! $line ]]; then echo "" > /dev/null @@ -112,7 +112,7 @@ function gravity_collapse() { #no custom file found, use defaults! echo -n "::: No custom adlist file detected, reading from default file..." sources=() - while read -a line; do + while read -r line; do #Do not read commented out or blank lines if [[ $line = \#* ]] || [[ ! $line ]]; then echo "" > /dev/null @@ -146,7 +146,7 @@ function gravity_patternCheck() { # Some of the blocklists are copyright, they need to be downloaded # and stored as is. They can be processed for content after they # have been saved. - cp $patternBuffer $saveLocation + cp "$patternBuffer" "$saveLocation" echo " List updated, transport successful!" else # curl didn't download any host files, probably because of the date check @@ -169,12 +169,12 @@ 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 + rm -f "$patternBuffer" } # spinup - main gravity function @@ -222,7 +222,7 @@ function gravity_Schwarzchild() { truncate -s 0 $piholeDir/$matterandlight & spinner $! for i in "${activeDomains[@]}" do - cat $i |tr -d '\r' >> $piholeDir/$matterandlight + "$i" |tr -d '\r' >> $piholeDir/$matterandlight done echo " done!" @@ -249,7 +249,7 @@ function gravity_Whitelist() { echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..." urls=() - for url in ${sources[@]} + for url in "${sources[@]}" do tmp=$(echo "$url" | awk -F '/' '{print $3}') urls=("${urls[@]}" $tmp) @@ -257,7 +257,7 @@ function gravity_Whitelist() { echo " done!" echo -n "::: Running whitelist script to update HOSTS file...." - $whitelistScript -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 @@ -283,13 +283,13 @@ function gravity_hostFormat() { if [[ -n $piholeIPv6 ]];then #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 + $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! echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc - cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc + $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc fi # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp $piholeDir/$accretionDisc $adList @@ -301,10 +301,10 @@ function gravity_blackbody() { for file in $piholeDir/*.$justDomainsExtension do # If list is in active array then leave it (noop) else rm the list - if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then + if [[ " ${activeDomains[@]} " =~ ${file} ]]; then : else - rm -f $file + rm -f "$file" fi done } @@ -343,7 +343,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP $dnsmasqPid & spinner $! + $SUDO kill -HUP "$dnsmasqPid" & spinner $! else # service not running, start it up $SUDO service dnsmasq start & spinner $! From 646c4a3ccc78c9167a79d5e4c95fe4bf6518cc86 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 26 Mar 2016 15:01:02 -0500 Subject: [PATCH 106/311] Newline not read correctly in prompt --- automated install/uninstall.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index d116c4e4..44cf2639 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -27,7 +27,9 @@ fi ######### SCRIPT ########### -read -p "Do you wish to purge PiHole's dependencies from your OS?\n WARNING: This is destructive if run on any non-Debian based OS \n(SAFE TO RUN ON RASPBIAN)" -n 1 -r +read -p "Do you wish to purge PiHole's dependencies from your OS?" -n 1 -r +ehco "WARNING: This is destructive if run on any non-Debian based OS" +echo "(SAFE TO RUN ON RASPBIAN)" echo if [[ $REPLY =~ ^{Yy]$ ]]; then $SUDO apt-get -y remove --purge dnsutils bc toilet From 5223627b719008a124e4acacb1da3da5ddb037ab Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 26 Mar 2016 15:05:55 -0500 Subject: [PATCH 107/311] read locks echos... reordered to warn user --- automated install/uninstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 44cf2639..dbc9cf00 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -27,9 +27,9 @@ fi ######### SCRIPT ########### -read -p "Do you wish to purge PiHole's dependencies from your OS?" -n 1 -r -ehco "WARNING: This is destructive if run on any non-Debian based OS" +echo "WARNING: This is destructive if run on any non-Debian based OS" echo "(SAFE TO RUN ON RASPBIAN)" +read -p "Do you wish to purge PiHole's dependencies from your OS?" -n 1 -r echo if [[ $REPLY =~ ^{Yy]$ ]]; then $SUDO apt-get -y remove --purge dnsutils bc toilet From 7388461ede2a71d7f42b27fecf5072440b830db3 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 26 Mar 2016 15:18:53 -0500 Subject: [PATCH 108/311] Modularized uninstall for cleanliness and robust usability. --- automated install/uninstall.sh | 104 ++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 46 deletions(-) mode change 100644 => 100755 automated install/uninstall.sh diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh old mode 100644 new mode 100755 index dbc9cf00..5ddaa0ac --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -25,54 +25,66 @@ else fi fi +function removeAndPurge { + # Purge dependencies + echo "Purging dependencies!" + $SUDO apt-get -y remove --purge dnsutils bc toilet + $SUDO apt-get -y remove --purge dnsmasq + $SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 + + # Remove dependency config files + echo "Removing dnsmasq config files..." + $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig &> /dev/null +} + +function removeNoPurge { + # Only web directories/files that are created by pihole should be removed. + echo "Removing the Pi-hole Web server files..." + $SUDO rm -rf /var/www/html/admin &> /dev/null + $SUDO rm -rf /var/www/html/pihole &> /dev/null + $SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null + + # If the web directory is empty after removing these files, then the parent html folder can be removed. + if [[ ! "$(ls -A /var/www/html)" ]]; then + $SUDO rm -rf /var/www/html &> /dev/null + fi + + # Attempt to preserve backwards compatibility with older versions + # to guarantee no additional changes were made to /etc/crontab after + # the installation of pihole, /etc/crontab.pihole should be permanently + # preserved. + if [[ -f /etc/crontab.orig ]]; then + echo "Initial Pi-hole cron detected. Restoring the default system cron..." + $SUDO mv /etc/crontab /etc/crontab.pihole + $SUDO mv /etc/crontab.orig /etc/crontab + $SUDO service cron restart + fi + + # Attempt to preserve backwards compatibility with older versions + if [[ -f /etc/cron.d/pihole ]];then + echo "Removing cron.d/pihole..." + $SUDO rm /etc/cron.d/pihole &> /dev/null + fi + + echo "Removing config files and scripts..." + $SUDO rm -rf /etc/lighttpd/ &> /dev/null + $SUDO rm /var/log/pihole.log &> /dev/null + $SUDO rm /usr/local/bin/gravity.sh &> /dev/null + $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null + $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null + $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null + $SUDO rm -rf /etc/pihole/ &> /dev/null + +} ######### SCRIPT ########### echo "WARNING: This is destructive if run on any non-Debian based OS" echo "(SAFE TO RUN ON RASPBIAN)" -read -p "Do you wish to purge PiHole's dependencies from your OS?" -n 1 -r -echo -if [[ $REPLY =~ ^{Yy]$ ]]; then - $SUDO apt-get -y remove --purge dnsutils bc toilet - $SUDO apt-get -y remove --purge dnsmasq - $SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 +while true; do + read -p "Do you wish to purge PiHole's dependencies from your OS?" yn + case $yn in + [Yy]* ) removeAndPurge; break;; - echo "Removing dnsmasq config files..." - $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -fi - -# Only web directories/files that are created by pihole should be removed. -echo "Removing the Pi-hole Web server files..." -$SUDO rm -rf /var/www/html/admin -$SUDO rm -rf /var/www/html/pihole -$SUDO rm /var/www/html/index.lighttpd.orig - -# If the web directory is empty after removing these files, then the parent html folder can be removed. -if [[ ! "$(ls -A /var/www/html)" ]]; then - $SUDO rm -rf /var/www/html -fi - -# Attempt to preserve backwards compatibility with older versions -# to guarantee no additional changes were made to /etc/crontab after -# the installation of pihole, /etc/crontab.pihole should be permanently -# preserved. -if [[ -f /etc/crontab.orig ]]; then - echo "Initial Pi-hole cron detected. Restoring the default system cron..." - $SUDO mv /etc/crontab /etc/crontab.pihole - $SUDO mv /etc/crontab.orig /etc/crontab - $SUDO service cron restart -fi - -# Attempt to preserve backwards compatibility with older versions -if [[ -f /etc/cron.d/pihole ]];then - echo "Removing cron.d/pihole..." - $SUDO rm /etc/cron.d/pihole -fi - -echo "Removing config files and scripts..." -$SUDO rm -rf /etc/lighttpd/ -$SUDO rm /var/log/pihole.log -$SUDO rm /usr/local/bin/gravity.sh -$SUDO rm /usr/local/bin/chronometer.sh -$SUDO rm /usr/local/bin/whitelist.sh -$SUDO rm /usr/local/bin/piholeLogFlush.sh -$SUDO rm -rf /etc/pihole/ + [Nn]* ) removeNoPurge; break;; + esac +done From 901cb44f5e2fe688cde871e1304ae1805c519c73 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 26 Mar 2016 16:50:05 -0500 Subject: [PATCH 109/311] Added /etc/.pihole/ and /var/log/*pihole* to uninstall as well as fixed missing call to removeNoPurge. --- automated install/basic-install.sh | 26 +++++++++++++------------- automated install/uninstall.sh | 14 +++++++++++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index fe385fbb..2f910c03 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -72,19 +72,19 @@ fi # fi ####### FUNCTIONS ########## -###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html -spinner() { - local pid=$1 - - spin='-\|/' - i=0 - while $SUDO kill -0 "$pid" 2>/dev/null - do - i=$(( (i+1) %4 )) - printf "\b%s" "{$spin:$i:1}" - sleep .1 - done - printf "\b" +spinner() +{ + local pid=$1 + local delay=0.75 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + printf " \b\b\b\b" } backupLegacyPihole() { diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 5ddaa0ac..9c47ce44 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -34,7 +34,10 @@ function removeAndPurge { # Remove dependency config files echo "Removing dnsmasq config files..." - $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig &> /dev/null + $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + + # Call removeNoPurge to remove PiHole specific files + removeNoPurge } function removeNoPurge { @@ -45,8 +48,10 @@ function removeNoPurge { $SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null # If the web directory is empty after removing these files, then the parent html folder can be removed. - if [[ ! "$(ls -A /var/www/html)" ]]; then - $SUDO rm -rf /var/www/html &> /dev/null + if [ -d "/var/www/html" ]; then + if [[ ! "$(ls -A /var/www/html)" ]]; then + $SUDO rm -rf /var/www/html &> /dev/null + fi fi # Attempt to preserve backwards compatibility with older versions @@ -73,7 +78,10 @@ function removeNoPurge { $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null + $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null + $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null + $SUDO rm -rf /etc/.pihole/ &> /dev/null } From 5ee382c8ebd96b920133e82c30079dcb6f6e6ab8 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 26 Mar 2016 17:00:52 -0500 Subject: [PATCH 110/311] Roll back addition of piholeDebug.sh (production master base) --- advanced/Scripts/piholeDebug.sh | 157 ----------------------------- automated install/basic-install.sh | 3 +- 2 files changed, 1 insertion(+), 159 deletions(-) delete mode 100644 advanced/Scripts/piholeDebug.sh diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh deleted file mode 100644 index ead75cd9..00000000 --- a/advanced/Scripts/piholeDebug.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env bash -# Pi-hole: A black hole for Internet advertisements -# (c) 2015, 2016 by Jacob Salmela -# Network-wide ad blocking via your Raspberry Pi -# http://pi-hole.net -# Flushes /var/log/pihole.log -# -# 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. - -# Nate Brandeburg -# nate@ubiquisoft.com -# 3/19/2016 - -######## GLOBAL VARS ######## -DEBUG_LOG="/var/log/pihole_debug.log" - -######## FIRST CHECK ######## -# Must be root to debug -if [[ $EUID -eq 0 ]];then - echo "::: You are root... Beginning debug!" -else - echo "::: sudo will be used for debugging." - # Check if sudo is actually installed - if [[ $(dpkg-query -s sudo) ]];then - export SUDO="sudo" - else - echo "::: Please install sudo or run this as root." - exit 1 - fi -fi - -# Ensure the file exists, create if not, clear if exists. -if [ ! -f "$DEBUG_LOG" ] -then - $SUDO touch $DEBUG_LOG - $SUDO chmod 644 $DEBUG_LOG - $SUDO chown "$USER":root $DEBUG_LOG -else - truncate -s 0 $DEBUG_LOG -fi - -### Check Pi internet connections ### -# Log the IP addresses of this Pi -IPADDR=$(ifconfig | perl -nle 's/dr:(\S+)/print $1/e') -echo "Writing local IPs to debug log" -echo "IP Addresses of this Pi:" >> $DEBUG_LOG -echo "$IPADDR" >> $DEBUG_LOG -echo >> $DEBUG_LOG - -# Check if we can connect to the local gateway -GATEWAY_CHECK=$(ping -q -w 1 -c 1 "$(ip r | grep default | cut -d ' ' -f 3)" > /dev/null && echo ok || echo error) -echo "Gateway check:" >> $DEBUG_LOG -echo "$GATEWAY_CHECK" >> $DEBUG_LOG -echo >> $DEBUG_LOG - -echo "Writing dnsmasq.conf to debug log..." -echo "############### Dnsmasq ###############" >> $DEBUG_LOG -DNSMASQFILE="/etc/dnsmasq.conf" -if [ -e "$DNSMASQFILE" ] -then - cat $DNSMASQFILE >> $DEBUG_LOG - echo >> $DEBUG_LOG -else - echo "No dnsmasq.conf file found!" >> $DEBUG_LOG - echo "No dnsmasq.conf file found!" -fi - -echo "Writing hosts file to debug log..." -echo "############### Hosts ###############" >> $DEBUG_LOG -HOSTSFILE="/etc/hosts" -if [ -e "$HOSTSFILE" ] -then - cat "$HOSTSFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG -else - echo "No hosts file found!" >> $DEBUG_LOG - echo "No hosts file found!" -fi - -### PiHole application specific logging ### -# Write Pi-Hole logs to debug log -echo "Writing whitelist to debug log..." -echo "############### Whitelist ###############" >> $DEBUG_LOG -WHITELISTFILE="/etc/pihole/whitelist.txt" -if [ -e "$WHITELISTFILE" ] -then - cat "$WHITELISTFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG -else - echo "No whitelist.txt file found!" >> $DEBUG_LOG - echo "No whitelist.txt file found!" -fi - -echo "Writing blacklist to debug log..." -echo "############### Blacklist ###############" >> $DEBUG_LOG -BLACKLISTFILE="/etc/pihole/blacklist.txt" -if [ -e "$BLACKLISTFILE" ] -then - cat "$BLACKLISTFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG -else - echo "No blacklist.txt file found!" >> $DEBUG_LOG - echo "No blacklist.txt file found!" -fi - -echo "Writing adlists.list to debug log..." -echo "############### adlists.list ###############" >> $DEBUG_LOG -ADLISTSFILE="/etc/pihole/adlists.list" -if [ -e "$ADLISTSFILE" ] -then - cat "$ADLISTSFILE" >> $DEBUG_LOG - echo >> $DEBUG_LOG -else - echo "No adlists.list file found!" >> $DEBUG_LOG - echo "No adlists.list file found!" -fi - - -# Continuously append the pihole.log file to the pihole_debug.log file -function dumpPiHoleLog { - trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT - echo -e "Writing current pihole traffic to debug log...\nTry loading any/all sites that you are having trouble with now... (Press ctrl+C to finish)" - echo "############### pihole.log ###############" >> $DEBUG_LOG - PIHOLELOG="/var/log/pihole.log" - if [ -e "$PIHOLELOG" ] - then - while true; do - tail -f "$PIHOLELOG" >> $DEBUG_LOG - echo >> $DEBUG_LOG - done - else - echo "No pihole.log file found!" >> $DEBUG_LOG - echo "No pihole.log file found!" - fi -} - -function finalWrites { - # Write the gravity.list after the user is finished capturing the pihole.log output - echo "Writing gravity.list to debug log..." - echo "############### gravity.list ###############" >> $DEBUG_LOG - GRAVITYFILE="/etc/pihole/gravity.list" - if [ -e "$GRAVITYFILE" ] - then - cat /etc/pihole/gravity.list >> $DEBUG_LOG - echo >> $DEBUG_LOG - else - echo "No gravity.list file found!" >> $DEBUG_LOG - echo "No gravity.list file found" - fi -} -trap finalWrites EXIT - -### Method calls for additinal logging ### -dumpPiHoleLog diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2f910c03..d3ba437f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -477,8 +477,7 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /usr/local/bin/piholeDebug.sh - $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,piholeDebug}.sh + $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh $SUDO echo " done." } From 5442954db6cd63a81eddc3e66d5cd48179102d52 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 27 Mar 2016 01:53:48 -0500 Subject: [PATCH 111/311] Prompt user to remove each dependent package if they do choose to remove packages at all. --- automated install/basic-install.sh | 11 +++++-- automated install/uninstall.sh | 51 +++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d3ba437f..7833c7e4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -75,9 +75,9 @@ fi spinner() { local pid=$1 - local delay=0.75 + local delay=0.50 local spinstr='|/-\' - while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} @@ -486,6 +486,10 @@ installConfigs() { $SUDO echo ":::" $SUDO echo "::: Installing configs..." versionCheckDNSmasq + if [ ! -d "/etc/lighttpd" ]; then + $SUDO mkdir /etc/lighttpd + $SUDO chown "$USER":root /etc/lighttpds + fi $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf } @@ -664,6 +668,9 @@ installPihole() { stopServices setUser $SUDO mkdir -p /etc/pihole/ + if [ ! -d "/var/www/html" ]; then + $SUDO mkdir /var/www/html + fi $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html $SUDO usermod -a -G www-data pihole diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 9c47ce44..8467256f 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -14,7 +14,7 @@ if [[ $EUID -eq 0 ]];then echo "You are root." else - echo "sudo will be used for the install." + echo "sudo will be used for the uninstall." # Check if it is actually installed # If it isn't, exit because the unnstall cannot complete if [[ $(dpkg-query -s sudo) ]];then @@ -27,15 +27,49 @@ fi function removeAndPurge { # Purge dependencies - echo "Purging dependencies!" - $SUDO apt-get -y remove --purge dnsutils bc toilet - $SUDO apt-get -y remove --purge dnsmasq - $SUDO apt-get -y remove --purge lighttpd php5-common php5-cgi php5 + read -p "Do you wish to purge dnsutils?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge dnsutils + fi + + read -p "Do you wish to purge bc?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge bc + fi + + read -p "Do you wish to purge toilet?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge toilet + fi + + read -p "Do you wish to purge dnsmasq?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge dnsmasq + fi + + read -p "Do you wish to purge lighttpd?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge lighttpd + fi + + read -p "Do you wish to purge php5?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + $SUDO apt-get -y remove --purge php5-common php5-cgi php5 + fi # Remove dependency config files echo "Removing dnsmasq config files..." $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + # Take care of any additional package cleaning + $SUDO apt-get -y autoremove + # Call removeNoPurge to remove PiHole specific files removeNoPurge } @@ -86,13 +120,14 @@ function removeNoPurge { } ######### SCRIPT ########### -echo "WARNING: This is destructive if run on any non-Debian based OS" -echo "(SAFE TO RUN ON RASPBIAN)" +echo "Preparing to remove packages, be sure that each may be safely removed depending on your operating system." +echo "(SAFE TO REMOVE ALL ON RASPBIAN)" while true; do - read -p "Do you wish to purge PiHole's dependencies from your OS?" yn + read -rp "Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" yn case $yn in [Yy]* ) removeAndPurge; break;; [Nn]* ) removeNoPurge; break;; esac done + From 2b5cee05e6e5c1181256ef1b8dfb1b089851e09a Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 27 Mar 2016 01:57:52 -0500 Subject: [PATCH 112/311] Check for existing directory before trying to perform operations on it. --- 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 7833c7e4..ca546256 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -488,7 +488,7 @@ installConfigs() { versionCheckDNSmasq if [ ! -d "/etc/lighttpd" ]; then $SUDO mkdir /etc/lighttpd - $SUDO chown "$USER":root /etc/lighttpds + $SUDO chown "$USER":root /etc/lighttpd fi $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf From 8c45bd32b749e0b95840b974e7c7123da7a87eac Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 27 Mar 2016 12:31:05 -0500 Subject: [PATCH 113/311] Loop through dependencies for future expansion. Syntax of uninstall script now matches basic-install.sh. More error handling of missing default files. Force user prompt for removing packages when uninstalling. --- automated install/basic-install.sh | 11 ++-- automated install/uninstall.sh | 101 +++++++++++++++-------------- 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ca546256..134ec3e2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -489,8 +489,8 @@ installConfigs() { if [ ! -d "/etc/lighttpd" ]; then $SUDO mkdir /etc/lighttpd $SUDO chown "$USER":root /etc/lighttpd + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig fi - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf } @@ -622,9 +622,13 @@ installPiholeWeb() { $SUDO echo " Existing page detected, not overwriting" else $SUDO mkdir /var/www/html/pihole - $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + if [ -f /var/www/html/index.lighttpd.html ]; then + $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + else + printf "\n:::\tNo default index.lighttpd.html file found... not backing up" + fi $SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html - $SUDO echo " done!" + $SUDO echo "::: done!" fi } @@ -646,7 +650,6 @@ runGravity() { fi #Don't run as SUDO, this was causing issues echo "::: Running gravity.sh" - echo ":::" /usr/local/bin/gravity.sh } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 8467256f..ffbf4246 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -12,71 +12,71 @@ # Must be root to uninstall if [[ $EUID -eq 0 ]];then - echo "You are root." + echo "::: You are root." else - echo "sudo will be used for the uninstall." + echo "::: Sudo will be used for the uninstall." # Check if it is actually installed # If it isn't, exit because the unnstall cannot complete if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else - echo "Please install sudo or run this as root." + echo "::: Please install sudo or run this as root." exit 1 fi fi +spinner() +{ + local pid=$1 + local delay=0.50 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + printf " \b\b\b\b" +} + function removeAndPurge { # Purge dependencies - read -p "Do you wish to purge dnsutils?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge dnsutils - fi - - read -p "Do you wish to purge bc?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge bc - fi - - read -p "Do you wish to purge toilet?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge toilet - fi - - read -p "Do you wish to purge dnsmasq?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge dnsmasq - fi - - read -p "Do you wish to purge lighttpd?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge lighttpd - fi - - read -p "Do you wish to purge php5?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - $SUDO apt-get -y remove --purge php5-common php5-cgi php5 - fi +echo ":::" + dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + for i in "${dependencies[@]}"; do + if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" | grep -c "ok installed")" -eq 1 ]; then + while true; do + read -rp "::: Do you wish to remove $i from your system? (y/n): " yn + case $yn in + [Yy]* ) echo "::: Removing $i..."; $SUDO apt-get -y remove --purge "$i" > /dev/null & spinner $!; echo "DONE!"; break;; + [Nn]* ) echo "::: Skipping $i"; break;; + * ) echo "::: You must answer yes or no!";; + esac + done + else + echo "IF FAILED ***" + fi + done # Remove dependency config files - echo "Removing dnsmasq config files..." + echo "::: Removing dnsmasq config files..." $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null # Take care of any additional package cleaning - $SUDO apt-get -y autoremove + echo "::: Auto removing remaining dependencies" + $SUDO apt-get -y autoremove &> /dev/null & spinner $!; echo "DONE!"; + echo "::: Auto cleaning remaining dependencies" + $SUDO apt-get -y autoclean &> /dev/null & spinner $!; echo "DONE!"; # Call removeNoPurge to remove PiHole specific files removeNoPurge } function removeNoPurge { + echo ":::" # Only web directories/files that are created by pihole should be removed. - echo "Removing the Pi-hole Web server files..." + echo "::: Removing the Pi-hole Web server files..." $SUDO rm -rf /var/www/html/admin &> /dev/null $SUDO rm -rf /var/www/html/pihole &> /dev/null $SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null @@ -93,7 +93,7 @@ function removeNoPurge { # the installation of pihole, /etc/crontab.pihole should be permanently # preserved. if [[ -f /etc/crontab.orig ]]; then - echo "Initial Pi-hole cron detected. Restoring the default system cron..." + echo "::: Initial Pi-hole cron detected. Restoring the default system cron..." $SUDO mv /etc/crontab /etc/crontab.pihole $SUDO mv /etc/crontab.orig /etc/crontab $SUDO service cron restart @@ -101,11 +101,11 @@ function removeNoPurge { # Attempt to preserve backwards compatibility with older versions if [[ -f /etc/cron.d/pihole ]];then - echo "Removing cron.d/pihole..." + echo "::: Removing cron.d/pihole..." $SUDO rm /etc/cron.d/pihole &> /dev/null fi - echo "Removing config files and scripts..." + echo "::: Removing config files and scripts..." $SUDO rm -rf /etc/lighttpd/ &> /dev/null $SUDO rm /var/log/pihole.log &> /dev/null $SUDO rm /usr/local/bin/gravity.sh &> /dev/null @@ -116,14 +116,18 @@ function removeNoPurge { $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null $SUDO rm -rf /etc/.pihole/ &> /dev/null - + + echo ":::" + printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" + printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n" + printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n" } ######### SCRIPT ########### -echo "Preparing to remove packages, be sure that each may be safely removed depending on your operating system." -echo "(SAFE TO REMOVE ALL ON RASPBIAN)" +echo "::: Preparing to remove packages, be sure that each may be safely removed depending on your operating system." +echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)" while true; do - read -rp "Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" yn + read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" yn case $yn in [Yy]* ) removeAndPurge; break;; @@ -131,3 +135,4 @@ while true; do esac done + From 1a1026b367d0b34512e96b8f070a7452f049844b Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 27 Mar 2016 14:44:42 -0500 Subject: [PATCH 114/311] Consistent stdout to match basic-install.sh and uninstall.sh --- advanced/Scripts/piholeDebug.sh | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index ab417aa6..7656f963 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -31,14 +31,14 @@ WHITELISTMATCHES="/tmp/whitelistmatches.list" ######## FIRST CHECK ######## # Must be root to debug if [[ $EUID -eq 0 ]]; then - echo "You are root... Beginning debug!" + echo "::: You are root... Beginning debug!" else - echo "sudo will be used for debugging." + echo "::: Sudo will be used for debugging." # Check if sudo is actually installed if [[ $(dpkg-query -s sudo) ]]; then export SUDO="sudo" else - echo "Please install sudo or run this as root." + echo "::: Please install sudo or run this as root." exit 1 fi fi @@ -119,7 +119,7 @@ function testNslookup { ### Check Pi internet connections ### # Log the IP addresses of this Pi IPADDR=$(ifconfig | perl -nle 's/dr:(\S+)/print $1/e') -echo "Writing local IPs to debug log" +echo "::: Writing local IPs to debug log" echo "IP Addresses of this Pi:" >> $DEBUG_LOG echo "$IPADDR" >> $DEBUG_LOG echo >> $DEBUG_LOG @@ -135,7 +135,7 @@ compareWhitelist compareBlacklist testNslookup -echo "Writing dnsmasq.conf to debug log..." +echo "::: Writing dnsmasq.conf to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############### Dnsmasq ###############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -151,10 +151,10 @@ then echo >> $DEBUG_LOG else echo "No dnsmasq.conf file found!" >> $DEBUG_LOG - echo "No dnsmasq.conf file found!" + printf ":::\tNo dnsmasq.conf file found!\n" fi -echo "Writing 01-pihole.conf to debug log..." +echo "::: Writing 01-pihole.conf to debug log..." echo "#######################################" >> $DEBUG_LOG echo "########### 01-pihole.conf ############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -170,10 +170,10 @@ then echo >> $DEBUG_LOG else echo "No 01-pihole.conf file found!" >> $DEBUG_LOG - echo "No 01-pihole.conf file found" + echo "::: No 01-pihole.conf file found\n" fi -echo "Writing lighttpd.conf to debug log..." +echo "::: Writing lighttpd.conf to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############ lighttpd.conf ############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -189,10 +189,10 @@ then echo >> $DEBUG_LOG else echo "No lighttpd.conf file found!" >> $DEBUG_LOG - echo "No lighttpd.conf file found" + printf ":::\tNo lighttpd.conf file found\n" fi -echo "Writing size of gravity.list to debug log..." +echo "::: Writing size of gravity.list to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############ gravity.list #############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -202,14 +202,14 @@ then echo >> $DEBUG_LOG else echo "No gravity.list file found!" >> $DEBUG_LOG - echo "No gravity.list file found" + printf ":::\tNo gravity.list file found\n" fi # Write the hostname output to compare against entries in /etc/hosts, which is logged next echo "Hostname of this pihole is: " >> $DEBUG_LOG hostname >> $DEBUG_LOG -echo "Writing hosts file to debug log..." +echo "::: Writing hosts file to debug log..." echo "#######################################" >> $DEBUG_LOG echo "################ Hosts ################" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -219,11 +219,11 @@ then echo >> $DEBUG_LOG else echo "No hosts file found!" >> $DEBUG_LOG - echo "No hosts file found!" + printf ":::\tNo hosts file found!\n" fi ### PiHole application specific logging ### -echo "Writing whitelist to debug log..." +echo "::: Writing whitelist to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############## Whitelist ##############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -233,10 +233,10 @@ then echo >> $DEBUG_LOG else echo "No whitelist.txt file found!" >> $DEBUG_LOG - echo "No whitelist.txt file found!" + printf ":::\tNo whitelist.txt file found!\n" fi -echo "Writing blacklist to debug log..." +echo "::: Writing blacklist to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############## Blacklist ##############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -246,10 +246,10 @@ then echo >> $DEBUG_LOG else echo "No blacklist.txt file found!" >> $DEBUG_LOG - echo "No blacklist.txt file found!" + printf ":::\tNo blacklist.txt file found!\n" fi -echo "Writing adlists.list to debug log..." +echo "::: Writing adlists.list to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############ adlists.list #############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -259,14 +259,14 @@ then echo >> $DEBUG_LOG else echo "No adlists.list file found!" >> $DEBUG_LOG - echo "No adlists.list file found!" + printf ":::\tNo adlists.list file found!\n" fi # Continuously append the pihole.log file to the pihole_debug.log file function dumpPiHoleLog { trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT - echo -e "Writing current pihole traffic to debug log...\nTry loading any/all sites that you are having trouble with now... (Press ctrl+C to finish)" + echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo "#######################################" >> $DEBUG_LOG echo "############# pihole.log ##############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG @@ -278,13 +278,13 @@ function dumpPiHoleLog { done else echo "No pihole.log file found!" >> $DEBUG_LOG - echo "No pihole.log file found!" + printf ":::\tNo pihole.log file found!\n" fi } # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "Finshed debugging!" + echo "::: Finshed debugging!" } trap finalWork EXIT From 6145748bfb3e922068b51c4d97108cdd6cb825c8 Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 27 Mar 2016 20:36:31 -0500 Subject: [PATCH 115/311] Change single echo to printf to forrect \t interpretation --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 7656f963..d2c8e245 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -170,7 +170,7 @@ then echo >> $DEBUG_LOG else echo "No 01-pihole.conf file found!" >> $DEBUG_LOG - echo "::: No 01-pihole.conf file found\n" + printf ":::\tNo 01-pihole.conf file found\n" fi echo "::: Writing lighttpd.conf to debug log..." From c520c55ff4b7b5288cf5344fd2e0144abe018e98 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 10:24:13 -0500 Subject: [PATCH 116/311] Addressed UAT issues and moved scripts to /opt/pihole Symlinks now include the /etc/pihole scripts in the user's PATH. --- automated install/basic-install.sh | 32 +++++++++++++++++++++--------- automated install/uninstall.sh | 28 +++++++++++++++----------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 134ec3e2..ff4962b7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -97,7 +97,12 @@ backupLegacyPihole() { $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" - $SUDO mv /usr/local/bin/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod 1766 /opt/pihole + fi + $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" else : fi @@ -470,14 +475,23 @@ versionCheckDNSmasq(){ installScripts() { # Install the scripts from /etc/.pihole to their various locations $SUDO echo ":::" - $SUDO echo -n "::: Installing scripts..." - $SUDO cp /etc/.pihole/gravity.sh /usr/local/bin/gravity.sh - $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /usr/local/bin/chronometer.sh - $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /usr/local/bin/whitelist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /usr/local/bin/blacklist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /usr/local/bin/piholeLogFlush.sh - $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /usr/local/bin/updateDashboard.sh - $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh + $SUDO echo -n "::: Installing scripts to /opt/pihole..." + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod 1766 /opt/pihole + fi + $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh + $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh + $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/bin/blacklist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh + $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh + $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall}.sh + for f in /opt/pihole/*; do + $SUDO ln -s /opt/pihole/"$f" /usr/local/bin/"$f" + done $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index ffbf4246..a08a9900 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -43,19 +43,20 @@ spinner() function removeAndPurge { # Purge dependencies echo ":::" - dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + # Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common + dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common git curl unzip wget ) for i in "${dependencies[@]}"; do - if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" | grep -c "ok installed")" -eq 1 ]; then + if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then while true; do - read -rp "::: Do you wish to remove $i from your system? (y/n): " yn + read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn case $yn in - [Yy]* ) echo "::: Removing $i..."; $SUDO apt-get -y remove --purge "$i" > /dev/null & spinner $!; echo "DONE!"; break;; - [Nn]* ) echo "::: Skipping $i"; break;; - * ) echo "::: You must answer yes or no!";; + [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "DONE!\n"; break;; + [Nn]* ) printf ":::\tSkipping %s" "$i"; break;; + * ) printf "::: You must answer yes or no!";; esac done else - echo "IF FAILED ***" + printf ":::\tPackage %s not installed... Not removing.\n" "$i" fi done @@ -64,10 +65,10 @@ echo ":::" $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null # Take care of any additional package cleaning - echo "::: Auto removing remaining dependencies" - $SUDO apt-get -y autoremove &> /dev/null & spinner $!; echo "DONE!"; - echo "::: Auto cleaning remaining dependencies" - $SUDO apt-get -y autoclean &> /dev/null & spinner $!; echo "DONE!"; + printf "::: Auto removing remaining dependencies" + $SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "DONE!\n"; + printf "::: Auto cleaning remaining dependencies" + $SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "DONE!\n"; # Call removeNoPurge to remove PiHole specific files removeNoPurge @@ -113,21 +114,24 @@ function removeNoPurge { $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null + $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null $SUDO rm -rf /etc/.pihole/ &> /dev/null + $SUDO rm -rf /opt/pihole/ &> /dev/null echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n" printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n" + printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!/n" } ######### SCRIPT ########### echo "::: Preparing to remove packages, be sure that each may be safely removed depending on your operating system." echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)" while true; do - read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package)" yn + read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]" yn case $yn in [Yy]* ) removeAndPurge; break;; From f444c7d4a577ad3641458c1a024aab5251b82d28 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 12:21:49 -0500 Subject: [PATCH 117/311] Merge resolution --- automated install/basic-install.sh | 53 ------------------------------ 1 file changed, 53 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2d08f17d..870de00c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -63,13 +63,6 @@ else fi fi -### Nate 3/26/2016 - Why are we declaring upgrade here? It isn't global (nor is it used anywhere else) -# if [ -d "/etc/pihole" ]; then - # # Likely an existing install - # upgrade=true - # else - # upgrade=false -# fi ####### FUNCTIONS ########## spinner() @@ -124,17 +117,10 @@ welcomeDialogs() { verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=51200 -<<<<<<< HEAD - - 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) ->>>>>>> ScriptCleanup fi if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then @@ -389,16 +375,6 @@ setDNS(){ 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 -<<<<<<< HEAD - 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 -======= piholeDNS1=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') @@ -407,7 +383,6 @@ setDNS(){ fi if ! valid_ip "$piholeDNS2" && [ "$piholeDNS2" ]; then ->>>>>>> ScriptCleanup piholeDNS2=$strInvalid fi @@ -415,17 +390,6 @@ setDNS(){ echo "::: Cancel selected, exiting...." exit 1 fi -<<<<<<< HEAD - - 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 -======= 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 @@ -435,7 +399,6 @@ setDNS(){ fi if [[ $piholeDNS2 == "$strInvalid" ]]; then ->>>>>>> ScriptCleanup piholeDNS2="" fi @@ -709,19 +672,6 @@ 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 @@ -775,9 +725,6 @@ 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 a4fbccac9b011f19a627df62a1eba669b4e53c3b Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 12:53:21 -0500 Subject: [PATCH 118/311] Merge conflict resolution --- advanced/Scripts/blacklist.sh | 58 +++++++---------------------------- advanced/Scripts/whitelist.sh | 10 ------ 2 files changed, 11 insertions(+), 57 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 3fd50e83..23313d54 100644 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -51,19 +51,11 @@ fi function HandleOther(){ #check validity of domain -<<<<<<< HEAD - 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 -======= 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 ->>>>>>> ScriptCleanup domList=("${domList[@]}" $validDomain) fi } @@ -73,16 +65,9 @@ function PopBlacklistFile(){ if [[ ! -f $blacklist ]];then touch $blacklist fi - for dom in "${domList[@]}" -<<<<<<< HEAD - do - if $addmode; then - AddDomain $dom -======= - do + for dom in "${domList[@]}"; do if "$addmode"; then AddDomain "$dom" ->>>>>>> ScriptCleanup else RemoveDomain "$dom" fi @@ -134,43 +119,27 @@ function ModifyHostFile(){ numberOf=$($blacklist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" -<<<<<<< HEAD - 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 - cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - fi - -======= echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." if [[ -n $piholeIPv6 ]];then $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList - else + else $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - fi - ->>>>>>> ScriptCleanup + fi fi else - echo ":::" for dom in "${domToRemoveList[@]}" do #we need to remove the domains from the blacklist file and the host file - echo "::: $dom" - echo -n "::: removing from HOSTS file..." -<<<<<<< HEAD - 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 ->>>>>>> ScriptCleanup - echo " done!" - echo -n "::: removing from blackist.txt..." - echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist - echo " done!" + echo "::: $dom" + echo -n "::: removing from HOSTS file..." + 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 - fi + fi } @@ -199,13 +168,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; -<<<<<<< HEAD - "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; -======= "-q" | "--quiet" ) versbose=false;; * ) HandleOther "$var";; ->>>>>>> ScriptCleanup esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index a241505b..199c1bbe 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -51,13 +51,8 @@ fi function HandleOther(){ #check validity of domain -<<<<<<< HEAD - 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/') - -======= 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/') ->>>>>>> ScriptCleanup if [ -z "$validDomain" ]; then echo "::: $1 is not a valid argument or domain name" else @@ -186,13 +181,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; -<<<<<<< HEAD - "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; -======= "-q" | "--quiet" ) versbose=false;; * ) HandleOther "$var";; ->>>>>>> ScriptCleanup esac done From eaf89995ee9e4f76ea981bee41e45cece815170f Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 12:59:45 -0500 Subject: [PATCH 119/311] Merge conflict resolution --- automated install/basic-install.sh | 46 ------------------------------ 1 file changed, 46 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f5586508..870de00c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -117,17 +117,10 @@ welcomeDialogs() { verifyFreeDiskSpace() { # 25MB is the minimum space needed (20MB install + 5MB one day of logs.) requiredFreeBytes=51200 -<<<<<<< HEAD - - 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) ->>>>>>> ScriptCleanup-Dev fi if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then @@ -382,16 +375,6 @@ setDNS(){ 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 -<<<<<<< HEAD - 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 -======= piholeDNS1=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}') piholeDNS2=$(echo "$piholeDNS" | sed 's/[, \t]\+/,/g' | awk -F, '{print$2}') @@ -400,7 +383,6 @@ setDNS(){ fi if ! valid_ip "$piholeDNS2" && [ "$piholeDNS2" ]; then ->>>>>>> ScriptCleanup-Dev piholeDNS2=$strInvalid fi @@ -408,17 +390,6 @@ setDNS(){ echo "::: Cancel selected, exiting...." exit 1 fi -<<<<<<< HEAD - - 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 -======= 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 @@ -428,7 +399,6 @@ setDNS(){ fi if [[ $piholeDNS2 == "$strInvalid" ]]; then ->>>>>>> ScriptCleanup-Dev piholeDNS2="" fi @@ -702,19 +672,6 @@ 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 @@ -768,9 +725,6 @@ 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 f2150ee7e102ae55daef3607a7f8388e304ac526 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 13:07:51 -0500 Subject: [PATCH 120/311] Merge conflict resolution --- README.md | 12 +-------- advanced/Scripts/blacklist.sh | 49 +---------------------------------- advanced/Scripts/whitelist.sh | 11 -------- gravity.sh | 28 -------------------- 4 files changed, 2 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 99fb7547..c58d6820 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,5 @@ -<<<<<<< HEAD -# Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, Zero (with an Ethernet adapter), and also works on most Debian based distros! -======= # Automated Install -<<<<<<< HEAD -##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) ->>>>>>> PiholeDebug -======= -##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet/Wi-Fi adapter) ->>>>>>> ScriptCleanup ->>>>>>> ScriptCleanup-Dev +##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) 1. Install Raspbian on Raspberry Pi variants or a Debian based distribution on other hardware or virtual machines 2. Run the command below diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index c8a1cfd9..1780b8ec 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -51,19 +51,10 @@ fi function HandleOther(){ #check validity of domain -<<<<<<< HEAD - 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 -======= 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 ->>>>>>> ScriptCleanup-Dev domList=("${domList[@]}" $validDomain) fi } @@ -73,16 +64,9 @@ function PopBlacklistFile(){ if [[ ! -f $blacklist ]];then touch $blacklist fi -<<<<<<< HEAD - for dom in "${domList[@]}" - do - if $addmode; then - AddDomain $dom -======= for dom in "${domList[@]}"; do if "$addmode"; then AddDomain "$dom" ->>>>>>> ScriptCleanup-Dev else RemoveDomain "$dom" fi @@ -134,18 +118,6 @@ function ModifyHostFile(){ numberOf=$($blacklist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" -<<<<<<< HEAD - 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 - cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - fi - - fi - else - -======= echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." if [[ -n $piholeIPv6 ]];then $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList @@ -154,22 +126,10 @@ function ModifyHostFile(){ fi fi else ->>>>>>> ScriptCleanup-Dev echo ":::" - for dom in "${domToRemoveList[@]}" + for dom in "${domToRemoveList[@]}" do #we need to remove the domains from the blacklist file and the host file -<<<<<<< HEAD - echo "::: $dom" - echo -n "::: removing from HOSTS file..." - 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 - fi -======= echo "::: $dom" echo -n "::: removing from HOSTS file..." echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList @@ -179,8 +139,6 @@ function ModifyHostFile(){ echo " done!" done fi ->>>>>>> ScriptCleanup-Dev - } function Reload() { @@ -208,13 +166,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; -<<<<<<< HEAD - "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; -======= "-q" | "--quiet" ) versbose=false;; * ) HandleOther "$var";; ->>>>>>> ScriptCleanup-Dev esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 3a30d11a..5d732ddc 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -51,13 +51,7 @@ fi function HandleOther(){ #check validity of domain -<<<<<<< HEAD - 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/') - -======= 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/') - ->>>>>>> ScriptCleanup-Dev if [ -z "$validDomain" ]; then echo "::: $1 is not a valid argument or domain name" else @@ -186,13 +180,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; -<<<<<<< HEAD - "-q" | "--quiet" ) versbose=false;; - * ) HandleOther $var;; -======= "-q" | "--quiet" ) versbose=false;; * ) HandleOther "$var";; ->>>>>>> ScriptCleanup-Dev esac done diff --git a/gravity.sh b/gravity.sh index a8ac7029..531ae4c1 100755 --- a/gravity.sh +++ b/gravity.sh @@ -169,22 +169,12 @@ function gravity_transport() { fi # Silently curl url -<<<<<<< HEAD curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer # Check for list updates gravity_patternCheck $patternBuffer -======= -<<<<<<< HEAD - curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer - # Check for list updates - gravity_patternCheck $patternBuffer -======= curl -s "$cmd_ext" "$heisenbergCompensator" -A "$agent" "$url" > "$patternBuffer" # Check for list updates gravity_patternCheck "$patternBuffer" ->>>>>>> ScriptCleanup ->>>>>>> ScriptCleanup-Dev - # Cleanup rm -f "$patternBuffer" } @@ -269,16 +259,7 @@ function gravity_Whitelist() { echo " done!" echo -n "::: Running whitelist script to update HOSTS file...." -<<<<<<< HEAD - $whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $! - -<<<<<<< HEAD -======= -======= $whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $! - ->>>>>>> ScriptCleanup ->>>>>>> ScriptCleanup-Dev numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s echo " $numWhitelisted domain${plural} whitelisted!" @@ -303,16 +284,7 @@ function gravity_hostFormat() { if [[ -n $piholeIPv6 ]];then #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 -<<<<<<< HEAD - cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc - -<<<<<<< HEAD -======= -======= $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc - ->>>>>>> ScriptCleanup ->>>>>>> ScriptCleanup-Dev 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! From bed869b08ef467984cb869cbf01c4f4724453de1 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 16:02:36 -0500 Subject: [PATCH 121/311] .DS_Store banished! --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e43b0f98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store From 80f4bf94759643e3add582982d412f9bb080e777 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 16:20:23 -0500 Subject: [PATCH 122/311] Bug fixes Fixed DONE! to done! Fixed symlinking user scripts Fixed /n to \n --- .gitignore | 1 + automated install/basic-install.sh | 7 ++++--- automated install/uninstall.sh | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e43b0f98 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 870de00c..dd5aa3a1 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -472,18 +472,19 @@ installScripts() { if [ ! -d /opt/pihole ]; then $SUDO mkdir /opt/pihole $SUDO chown "$USER":root /opt/pihole - $SUDO chmod 1766 /opt/pihole + $SUDO chmod u+srwx /opt/pihole fi $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/bin/blacklist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall}.sh for f in /opt/pihole/*; do - $SUDO ln -s /opt/pihole/"$f" /usr/local/bin/"$f" + filename=${f##*/} + $SUDO ln -s /opt/pihole/"$filename" /usr/local/bin/"$filename" done $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index a08a9900..ef82fa07 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -50,7 +50,7 @@ echo ":::" while true; do read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn case $yn in - [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "DONE!\n"; break;; + [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "done!\n"; break;; [Nn]* ) printf ":::\tSkipping %s" "$i"; break;; * ) printf "::: You must answer yes or no!";; esac @@ -65,10 +65,10 @@ echo ":::" $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null # Take care of any additional package cleaning - printf "::: Auto removing remaining dependencies" - $SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "DONE!\n"; - printf "::: Auto cleaning remaining dependencies" - $SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "DONE!\n"; + printf "::: Auto removing remaining dependencies..." + $SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "done!\n"; + printf "::: Auto cleaning remaining dependencies..." + $SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "done!\n"; # Call removeNoPurge to remove PiHole specific files removeNoPurge @@ -124,14 +124,14 @@ function removeNoPurge { printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n" printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n" - printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!/n" + printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!\n" } ######### SCRIPT ########### echo "::: Preparing to remove packages, be sure that each may be safely removed depending on your operating system." echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)" while true; do - read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]" yn + read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn case $yn in [Yy]* ) removeAndPurge; break;; From 138aeaf8c746714dfb8d5202d8404c0ba64c1649 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 16:25:12 -0500 Subject: [PATCH 123/311] Added uninstall.sh and updateDashboard.sh to be removed on uninstall from u/l/b --- automated install/uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index ef82fa07..941232ca 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -114,6 +114,8 @@ function removeNoPurge { $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null + $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null + $SUDO rm /usr/local/bin/uninstall.sh &> /dev/null $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null From 660e71f0320e61f4d1d3458d01bfbd627412e456 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 16:32:42 -0500 Subject: [PATCH 124/311] Added blacklist.sh to be removed on uninstall from u/l/b --- automated install/uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 941232ca..cef36dd6 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -112,6 +112,7 @@ function removeNoPurge { $SUDO rm /usr/local/bin/gravity.sh &> /dev/null $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null + $SUDO rm /usr/local/bin/blacklist.sh &> /dev/null $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null From 32dd594f06ecb3ca24a7881eeb8e890bcafedf9c Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 17:08:19 -0500 Subject: [PATCH 125/311] Check if lighttpd has been uninstalled before removing conf files If is still installed, then restore the original lighttpd.conf file. --- automated install/uninstall.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index cef36dd6..786e8cea 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -107,8 +107,13 @@ function removeNoPurge { fi echo "::: Removing config files and scripts..." - $SUDO rm -rf /etc/lighttpd/ &> /dev/null - $SUDO rm /var/log/pihole.log &> /dev/null + if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then + $SUDO rm -rf /etc/lighttpd/ &> /dev/null + else + if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then + $SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf + fi + fi $SUDO rm /usr/local/bin/gravity.sh &> /dev/null $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null From 76ea1962bed05baeee618e6bfe911d12775f6144 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:31:21 -0500 Subject: [PATCH 126/311] Controller script, pihole.sh added Syntax changes for user output to be consistent --- advanced/Scripts/blacklist.sh | 20 +++---- advanced/Scripts/chronometer.sh | 16 +++--- advanced/Scripts/whitelist.sh | 18 +++--- pihole.sh | 98 +++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 27 deletions(-) create mode 100644 pihole.sh diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 1780b8ec..158de7e2 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -11,15 +11,15 @@ # (at your option) any later version. if [[ $# = 0 ]]; then - echo "Immediately blacklists one or more domains in the hosts file" - echo " " - echo "Usage: blacklist.sh domain1 [domain2 ...]" - echo " " - echo "Options:" - echo " -d, --delmode Remove domains from the blacklist" - echo " -nr, --noreload Update blacklist without refreshing dnsmasq" - echo " -f, --force Force updating of the hosts files, even if there are no changes" - echo " -q, --quiet output is less verbose" + echo "::: Immediately blacklists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: pihole.sh -b domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the blacklist" + echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" exit 1 fi @@ -53,7 +53,7 @@ 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 + echo "::: $1 is not a valid argument or domain name" else domList=("${domList[@]}" $validDomain) fi diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 64b87025..326ec2b0 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -118,14 +118,14 @@ function normalChrono(){ } function displayHelp(){ - echo "Displays stats about your piHole!" - echo " " - echo "Usage: chronometer.sh [optional:-j]" - echo "Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" - echo " " - echo "Options:" - echo " -j, --json output stats as JSON formatted string" - echo " -h, --help display this help text" + echo "::: Displays stats about your piHole!" + echo ":::" + echo "::: Usage: pihole.sh -c [optional:-j]" + echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" + echo ":::" + echo "::: Options:" + echo "::: -j, --json output stats as JSON formatted string" + echo "::: -h, --help display this help text" exit 1 } diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 5d732ddc..fa2379c6 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -11,15 +11,15 @@ # (at your option) any later version. if [[ $# = 0 ]]; then - echo "Immediately whitelists one or more domains in the hosts file" - echo " " - echo "Usage: whitelist.sh domain1 [domain2 ...]" - echo " " - echo "Options:" - echo " -d, --delmode Remove domains from the whitelist" - echo " -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo " -f, --force Force updating of the hosts files, even if there are no changes" - echo " -q, --quiet output is less verbose" + echo "::: Immediately whitelists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: pihole -w domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the whitelist" + echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" exit 1 fi diff --git a/pihole.sh b/pihole.sh new file mode 100644 index 00000000..3a2ce22c --- /dev/null +++ b/pihole.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Pi-hole: A black hole for Internet advertisements +# (c) 2015, 2016 by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# Controller for all pihole scripts and functions. +# +# 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. + +# Must be root to use this tool +if [[ $EUID -eq 0 ]];then + echo "::: You are root." +else + echo "::: Sudo will be used for this tool." + # Check if it is actually installed + # If it isn't, exit because the unnstall cannot complete + if [[ $(dpkg-query -s sudo) ]];then + export SUDO="sudo" + else + echo "::: Please install sudo or run this as root." + exit 1 + fi +fi + +function whitelistFunc { + shift + $SUDO /opt/pihole/whitelist.sh "$@" + exit 1 +} + +function blacklistFunc { + shift + $SUDO /opt/pihole/blacklist.sh "$@" + exit 1 +} + +function debugFunc { + $SUDO /opt/pihole/piholeDebug.sh + exit 1 +} + +function flushFunc { + $SUDO /opt/pihole/piholeLogFlush.sh + exit 1 +} + +function updateDashboardFunc { + $SUDO /opt/pihole/updateDashboard.sh + exit 1 +} + +function setupLCDFunction { + $SUDO /opt/pihole/setupLCD.sh + exit 1 +} + +function chronometerFunc { + $SUDO /opt/pihole/chronometer.sh + exit 1 +} + +function helpFunc { + echo "::: Control all PiHole specific functions!" + echo ":::" + echo "::: Usage: pihole.sh [options]" + printf ":::\tAdd -h after -w, -b, or -c for more information on usage\n" + echo ":::" + echo "::: Options:" + printf "::: -w, --whitelist\t\tWhitelist domains\n" + printf "::: -b, --blacklist\t\tBlacklist domains\n" + printf "::: -d, --debug\t\tStart a debugging session if having trouble\n" + printf "::: -f, --flush\t\tFlush the pihole.log file\n" + printf "::: -u, --updateDashboard\t\tUpdate the web dashboard manually\n" + printf "::: -s, --setupLCD\t\tAutomatically configures the Pi to use the 2.8 LCD screen to display stats on it\n" + printf "::: -c, --chronometer\t\tCalculates stats and displays to an LCD\n" + printf "::: -h, --help\t\tShow this help dialog\n" + exit 1 +} + +if [[ $# = 0 ]]; then + helpFunc +fi + +# Handle redirecting to specific functions based on arguments +case "$1" in +"-w" | "--whitelist" ) whitelistFunc "$@";; +"-b" | "--blacklist" ) blacklistFunc "$@";; +"-d" | "--debug" ) debugFunc;; +"-f" | "--flush" ) flushFunc;; +"-u" | "--updateDashboard" ) updateDashboardFunc;; +"-s" | "--setupLCD" ) setupLCDFunction;; +"-c" | "--chronometer" ) chronometerFunc;; +"-h" | "--help" ) helpFunc;; +* ) helpFunc;; +esac From fee55fa6422a840d1f6b7957492e365ba325d287 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:37:49 -0500 Subject: [PATCH 127/311] Added gravity.sh to the list of options --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/chronometer.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- pihole.sh | 21 +++++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 158de7e2..e370142b 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -13,7 +13,7 @@ if [[ $# = 0 ]]; then echo "::: Immediately blacklists one or more domains in the hosts file" echo ":::" - echo "::: Usage: pihole.sh -b domain1 [domain2 ...]" + echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" echo ":::" echo "::: Options:" echo "::: -d, --delmode Remove domains from the blacklist" diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 326ec2b0..d1cef601 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -120,7 +120,7 @@ function normalChrono(){ function displayHelp(){ echo "::: Displays stats about your piHole!" echo ":::" - echo "::: Usage: pihole.sh -c [optional:-j]" + echo "::: Usage: sudo pihole.sh -c [optional:-j]" echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" echo ":::" echo "::: Options:" diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index fa2379c6..8aec77af 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -13,7 +13,7 @@ if [[ $# = 0 ]]; then echo "::: Immediately whitelists one or more domains in the hosts file" echo ":::" - echo "::: Usage: pihole -w domain1 [domain2 ...]" + echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" echo ":::" echo "::: Options:" echo "::: -d, --delmode Remove domains from the whitelist" diff --git a/pihole.sh b/pihole.sh index 3a2ce22c..f730c210 100644 --- a/pihole.sh +++ b/pihole.sh @@ -61,6 +61,10 @@ function chronometerFunc { $SUDO /opt/pihole/chronometer.sh exit 1 } +function gravityFunc { + $SUDO /opt/pihole/gravity.sh + exit 1 +} function helpFunc { echo "::: Control all PiHole specific functions!" @@ -69,14 +73,15 @@ function helpFunc { printf ":::\tAdd -h after -w, -b, or -c for more information on usage\n" echo ":::" echo "::: Options:" - printf "::: -w, --whitelist\t\tWhitelist domains\n" - printf "::: -b, --blacklist\t\tBlacklist domains\n" - printf "::: -d, --debug\t\tStart a debugging session if having trouble\n" - printf "::: -f, --flush\t\tFlush the pihole.log file\n" - printf "::: -u, --updateDashboard\t\tUpdate the web dashboard manually\n" - printf "::: -s, --setupLCD\t\tAutomatically configures the Pi to use the 2.8 LCD screen to display stats on it\n" - printf "::: -c, --chronometer\t\tCalculates stats and displays to an LCD\n" - printf "::: -h, --help\t\tShow this help dialog\n" + echo "::: -w, --whitelist Whitelist domains" + echo "::: -b, --blacklist Blacklist domains" + echo "::: -d, --debug Start a debugging session if having trouble" + echo "::: -f, --flush Flush the pihole.log file" + echo "::: -u, --updateDashboard Update the web dashboard manually" + echo "::: -g, --updateGravity Update the list of ad-serving domains" + echo "::: -s, --setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, --chronometer Calculates stats and displays to an LCD" + echo "::: -h, --help Show this help dialog" exit 1 } From 00b65abd09cd3eade45475e4138574554b725221 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:44:54 -0500 Subject: [PATCH 128/311] Minor changes to reflect new tool usage Removed symlink of scripts to u/l/b Added copy for setupLCD to /opt/pihole/ New spinner added to gravity.sh to reflect new spinner in basic-install.sh and uninstall.sh --- automated install/basic-install.sh | 11 ++++------- automated install/uninstall.sh | 8 -------- gravity.sh | 25 +++++++++++++------------ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index dd5aa3a1..3597f757 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -93,8 +93,8 @@ backupLegacyPihole() { if [ ! -d /opt/pihole ]; then $SUDO mkdir /opt/pihole $SUDO chown "$USER":root /opt/pihole - $SUDO chmod 1766 /opt/pihole - fi + $SUDO chmod u+srwx /opt/pihole + fi $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" else : @@ -481,11 +481,8 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall}.sh - for f in /opt/pihole/*; do - filename=${f##*/} - $SUDO ln -s /opt/pihole/"$filename" /usr/local/bin/"$filename" - done + $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 786e8cea..0ac06521 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -114,14 +114,6 @@ function removeNoPurge { $SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf fi fi - $SUDO rm /usr/local/bin/gravity.sh &> /dev/null - $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null - $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null - $SUDO rm /usr/local/bin/blacklist.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null - $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null - $SUDO rm /usr/local/bin/uninstall.sh &> /dev/null $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null diff --git a/gravity.sh b/gravity.sh index 531ae4c1..c7b60680 100755 --- a/gravity.sh +++ b/gravity.sh @@ -75,18 +75,19 @@ if [[ -r $piholeDir/pihole.conf ]];then fi -spinner(){ - local pid=$1 - - spin='-\|/' - i=0 - while $SUDO kill -0 "$pid" 2>/dev/null - do - i=$(( (i+1) %4 )) - printf "\b%s" "${spin:$i:1}" - sleep .1 - done - printf "\b" +spinner() +{ + local pid=$1 + local delay=0.50 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + printf " \b\b\b\b" } ########################### From 86dd4dd7849e3d7af7a38fd44e1058814076bc65 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:45:55 -0500 Subject: [PATCH 129/311] New spinner for gravity.sh Spinner in gravity.sh now matches basic-install.sh and uninstall.sh --- gravity.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gravity.sh b/gravity.sh index 3434ac9c..ed94448b 100755 --- a/gravity.sh +++ b/gravity.sh @@ -75,18 +75,19 @@ if [[ -r $piholeDir/pihole.conf ]];then fi -spinner(){ - local pid=$1 - - spin='-\|/' - i=0 - while $SUDO kill -0 "$pid" 2>/dev/null - do - i=$(( (i+1) %4 )) - printf "\b%s" "${spin:$i:1}" - sleep .1 - done - printf "\b" +spinner() +{ + local pid=$1 + local delay=0.50 + local spinstr='|/-\' + while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" + done + printf " \b\b\b\b" } ########################### From 456eee05f23b1e8d6147fc45e72a835bc611e1fd Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 28 Mar 2016 18:55:37 -0500 Subject: [PATCH 130/311] Added pihole.sh to /usr/local/bin Uninstall.sh will handle removing the file --- automated install/basic-install.sh | 1 + automated install/uninstall.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3597f757..f490aabd 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -483,6 +483,7 @@ installScripts() { $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh + $SUDO cp /etc/.pihole/pihole.sh /usr/local/bin/pihole.sh $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 0ac06521..8c19709f 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -119,6 +119,7 @@ function removeNoPurge { $SUDO rm -rf /etc/pihole/ &> /dev/null $SUDO rm -rf /etc/.pihole/ &> /dev/null $SUDO rm -rf /opt/pihole/ &> /dev/null + $SUDO rm /usr/local/bin/pihole.sh &> /dev/null echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" From 45cb9a2e800118196187c45627083b5a7f1847da Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 28 Mar 2016 22:51:54 -0400 Subject: [PATCH 131/311] fix template team link --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 071fdf89..b289a1c0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,4 +8,4 @@ Changes proposed in this pull request: - -@pihole/gravity +@pi-hole/gravity From fb5bc16c837027c90c0b5ffbcb844ea93746f61a Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 29 Mar 2016 00:14:56 -0500 Subject: [PATCH 132/311] Call gravity.sh in it's new location --- automated install/basic-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f490aabd..ae0a831f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -656,8 +656,7 @@ runGravity() { fi #Don't run as SUDO, this was causing issues echo "::: Running gravity.sh" - - /usr/local/bin/gravity.sh + /opt/pihole/gravity.sh } setUser(){ From 31fc2bfeb7753ac6137d2e61425d8df6dae22d5c Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 29 Mar 2016 00:25:40 -0500 Subject: [PATCH 133/311] Modified gravity.sh to point to new file locations and fixed permission issue --- gravity.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index c7b60680..6184ea72 100755 --- a/gravity.sh +++ b/gravity.sh @@ -31,8 +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 +whitelistScript=/opt/pihole/whitelist.sh +blacklistScript=/opt/pihole/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 @@ -129,12 +129,12 @@ function gravity_collapse() { # Temporary hack to allow non-root access to pihole directory # Will update later, needed for existing installs, new installs should # create this directory as non-root - $SUDO chmod 777 $piholeDir find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! - echo "." + echo ":::" else echo -n "::: Creating pihole directory..." mkdir $piholeDir & spinner $! + $SUDO chmod 777 $piholeDir echo " done!" fi } From 7014b5a150247ea832182c5b67efbc41aff456b3 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 29 Mar 2016 17:45:00 -0400 Subject: [PATCH 134/311] Reverted password for web interface Work will continue in the secure-web-interface branch --- automated install/basic-install.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 97b47dad..0b2513da 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -658,19 +658,6 @@ 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 @@ -721,9 +708,6 @@ 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 ec4d2d65a656e0bf479a99919cb740a8fa98bb27 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Mar 2016 19:49:39 -0500 Subject: [PATCH 135/311] PromoFaux request: Detailed adlists.list output Now tells user (and logs to pihole_Debug.log) that the adlists.default file is in use --- advanced/Scripts/piholeDebug.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index d2c8e245..145a602c 100644 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -258,8 +258,8 @@ then cat "$ADLISTSFILE" >> $DEBUG_LOG echo >> $DEBUG_LOG else - echo "No adlists.list file found!" >> $DEBUG_LOG - printf ":::\tNo adlists.list file found!\n" + echo "No adlists.list file found... using adlists.default!" >> $DEBUG_LOG + printf ":::\tNo adlists.list file found... using adlists.default!\n" fi From 5f7c11f4959e1ca4dca1c0111d4401600522a264 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Mar 2016 19:51:09 -0500 Subject: [PATCH 136/311] Sudo added to ifconfig to ensure it runs if debug not run as root --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 145a602c..e9d95234 100644 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -118,7 +118,7 @@ function testNslookup { ### Check Pi internet connections ### # Log the IP addresses of this Pi -IPADDR=$(ifconfig | perl -nle 's/dr:(\S+)/print $1/e') +IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e') echo "::: Writing local IPs to debug log" echo "IP Addresses of this Pi:" >> $DEBUG_LOG echo "$IPADDR" >> $DEBUG_LOG From 45f24c8a85edf0162530e785e9b0a2bfea3318a4 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Mar 2016 19:56:11 -0500 Subject: [PATCH 137/311] Readded `cat`s that were originally considered UUOC --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 0e13cb95..ddc177a0 100755 --- a/gravity.sh +++ b/gravity.sh @@ -222,7 +222,7 @@ function gravity_Schwarzchild() { truncate -s 0 $piholeDir/$matterandlight & spinner $! for i in "${activeDomains[@]}" do - "$i" |tr -d '\r' >> $piholeDir/$matterandlight + cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight done echo " done!" @@ -282,12 +282,12 @@ function gravity_hostFormat() { if [[ -n $piholeIPv6 ]];then #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 - $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $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! echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc - $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc + cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc fi # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp $piholeDir/$accretionDisc $adList From 2625d9f7fe52fce75a19ba18964e93c99d6a9ea9 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Mar 2016 20:09:19 -0500 Subject: [PATCH 138/311] Made piholeDebug.sh +x --- advanced/Scripts/piholeDebug.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 advanced/Scripts/piholeDebug.sh diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh old mode 100644 new mode 100755 From 4b0a7c22524e0a7b9af1ed92e0a90c4f21f7179b Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Mar 2016 20:23:24 -0500 Subject: [PATCH 139/311] Added 01-pihole.conf to be removed on uninstall regardless of removing dnsmasq --- automated install/uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 786e8cea..44c40791 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -114,6 +114,7 @@ function removeNoPurge { $SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf fi fi + $SUDO rm /usr/local/bin/gravity.sh &> /dev/null $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null @@ -123,6 +124,7 @@ function removeNoPurge { $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null $SUDO rm /usr/local/bin/uninstall.sh &> /dev/null $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null + $SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null $SUDO rm -rf /etc/.pihole/ &> /dev/null From 777676b5258cfc8fd26105f21907ff2662be1c9b Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 31 Mar 2016 20:33:15 -0500 Subject: [PATCH 140/311] Made uninstall.sh and pihole.sh executable. --- automated install/uninstall.sh | 0 pihole.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 automated install/uninstall.sh mode change 100644 => 100755 pihole.sh diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh old mode 100644 new mode 100755 diff --git a/pihole.sh b/pihole.sh old mode 100644 new mode 100755 From 7b8fa3b922022af237c28cd82040ccd68de9b4d8 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 1 Apr 2016 01:11:59 -0500 Subject: [PATCH 141/311] Permissions changed for /etc/pihole and cleaned up some output --- advanced/pihole.cron | 2 +- gravity.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 83b431a4..9d390143 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -10,7 +10,7 @@ # (at your option) any later version. # Pi-hole: Update the ad sources once a week on Sunday at 01:59 -# Download any updates from the ad lists +# Download any updates from the adlists 59 1 * * 7 root /usr/local/bin/gravity.sh # Pi-hole: Update the Web interface shortly after gravity runs diff --git a/gravity.sh b/gravity.sh index ddc177a0..e541184f 100755 --- a/gravity.sh +++ b/gravity.sh @@ -130,8 +130,8 @@ function gravity_collapse() { # Will update later, needed for existing installs, new installs should # create this directory as non-root $SUDO chmod 777 $piholeDir - find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! - echo "." + $SUDO chown root:root $piholeDir + echo "..." else echo -n "::: Creating pihole directory..." mkdir $piholeDir & spinner $! @@ -246,7 +246,7 @@ function gravity_Whitelist() { echo ":::" # 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..." + echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..." urls=() for url in "${sources[@]}" From cf01b5a00245e8cedd0fd702ac02dd665a77b070 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 1 Apr 2016 12:17:05 -0500 Subject: [PATCH 142/311] Readded `cat` calls to fix permission issue --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 1780b8ec..75bdcd19 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -115,7 +115,7 @@ function ModifyHostFile(){ if $addmode; then #add domains to the hosts file if [[ -r $blacklist ]];then - numberOf=$($blacklist | sed '/^\s*$/d' | wc -l) + numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 5d732ddc..1479c62a 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -120,7 +120,7 @@ function ModifyHostFile(){ #remove domains in from hosts file if [[ -r $whitelist ]];then # Remove whitelist entries - numberOf=$($whitelist | sed '/^\s*$/d' | wc -l) + numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..." From 0fbf72bb095b82940182404aef68e3482aaf7e4c Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Fri, 1 Apr 2016 20:19:47 -0400 Subject: [PATCH 143/311] Change dummy domain and show device's hostname in ping * Change dummy domain Allows users to access Pi-hole console with my.pi-hole.net instead of the IP address * Cleaned up formatting * Put device hostname at the top of the list Changed my.pi-hole.net to pi.hole and placed it under the device hostname. This way, ping will return the device hostname but you still can access the web interface with pi.hole/admin --- gravity.sh | 88 +++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/gravity.sh b/gravity.sh index e541184f..bc5f53f6 100755 --- a/gravity.sh +++ b/gravity.sh @@ -16,14 +16,14 @@ 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 + # 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 + else echo "::: Please install sudo or run this script as root." - exit 1 - fi + exit 1 + fi fi piholeIPfile=/tmp/piholeIP @@ -50,9 +50,6 @@ if [[ -f $piholeIPv6file ]];then piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') fi - - - # Variables for various stages of downloading and formatting the list ## Nate 3/26/2016 - Commented unused variables basename=pihole @@ -74,9 +71,7 @@ if [[ -r $piholeDir/pihole.conf ]];then . $piholeDir/pihole.conf fi - -spinner() -{ +spinner() { local pid=$1 local delay=0.50 local spinstr='|/-\' @@ -112,7 +107,7 @@ function gravity_collapse() { else #no custom file found, use defaults! echo -n "::: No custom adlist file detected, reading from default file..." - sources=() + sources=() while read -r line; do #Do not read commented out or blank lines if [[ $line = \#* ]] || [[ ! $line ]]; then @@ -179,7 +174,7 @@ function gravity_transport() { # spinup - main gravity function function gravity_spinup() { - echo "::: " + echo "::: " # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do @@ -198,17 +193,17 @@ function gravity_spinup() { # Use a case statement to download lists that need special cURL commands # to complete properly and reset the user agent when required case "$domain" in - "adblock.mahakala.is") - agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' - cmd_ext="-e http://forum.xda-developers.com/" - ;; + "adblock.mahakala.is") + agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' + cmd_ext="-e http://forum.xda-developers.com/" + ;; - "pgl.yoyo.org") - cmd_ext="-d mimetype=plaintext -d hostformat=hosts" - ;; + "pgl.yoyo.org") + cmd_ext="-d mimetype=plaintext -d hostformat=hosts" + ;; - # Default is a simple request - *) cmd_ext="" + # Default is a simple request + *) cmd_ext="" esac gravity_transport "$url" "$cmd_ext" "$agent" done @@ -216,7 +211,7 @@ function gravity_spinup() { # Schwarzchild - aggregate domains to one list and add blacklisted domains function gravity_Schwarzchild() { - echo "::: " + 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 $! @@ -225,10 +220,8 @@ function gravity_Schwarzchild() { cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight done echo " done!" - } - function gravity_Blacklist(){ # Append blacklist entries if they exist echo -n "::: Running blacklist script to update HOSTS file...." @@ -236,14 +229,11 @@ function gravity_Blacklist(){ numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s - echo " $numBlacklisted domain${plural} blacklisted!" - - + echo " $numBlacklisted domain${plural} blacklisted!" } - function gravity_Whitelist() { - echo ":::" + echo ":::" # Prevent our sources from being pulled into the hole plural=; [[ "${sources[@]}" != "1" ]] && plural=s echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..." @@ -260,10 +250,7 @@ function gravity_Whitelist() { $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!" - - - + echo " $numWhitelisted domain${plural} whitelisted!" } function gravity_unique() { @@ -276,19 +263,21 @@ function gravity_unique() { } function gravity_hostFormat() { - # Format domain list as "192.168.x.x domain.com" + # Format domain list as "192.168.x.x domain.com" echo "::: Formatting domains into a HOSTS file..." - # If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols - if [[ -n $piholeIPv6 ]];then - #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! - echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc - cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc - fi + hostname=$( $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 hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin) + echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc + cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc + fi + # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp $piholeDir/$accretionDisc $adList } @@ -308,21 +297,18 @@ function gravity_blackbody() { } function gravity_advanced() { - - # Remove comments and print only the domain name # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo -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!" + echo " done!" numberOf=$(wc -l < $piholeDir/$supernova) echo "::: $numberOf domains being pulled in by gravity..." gravity_unique - } function gravity_reload() { From 12b5be239b9156ac8b09c33a03bc6362fa70df42 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Sat, 2 Apr 2016 13:31:49 +0000 Subject: [PATCH 144/311] Add Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 28e6791b..d9848502 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet/Wi-Fi adapter) +[![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + 1. Install Raspbian 2. Run the command below From d47fbbbe964fc6c1f8f8f96d44f11fe227c10b53 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 17:58:10 -0500 Subject: [PATCH 145/311] Mcat12 requests. Added bash-completion support --- advanced/bash-completion/pihole | 12 ++++++++++ automated install/basic-install.sh | 3 ++- automated install/uninstall.sh | 11 ++------- pihole.sh => pihole | 38 +++++++++++++++--------------- 4 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 advanced/bash-completion/pihole rename pihole.sh => pihole (60%) diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole new file mode 100644 index 00000000..026f008f --- /dev/null +++ b/advanced/bash-completion/pihole @@ -0,0 +1,12 @@ +_pihole() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer help" + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} +complete -F _pihole pihole \ No newline at end of file diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ff306d45..4c5afd86 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -483,7 +483,8 @@ installScripts() { $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh - $SUDO cp /etc/.pihole/pihole.sh /usr/local/bin/pihole.sh + $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole + $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash-completion.d/pihole $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 146d5dae..3577e8d6 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -115,21 +115,14 @@ function removeNoPurge { fi fi - $SUDO rm /usr/local/bin/gravity.sh &> /dev/null - $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null - $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null - $SUDO rm /usr/local/bin/blacklist.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null - $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null - $SUDO rm /usr/local/bin/uninstall.sh &> /dev/null $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null $SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null $SUDO rm -rf /var/log/*pihole* &> /dev/null $SUDO rm -rf /etc/pihole/ &> /dev/null $SUDO rm -rf /etc/.pihole/ &> /dev/null $SUDO rm -rf /opt/pihole/ &> /dev/null - $SUDO rm /usr/local/bin/pihole.sh &> /dev/null + $SUDO rm /usr/local/bin/pihole &> /dev/null + $SUDO rm /etc/bash-completion.d/pihole echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" diff --git a/pihole.sh b/pihole similarity index 60% rename from pihole.sh rename to pihole index f730c210..9944c0fa 100755 --- a/pihole.sh +++ b/pihole @@ -16,7 +16,7 @@ if [[ $EUID -eq 0 ]];then else echo "::: Sudo will be used for this tool." # Check if it is actually installed - # If it isn't, exit because the unnstall cannot complete + # If it isn't, exit because the pihole cannot be invoked without privileges. if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else @@ -70,18 +70,18 @@ function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" echo "::: Usage: pihole.sh [options]" - printf ":::\tAdd -h after -w, -b, or -c for more information on usage\n" + printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo ":::" echo "::: Options:" - echo "::: -w, --whitelist Whitelist domains" - echo "::: -b, --blacklist Blacklist domains" - echo "::: -d, --debug Start a debugging session if having trouble" - echo "::: -f, --flush Flush the pihole.log file" - echo "::: -u, --updateDashboard Update the web dashboard manually" - echo "::: -g, --updateGravity Update the list of ad-serving domains" - echo "::: -s, --setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, --chronometer Calculates stats and displays to an LCD" - echo "::: -h, --help Show this help dialog" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" exit 1 } @@ -91,13 +91,13 @@ fi # Handle redirecting to specific functions based on arguments case "$1" in -"-w" | "--whitelist" ) whitelistFunc "$@";; -"-b" | "--blacklist" ) blacklistFunc "$@";; -"-d" | "--debug" ) debugFunc;; -"-f" | "--flush" ) flushFunc;; -"-u" | "--updateDashboard" ) updateDashboardFunc;; -"-s" | "--setupLCD" ) setupLCDFunction;; -"-c" | "--chronometer" ) chronometerFunc;; -"-h" | "--help" ) helpFunc;; +"-w" | "whitelist" ) whitelistFunc "$@";; +"-b" | "blacklist" ) blacklistFunc "$@";; +"-d" | "debug" ) debugFunc;; +"-f" | "flush" ) flushFunc;; +"-u" | "-updateDashboard" ) updateDashboardFunc;; +"-s" | "setupLCD" ) setupLCDFunction;; +"-c" | "chronometer" ) chronometerFunc;; +"-h" | "help" ) helpFunc;; * ) helpFunc;; esac From 447af208b3fbcda7d7354f433372ae334d789cbf Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 17:59:59 -0500 Subject: [PATCH 146/311] Fixed missing `cp` of `piholeDebug.sh` to /opt/pihole --- automated install/basic-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index deaa3762..c97fdb9c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -478,6 +478,7 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh From e97755eb91533b120d43ecdba762cab13d81ec39 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 2 Apr 2016 19:28:30 -0400 Subject: [PATCH 147/311] Fix missing cats --- advanced/Scripts/blacklist.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 75bdcd19..5d23eb49 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -120,9 +120,9 @@ function ModifyHostFile(){ echo ":::" echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." if [[ -n $piholeIPv6 ]];then - $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList + cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList else - $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList + cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList fi fi else From 75f1969bd2eafd4241249b5b76446792261b4b44 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 18:39:09 -0500 Subject: [PATCH 148/311] Set executable permissions of `pihole` and changed installer to invoke sudo for gravity.sh. Note: We invoke gravity.sh with sudo in other places, so ignore the removed comment. --- 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 4c5afd86..c984c640 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -484,6 +484,7 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole + $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash-completion.d/pihole $SUDO echo " done." } @@ -655,9 +656,8 @@ runGravity() { echo "::: Cleaning up previous install (preserving whitelist/blacklist)" $SUDO rm /etc/pihole/list.* fi - #Don't run as SUDO, this was causing issues echo "::: Running gravity.sh" - /opt/pihole/gravity.sh + $SUDO /opt/pihole/gravity.sh } setUser(){ From 3dff7e80fc8259787fec387c1617a051f947c1b2 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 18:52:03 -0500 Subject: [PATCH 149/311] Fixed path to /etc/bash_completion.d/ --- automated install/basic-install.sh | 2 +- automated install/uninstall.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1b576049..da7abbaf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -486,7 +486,7 @@ installScripts() { $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole - $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash-completion.d/pihole + $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 3577e8d6..de950a48 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -122,7 +122,7 @@ function removeNoPurge { $SUDO rm -rf /etc/.pihole/ &> /dev/null $SUDO rm -rf /opt/pihole/ &> /dev/null $SUDO rm /usr/local/bin/pihole &> /dev/null - $SUDO rm /etc/bash-completion.d/pihole + $SUDO rm /etc/bash_completion.d/pihole echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" From 1a2046a7ebc1104e6d02d29b03ddeac215115585 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 19:20:54 -0500 Subject: [PATCH 150/311] Added uninstall option to `pihole` command. Minor fixes --- advanced/Scripts/chronometer.sh | 4 ++-- automated install/basic-install.sh | 5 +++-- pihole | 23 ++++++++++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index d1cef601..58bf300b 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -35,7 +35,7 @@ function CalcBlockedDomains(){ function CalcQueriesToday(){ if [ -e "$piLog" ];then - queriesToday=$("$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l) + queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l) else queriesToday="Err." fi @@ -43,7 +43,7 @@ function CalcQueriesToday(){ function CalcblockedToday(){ if [ -e "$piLog" ] && [ -e "$gravity" ];then - blockedToday=$($piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) + blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) else blockedToday="Err." fi diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index da7abbaf..ec6396a9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -118,9 +118,9 @@ verifyFreeDiskSpace() { # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) requiredFreeBytes=51200 - existingFreeBytes=`df -lk / 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` + existingFreeBytes=$(df -lk /dev 2>&1 | awk '{print $4}' | head -2 | tail -1) fi if [[ $existingFreeBytes -lt $requiredFreeBytes ]]; then @@ -487,6 +487,7 @@ installScripts() { $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole + $SUDO . /etc/bsah_completion.d/pihole $SUDO echo " done." } diff --git a/pihole b/pihole index 9944c0fa..943bbec3 100755 --- a/pihole +++ b/pihole @@ -52,6 +52,11 @@ function updateDashboardFunc { exit 1 } +function updateGravityFunc { + $SUDO /opt/pihole/gravish.sh + exit 1 +} + function setupLCDFunction { $SUDO /opt/pihole/setupLCD.sh exit 1 @@ -66,6 +71,11 @@ function gravityFunc { exit 1 } +function uninstallFunc { + $SUDO /opt/pihole/uninstall.sh + exit 1 +} + function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" @@ -82,6 +92,7 @@ function helpFunc { echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -h, help Show this help dialog" + echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } @@ -91,13 +102,15 @@ fi # Handle redirecting to specific functions based on arguments case "$1" in -"-w" | "whitelist" ) whitelistFunc "$@";; -"-b" | "blacklist" ) blacklistFunc "$@";; -"-d" | "debug" ) debugFunc;; -"-f" | "flush" ) flushFunc;; -"-u" | "-updateDashboard" ) updateDashboardFunc;; +"-w" | "whitelist" ) whitelistFunc "$@";; +"-b" | "blacklist" ) blacklistFunc "$@";; +"-d" | "debug" ) debugFunc;; +"-f" | "flush" ) flushFunc;; +"-u" | "updateDashboard" ) updateDashboardFunc;; +"-g" | "updateGravity" ) updateGravityFunc;; "-s" | "setupLCD" ) setupLCDFunction;; "-c" | "chronometer" ) chronometerFunc;; "-h" | "help" ) helpFunc;; +"uninstall" ) uninstallFunc;; * ) helpFunc;; esac From 37fa462db5fdfb0c868f749afe580c683b8754c4 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 19:24:19 -0500 Subject: [PATCH 151/311] Erraneous call to SUDO removed --- 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 ec6396a9..ec5fc90e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -487,7 +487,7 @@ installScripts() { $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole - $SUDO . /etc/bsah_completion.d/pihole + . /etc/bsah_completion.d/pihole $SUDO echo " done." } From 5d5d6c2c705419590f6179326f2c7a1ca074b1b6 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 19:31:26 -0500 Subject: [PATCH 152/311] handle case where parent directories do not exist --- 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 ec5fc90e..7d0db3cb 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -680,7 +680,7 @@ installPihole() { setUser $SUDO mkdir -p /etc/pihole/ if [ ! -d "/var/www/html" ]; then - $SUDO mkdir /var/www/html + $SUDO mkdir -p /var/www/html fi $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html From 71133f6b5935eb26308861cfce19dae1ba536f55 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 19:42:33 -0500 Subject: [PATCH 153/311] Spelling error fix... --- 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 7d0db3cb..f73de585 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -487,7 +487,7 @@ installScripts() { $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole - . /etc/bsah_completion.d/pihole + . /etc/bash_completion.d/pihole $SUDO echo " done." } From 7f9410fd34f0db5e82d49b4f27991af587a4530a Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 19:45:44 -0500 Subject: [PATCH 154/311] Added uninstall option to bash-completion --- advanced/bash-completion/pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole index 026f008f..e2c70558 100644 --- a/advanced/bash-completion/pihole +++ b/advanced/bash-completion/pihole @@ -4,7 +4,7 @@ _pihole() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer help" + opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer uninstall help" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 From ad8573c73928cdf34f7d8ebf609cc08f75c2aecf Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 18:10:50 +0100 Subject: [PATCH 155/311] Pedantic change, stops my editor from treating all of the code as one long sting in `' '` (as the `'` was escaped 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 f73de585..332b8153 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -69,7 +69,7 @@ spinner() { local pid=$1 local delay=0.50 - local spinstr='|/-\' + local spinstr='/-\|' while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" From 5976b20aec82a07cf1c0eefa91be78d071eae44e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 18:25:39 +0100 Subject: [PATCH 156/311] Fix spelling mistake, remove unaccessed function. --- pihole | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pihole b/pihole index 943bbec3..66f967dc 100755 --- a/pihole +++ b/pihole @@ -53,7 +53,7 @@ function updateDashboardFunc { } function updateGravityFunc { - $SUDO /opt/pihole/gravish.sh + $SUDO /opt/pihole/gravity.sh exit 1 } @@ -66,10 +66,7 @@ function chronometerFunc { $SUDO /opt/pihole/chronometer.sh exit 1 } -function gravityFunc { - $SUDO /opt/pihole/gravity.sh - exit 1 -} + function uninstallFunc { $SUDO /opt/pihole/uninstall.sh From 97d3aedba17ad9608cf7c4b1f74c97a738ceb9c9 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 18:27:18 +0100 Subject: [PATCH 157/311] Add some output to the log flush --- advanced/Scripts/piholeLogFlush.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/advanced/Scripts/piholeLogFlush.sh b/advanced/Scripts/piholeLogFlush.sh index bbcf1ade..db97f8cb 100755 --- a/advanced/Scripts/piholeLogFlush.sh +++ b/advanced/Scripts/piholeLogFlush.sh @@ -10,4 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +echo -n "::: Flushing /var/log/pihole.log ..." truncate -s 0 /var/log/pihole.log +echo "... done!" From 36645d93352f017a2872a0fb543c958121b1eba7 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 18:39:22 +0100 Subject: [PATCH 158/311] Add check for existing files in /usr/local/bin left over from previous version, as those scripts are replaced with `pihole ` script. --- automated install/basic-install.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 332b8153..78bf8809 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -488,6 +488,17 @@ installScripts() { $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole . /etc/bash_completion.d/pihole + + #Tidy up /usr/local/bin directory if installing over previous install. + oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug) + for i in "${oldFiles[@]}" + do + : + if [ -f "/usr/local/bin/$i.sh" ]; then + $SUDO rm /usr/local/bin/$i.sh + fi + done + $SUDO echo " done." } From 2d08217173a6de34198c60b2a4f5f9df7c38acfa Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 21:43:36 +0100 Subject: [PATCH 159/311] Tidy up For loops, clean up whitespace --- automated install/basic-install.sh | 942 ++++++++++++++--------------- 1 file changed, 469 insertions(+), 473 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 78bf8809..6a618338 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -50,17 +50,17 @@ dhcpcdFile=/etc/dhcpcd.conf # Must be root to install echo ":::" if [[ $EUID -eq 0 ]];then - echo "::: You are root." + echo "::: You are root." else - echo "::: sudo will be used for the install." - # 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 as root." - exit 1 - fi + echo "::: sudo will be used for the install." + # 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 as root." + exit 1 + fi fi @@ -81,343 +81,343 @@ spinner() } backupLegacyPihole() { - # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. - if [[ -f /etc/dnsmasq.d/adList.conf ]];then - echo "::: Original Pi-hole detected. Initiating sub space transport" - $SUDO mkdir -p /etc/pihole/original/ - $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" - $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" - if [ ! -d /opt/pihole ]; then - $SUDO mkdir /opt/pihole - $SUDO chown "$USER":root /opt/pihole - $SUDO chmod u+srwx /opt/pihole - fi - $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" - else - : - fi + # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. + if [[ -f /etc/dnsmasq.d/adList.conf ]];then + echo "::: Original Pi-hole detected. Initiating sub space transport" + $SUDO mkdir -p /etc/pihole/original/ + $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" + $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod u+srwx /opt/pihole + fi + $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" + else + : + fi } welcomeDialogs() { - # Display the welcome dialog - whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" $r $c + # Display the welcome dialog + whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" $r $c - # Support for a part-time dev - 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 + # Support for a part-time dev + 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. - In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $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. + In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } verifyFreeDiskSpace() { - # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) - requiredFreeBytes=51200 + # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 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) - fi + 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" - echo "Insufficient free space, exiting..." - exit 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" + echo "Insufficient free space, exiting..." + exit 1 + fi } chooseInterface() { - # Turn the available interfaces into an array so it can be used with a whiptail dialog - interfacesArray=() - firstloop=1 + # Turn the available interfaces into an array so it can be used with a whiptail dialog + interfacesArray=() + firstloop=1 - while read -r line - do - mode="OFF" - if [[ $firstloop -eq 1 ]]; then - firstloop=0 - mode="ON" - fi - interfacesArray+=("$line" "available" "$mode") - done <<< "$availableInterfaces" + while read -r line + do + mode="OFF" + if [[ $firstloop -eq 1 ]]; then + firstloop=0 + mode="ON" + fi + interfacesArray+=("$line" "available" "$mode") + done <<< "$availableInterfaces" - # Find out how many interfaces are available to choose from - interfaceCount=$(echo "$availableInterfaces" | wc -l) - chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount) - chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - for desiredInterface in $chooseInterfaceOptions - do - piholeInterface=$desiredInterface - echo "::: Using interface: $piholeInterface" - echo "${piholeInterface}" > /tmp/piholeINT - done - else - echo "::: Cancel selected, exiting...." - exit 1 - fi + # Find out how many interfaces are available to choose from + interfaceCount=$(echo "$availableInterfaces" | wc -l) + chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount) + chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]];then + for desiredInterface in $chooseInterfaceOptions + do + piholeInterface=$desiredInterface + echo "::: Using interface: $piholeInterface" + echo "${piholeInterface}" > /tmp/piholeINT + done + else + echo "::: Cancel selected, exiting...." + exit 1 + fi } cleanupIPv6() { - # Removes IPv6 indicator file if we are not using IPv6 - if [ -f "/etc/pihole/.useIPv6" ] && [ ! "$useIPv6" ]; then - rm /etc/pihole/.useIPv6 - fi + # 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 - cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) - options=(IPv4 "Block ads over IPv4" on - IPv6 "Block ads over IPv6" off) - choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - for choice in $choices - do - case $choice in - IPv4 ) useIPv4=true;; - IPv6 ) useIPv6=true;; - esac - done + # Let use select IPv4 and/or IPv6 + cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) + options=(IPv4 "Block ads over IPv4" on + IPv6 "Block ads over IPv6" off) + choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]];then + for choice in $choices + do + case $choice in + IPv4 ) useIPv4=true;; + IPv6 ) useIPv6=true;; + esac + done - if [ $useIPv4 ] && [ ! $useIPv6 ]; then - getStaticIPv4Settings - setStaticIPv4 - echo "::: Using IPv4 on $IPv4addr" - echo "::: IPv6 will NOT be used." - fi - if [ ! $useIPv4 ] && [ $useIPv6 ]; then - useIPv6dialog - echo "::: IPv4 will NOT be used." - echo "::: Using IPv6 on $piholeIPv6" - fi - if [ $useIPv4 ] && [ $useIPv6 ]; then - getStaticIPv4Settings - setStaticIPv4 - useIPv6dialog - echo "::: Using IPv4 on $IPv4addr" - echo "::: Using IPv6 on $piholeIPv6" - fi - if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then - echo "::: Cannot continue, neither IPv4 or IPv6 selected" - echo "::: Exiting" - exit 1 - fi - cleanupIPv6 - else - echo "::: Cancel selected. Exiting..." - exit 1 - fi + if [ $useIPv4 ] && [ ! $useIPv6 ]; then + getStaticIPv4Settings + setStaticIPv4 + echo "::: Using IPv4 on $IPv4addr" + echo "::: IPv6 will NOT be used." + fi + if [ ! $useIPv4 ] && [ $useIPv6 ]; then + useIPv6dialog + echo "::: IPv4 will NOT be used." + echo "::: Using IPv6 on $piholeIPv6" + fi + if [ $useIPv4 ] && [ $useIPv6 ]; then + getStaticIPv4Settings + setStaticIPv4 + useIPv6dialog + echo "::: Using IPv4 on $IPv4addr" + echo "::: Using IPv6 on $piholeIPv6" + fi + if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then + echo "::: Cannot continue, neither IPv4 or IPv6 selected" + echo "::: Exiting" + exit 1 + fi + cleanupIPv6 + else + echo "::: Cancel selected. Exiting..." + exit 1 + fi } useIPv6dialog() { - # Show the IPv6 address used for blocking - piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') - whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c + # Show the IPv6 address used for blocking + piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') + whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c - $SUDO touch /etc/pihole/.useIPv6 + $SUDO touch /etc/pihole/.useIPv6 } getStaticIPv4Settings() { - # Ask if the user wants to use DHCP settings as their static IP - if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address? - IP address: $IPv4addr - Gateway: $IPv4gw" $r $c) then - # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. - whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. - If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. - It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c - # Nothing else to do since the variables are already set above - else - # Otherwise, we need to ask the user to input their desired settings. - # Start by getting the IPv4 address (pre-filling it with info gathered from DHCP) - # Start a loop to let the user enter their information with the chance to go back and edit it if necessary - until [[ $ipSettingsCorrect = True ]] - do - # Ask for the IPv4 address - IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3) - if [[ $? = 0 ]];then - echo "::: Your static IPv4 address: $IPv4addr" - # Ask for the gateway - IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3) - if [[ $? = 0 ]];then - echo "::: Your static IPv4 gateway: $IPv4gw" - # Give the user a chance to review their settings before moving on - if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct? - IP address: $IPv4addr - Gateway: $IPv4gw" $r $c)then - # If the settings are correct, then we need to set the piholeIP - # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script - echo "${IPv4addr%/*}" > /tmp/piholeIP - echo "$piholeInterface" > /tmp/piholeINT - # After that's done, the loop ends and we move on - ipSettingsCorrect=True - else - # If the settings are wrong, the loop continues - ipSettingsCorrect=False - fi - else - # Cancelling gateway settings window - ipSettingsCorrect=False - echo "::: Cancel selected. Exiting..." - exit 1 - fi - else - # Cancelling IPv4 settings window - ipSettingsCorrect=False - echo "::: Cancel selected. Exiting..." - exit 1 - fi - done - # End the if statement for DHCP vs. static - fi + # Ask if the user wants to use DHCP settings as their static IP + if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address? + IP address: $IPv4addr + Gateway: $IPv4gw" $r $c) then + # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. + whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. + If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. + It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c + # Nothing else to do since the variables are already set above + else + # Otherwise, we need to ask the user to input their desired settings. + # Start by getting the IPv4 address (pre-filling it with info gathered from DHCP) + # Start a loop to let the user enter their information with the chance to go back and edit it if necessary + until [[ $ipSettingsCorrect = True ]] + do + # Ask for the IPv4 address + IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3) + if [[ $? = 0 ]];then + echo "::: Your static IPv4 address: $IPv4addr" + # Ask for the gateway + IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3) + if [[ $? = 0 ]];then + echo "::: Your static IPv4 gateway: $IPv4gw" + # Give the user a chance to review their settings before moving on + if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct? + IP address: $IPv4addr + Gateway: $IPv4gw" $r $c)then + # If the settings are correct, then we need to set the piholeIP + # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script + echo "${IPv4addr%/*}" > /tmp/piholeIP + echo "$piholeInterface" > /tmp/piholeINT + # After that's done, the loop ends and we move on + ipSettingsCorrect=True + else + # If the settings are wrong, the loop continues + ipSettingsCorrect=False + fi + else + # Cancelling gateway settings window + ipSettingsCorrect=False + echo "::: Cancel selected. Exiting..." + exit 1 + fi + else + # Cancelling IPv4 settings window + ipSettingsCorrect=False + echo "::: Cancel selected. Exiting..." + exit 1 + fi + done + # End the if statement for DHCP vs. static + fi } setDHCPCD() { - # Append these lines to dhcpcd.conf to enable a static IP - echo "::: interface $piholeInterface - static ip_address=$IPv4addr - static routers=$IPv4gw - static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null + # Append these lines to dhcpcd.conf to enable a static IP + echo "::: interface $piholeInterface + static ip_address=$IPv4addr + static routers=$IPv4gw + static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null } setStaticIPv4() { - # Tries to set the IPv4 address - if grep -q "$IPv4addr" $dhcpcdFile; then - # address already set, noop - : - else - setDHCPCD - $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" - echo ":::" - echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." - echo ":::" - fi + # Tries to set the IPv4 address + if grep -q "$IPv4addr" $dhcpcdFile; then + # address already set, noop + : + else + setDHCPCD + $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" + echo ":::" + echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" + fi } function valid_ip() { - local ip=$1 - local stat=1 + 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 + 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 - OpenDNS "" off - Level3 "" off - Norton "" off - Comodo "" off - Custom "" off) - DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - case $DNSchoices in - Google) - echo "::: Using Google DNS servers." - piholeDNS1="8.8.8.8" - piholeDNS2="8.8.4.4" - ;; - OpenDNS) - echo "::: Using OpenDNS servers." - 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" - ;; - Custom) - until [[ $DNSSettingsCorrect = True ]] - do + 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 + Custom "" off) + DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]];then + case $DNSchoices in + Google) + echo "::: Using Google DNS servers." + piholeDNS1="8.8.8.8" + piholeDNS2="8.8.4.4" + ;; + OpenDNS) + echo "::: Using OpenDNS servers." + 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" + ;; + Custom) + until [[ $DNSSettingsCorrect = True ]] + do - strInvalid="Invalid" + strInvalid="Invalid" - if [ ! $piholeDNS1 ]; then - if [ ! $piholeDNS2 ]; then - prePopulate="" - else - prePopulate=", $piholeDNS2" - fi - elif [ $piholeDNS1 ] && [ ! $piholeDNS2 ]; then - prePopulate="$piholeDNS1" - elif [ $piholeDNS1 ] && [ $piholeDNS2 ]; then - prePopulate="$piholeDNS1, $piholeDNS2" - fi + if [ ! $piholeDNS1 ]; then + if [ ! $piholeDNS2 ]; then + prePopulate="" + else + prePopulate=", $piholeDNS2" + fi + 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}') - - if ! valid_ip "$piholeDNS1" || [ ! "$piholeDNS1" ]; then - piholeDNS1=$strInvalid - fi - - if ! valid_ip "$piholeDNS2" && [ "$piholeDNS2" ]; then - piholeDNS2=$strInvalid - 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}') - 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 - - if [[ $piholeDNS1 == "$strInvalid" ]]; then - piholeDNS1="" - fi - - if [[ $piholeDNS2 == "$strInvalid" ]]; then - piholeDNS2="" - fi + if ! valid_ip "$piholeDNS1" || [ ! "$piholeDNS1" ]; then + piholeDNS1=$strInvalid + 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 - ;; - esac - else - echo "::: Cancel selected. Exiting..." - exit 1 - 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 + + 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 + ;; + esac + else + echo "::: Cancel selected. Exiting..." + exit 1 + fi } versionCheckDNSmasq(){ @@ -466,138 +466,134 @@ versionCheckDNSmasq(){ } installScripts() { - # Install the scripts from /etc/.pihole to their various locations - $SUDO echo ":::" - $SUDO echo -n "::: Installing scripts to /opt/pihole..." - if [ ! -d /opt/pihole ]; then - $SUDO mkdir /opt/pihole - $SUDO chown "$USER":root /opt/pihole - $SUDO chmod u+srwx /opt/pihole - fi - $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh - $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh - $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh - $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh - $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh - $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh - $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole - $SUDO chmod 755 /usr/local/bin/pihole - $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole - . /etc/bash_completion.d/pihole - - #Tidy up /usr/local/bin directory if installing over previous install. - oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug) - for i in "${oldFiles[@]}" - do - : - if [ -f "/usr/local/bin/$i.sh" ]; then - $SUDO rm /usr/local/bin/$i.sh - fi - done - - $SUDO echo " done." + # Install the scripts from /etc/.pihole to their various locations + $SUDO echo ":::" + $SUDO echo -n "::: Installing scripts to /opt/pihole..." + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod u+srwx /opt/pihole + fi + $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh + $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh + $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh + $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh + $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh + $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh + $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole + $SUDO chmod 755 /usr/local/bin/pihole + $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole + . /etc/bash_completion.d/pihole + + #Tidy up /usr/local/bin directory if installing over previous install. + oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug) + for i in "${oldFiles[@]}"; do + if [ -f "/usr/local/bin/$i.sh" ]; then + $SUDO rm /usr/local/bin/"$i".sh + fi + done + + $SUDO echo " done." } installConfigs() { - # Install the configs from /etc/.pihole to their various locations - $SUDO echo ":::" - $SUDO echo "::: Installing configs..." - versionCheckDNSmasq - if [ ! -d "/etc/lighttpd" ]; then - $SUDO mkdir /etc/lighttpd - $SUDO chown "$USER":root /etc/lighttpd - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig - fi - $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf + # Install the configs from /etc/.pihole to their various locations + $SUDO echo ":::" + $SUDO echo "::: Installing configs..." + versionCheckDNSmasq + if [ ! -d "/etc/lighttpd" ]; then + $SUDO mkdir /etc/lighttpd + $SUDO chown "$USER":root /etc/lighttpd + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig + fi + $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf } stopServices() { - # Stop dnsmasq and lighttpd - $SUDO echo ":::" - $SUDO echo -n "::: Stopping services..." - #$SUDO service dnsmasq stop & spinner $! || true - $SUDO service lighttpd stop & spinner $! || true - $SUDO echo " done." + # Stop dnsmasq and lighttpd + $SUDO echo ":::" + $SUDO echo -n "::: Stopping services..." + #$SUDO service dnsmasq stop & spinner $! || true + $SUDO service lighttpd stop & spinner $! || true + $SUDO echo " done." } checkForDependencies() { - #Running apt-get update/upgrade with minimal output can cause some issues with - #requiring user input (e.g password for phpmyadmin see #218) - #We'll change the logic up here, to check to see if there are any updates availible and - # if so, advise the user to run apt-get update/upgrade at their own discretion + #Running apt-get update/upgrade with minimal output can cause some issues with + #requiring user input (e.g password for phpmyadmin see #218) + #We'll change the logic up here, to check to see if there are any updates availible and + # if so, advise the user to run apt-get update/upgrade at their own discretion - #Check to see if apt-get update has already been run today - # it needs to have been run at least once on new installs! + #Check to see if apt-get update has already been run today + # it needs to have been run at least once on new installs! - timestamp=$(stat -c %Y /var/cache/apt/) - timestampAsDate=$(date -d @"$timestamp" "+%b %e") - today=$(date "+%b %e") + timestamp=$(stat -c %Y /var/cache/apt/) + timestampAsDate=$(date -d @"$timestamp" "+%b %e") + today=$(date "+%b %e") - if [ ! "$today" == "$timestampAsDate" ]; then - #update package lists - echo ":::" - echo -n "::: apt-get update has not been run today. Running now..." - $SUDO apt-get -qq update & spinner $! - echo " done!" - fi - echo ":::" - echo -n "::: Checking apt-get for upgraded packages...." - updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) - echo " done!" - echo ":::" - if [[ $updatesToInstall -eq "0" ]]; then - echo "::: Your pi is up to date! Continuing with pi-hole installation..." - else - echo "::: There are $updatesToInstall updates availible for your pi!" - echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " - echo ":::" - fi + if [ ! "$today" == "$timestampAsDate" ]; then + #update package lists + echo ":::" + echo -n "::: apt-get update has not been run today. Running now..." + $SUDO apt-get -qq update & spinner $! + echo " done!" + fi + echo ":::" + echo -n "::: Checking apt-get for upgraded packages...." + updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) + echo " done!" + echo ":::" + if [[ $updatesToInstall -eq "0" ]]; then + echo "::: Your pi is up to date! Continuing with pi-hole installation..." + else + echo "::: There are $updatesToInstall updates availible for your pi!" + echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " + echo ":::" + fi echo ":::" echo "::: Checking dependencies:" - dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) - for i in "${dependencies[@]}" - do - : - echo -n "::: Checking for $i..." - if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then - echo -n " Not found! Installing...." - $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! - echo " done!" - else - echo " already installed!" - fi - done + dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + for i in "${dependencies[@]}"; do + echo -n "::: Checking for $i..." + if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi + done } getGitFiles() { - # Setup git repos for base files and web admin - echo ":::" - echo "::: Checking for existing base files..." - if is_repo $piholeFilesDir; then - make_repo $piholeFilesDir $piholeGitUrl - else - update_repo $piholeFilesDir - fi + # Setup git repos for base files and web admin + echo ":::" + echo "::: Checking for existing base files..." + if is_repo $piholeFilesDir; then + make_repo $piholeFilesDir $piholeGitUrl + else + update_repo $piholeFilesDir + fi - echo ":::" - echo "::: Checking for existing web interface..." - if is_repo $webInterfaceDir; then - make_repo $webInterfaceDir $webInterfaceGitUrl - else - update_repo $webInterfaceDir - fi + echo ":::" + echo "::: Checking for existing web interface..." + if is_repo $webInterfaceDir; then + make_repo $webInterfaceDir $webInterfaceGitUrl + else + update_repo $webInterfaceDir + fi } is_repo() { - # If the directory does not have a .git folder it is not a repo - echo -n "::: Checking $1 is a repo..." + # If the directory does not have a .git folder it is not a repo + echo -n "::: Checking $1 is a repo..." if [ -d "$1/.git" ]; then - echo " OK!" + echo " OK!" return 1 fi echo " not found!!" @@ -622,94 +618,94 @@ update_repo() { CreateLogFile() { - # Create logfiles if necessary - echo ":::" - $SUDO echo -n "::: Creating log file and changing owner to dnsmasq..." - if [ ! -f /var/log/pihole.log ]; then - $SUDO touch /var/log/pihole.log - $SUDO chmod 644 /var/log/pihole.log - $SUDO chown dnsmasq:root /var/log/pihole.log - $SUDO echo " done!" - else - $SUDO echo " already exists!" - fi + # Create logfiles if necessary + echo ":::" + $SUDO echo -n "::: Creating log file and changing owner to dnsmasq..." + if [ ! -f /var/log/pihole.log ]; then + $SUDO touch /var/log/pihole.log + $SUDO chmod 644 /var/log/pihole.log + $SUDO chown dnsmasq:root /var/log/pihole.log + $SUDO echo " done!" + else + $SUDO echo " already exists!" + fi } installPiholeWeb() { - # Install the web interface - $SUDO echo ":::" - $SUDO echo -n "::: Installing pihole custom index page..." - if [ -d "/var/www/html/pihole" ]; then - $SUDO echo " Existing page detected, not overwriting" - else - $SUDO mkdir /var/www/html/pihole - if [ -f /var/www/html/index.lighttpd.html ]; then - $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig - else - printf "\n:::\tNo default index.lighttpd.html file found... not backing up" - fi - $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. - $SUDO echo " done!" - fi + # Install the web interface + $SUDO echo ":::" + $SUDO echo -n "::: Installing pihole custom index page..." + if [ -d "/var/www/html/pihole" ]; then + $SUDO echo " Existing page detected, not overwriting" + else + $SUDO mkdir /var/www/html/pihole + if [ -f /var/www/html/index.lighttpd.html ]; then + $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + else + printf "\n:::\tNo default index.lighttpd.html file found... not backing up" + fi + $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. + $SUDO echo " done!" + fi } installCron() { - # Install the cron job - $SUDO echo ":::" - $SUDO echo -n "::: Installing latest Cron script..." - $SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole - $SUDO echo " done!" + # Install the cron job + $SUDO echo ":::" + $SUDO echo -n "::: Installing latest Cron script..." + $SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole + $SUDO echo " done!" } runGravity() { - # Rub gravity.sh to build blacklists - $SUDO echo ":::" - $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)" - $SUDO rm /etc/pihole/list.* - fi - echo "::: Running gravity.sh" - $SUDO /opt/pihole/gravity.sh + # Rub gravity.sh to build blacklists + $SUDO echo ":::" + $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)" + $SUDO rm /etc/pihole/list.* + fi + echo "::: Running gravity.sh" + $SUDO /opt/pihole/gravity.sh } 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 + # 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 + $SUDO useradd -r -s /usr/sbin/nologin pihole + fi } installPihole() { - # Install base files and web interface - checkForDependencies # done - stopServices - setUser - $SUDO mkdir -p /etc/pihole/ - if [ ! -d "/var/www/html" ]; then - $SUDO mkdir -p /var/www/html - fi - $SUDO chown www-data:www-data /var/www/html - $SUDO chmod 775 /var/www/html - $SUDO usermod -a -G www-data pihole - $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null + # Install base files and web interface + checkForDependencies # done + stopServices + setUser + $SUDO mkdir -p /etc/pihole/ + if [ ! -d "/var/www/html" ]; then + $SUDO mkdir -p /var/www/html + fi + $SUDO chown www-data:www-data /var/www/html + $SUDO chmod 775 /var/www/html + $SUDO usermod -a -G www-data pihole + $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null - getGitFiles - installScripts - installConfigs - CreateLogFile - installPiholeWeb - installCron - runGravity + getGitFiles + installScripts + installConfigs + CreateLogFile + installPiholeWeb + installCron + runGravity } displayFinalMessage() { - # Final completion message to user - whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: + # Final completion message to user + whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: $IPv4addr $piholeIPv6 From c6fb0bad4b71f103aa90557bab6e2815007d71b7 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 21:45:00 +0100 Subject: [PATCH 160/311] change spinstr to match spinstr in basic-install.sh --- automated install/uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index de950a48..7082713a 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -29,7 +29,7 @@ spinner() { local pid=$1 local delay=0.50 - local spinstr='|/-\' + local spinstr='/-\|' while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" From 0e6e8040ba661cb24e1258febfccd28d13f52793 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 21:54:16 +0100 Subject: [PATCH 161/311] Change spinstr to match install and uninstall scripts --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c03cc1da..4f6713c1 100755 --- a/gravity.sh +++ b/gravity.sh @@ -74,7 +74,7 @@ fi spinner() { local pid=$1 local delay=0.50 - local spinstr='|/-\' + local spinstr='/-|' while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" From d710b97276d3c585d8e04c1ec3646b0f536622be Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 3 Apr 2016 22:10:04 +0100 Subject: [PATCH 162/311] Fix issue raised in #421 (Use variable instead of hardcoded path, do not delete user created pihole.conf!) --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 4f6713c1..c8a0d842 100755 --- a/gravity.sh +++ b/gravity.sh @@ -315,7 +315,7 @@ function gravity_reload() { #Clear no longer needed files... echo ":::" echo -n "::: Cleaning up un-needed files..." - $SUDO rm /etc/pihole/pihole.* + $SUDO rm $piholeDir/pihole.*.txt echo " done!" # Reload hosts file From 69e8c014c396bc7c25dd993b83fccfac6a6f25a1 Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 3 Apr 2016 17:25:48 -0500 Subject: [PATCH 163/311] Indentation fix --- automated install/basic-install.sh | 1024 ++++++++++++++-------------- 1 file changed, 506 insertions(+), 518 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6a618338..cd408887 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -50,28 +50,28 @@ dhcpcdFile=/etc/dhcpcd.conf # Must be root to install echo ":::" if [[ $EUID -eq 0 ]];then - echo "::: You are root." + echo "::: You are root." else - echo "::: sudo will be used for the install." - # 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 as root." - exit 1 - fi + echo "::: sudo will be used for the install." + # 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 as root." + exit 1 + fi fi ####### FUNCTIONS ########## spinner() { - local pid=$1 + local pid=$1 local delay=0.50 local spinstr='/-\|' while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do - local temp=${spinstr#?} + local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay @@ -81,523 +81,511 @@ spinner() } backupLegacyPihole() { - # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. - if [[ -f /etc/dnsmasq.d/adList.conf ]];then - echo "::: Original Pi-hole detected. Initiating sub space transport" - $SUDO mkdir -p /etc/pihole/original/ - $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" - $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" - if [ ! -d /opt/pihole ]; then - $SUDO mkdir /opt/pihole - $SUDO chown "$USER":root /opt/pihole - $SUDO chmod u+srwx /opt/pihole - fi - $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" - else - : - fi + # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. + if [[ -f /etc/dnsmasq.d/adList.conf ]];then + echo "::: Original Pi-hole detected. Initiating sub space transport" + $SUDO mkdir -p /etc/pihole/original/ + $SUDO mv /etc/dnsmasq.d/adList.conf /etc/pihole/original/adList.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/dnsmasq.conf /etc/pihole/original/dnsmasq.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/resolv.conf /etc/pihole/original/resolv.conf."$(date "+%Y-%m-%d")" + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/pihole/original/lighttpd.conf."$(date "+%Y-%m-%d")" + $SUDO mv /var/www/pihole/index.html /etc/pihole/original/index.html."$(date "+%Y-%m-%d")" + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod u+srwx /opt/pihole + fi + $SUDO mv /opt/pihole/gravity.sh /etc/pihole/original/gravity.sh."$(date "+%Y-%m-%d")" + else + : + fi } welcomeDialogs() { - # Display the welcome dialog - whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" $r $c + # Display the welcome dialog + whiptail --msgbox --backtitle "Welcome" --title "Pi-hole automated installer" "This installer will transform your Raspberry Pi into a network-wide ad blocker!" $r $c - # Support for a part-time dev - 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 + # Support for a part-time dev + 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. - In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $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. + In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } verifyFreeDiskSpace() { - # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) - requiredFreeBytes=51200 + # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 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) - fi + 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" - echo "Insufficient free space, exiting..." - exit 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" + echo "Insufficient free space, exiting..." + exit 1 + fi } chooseInterface() { - # Turn the available interfaces into an array so it can be used with a whiptail dialog - interfacesArray=() - firstloop=1 + # Turn the available interfaces into an array so it can be used with a whiptail dialog + interfacesArray=() + firstloop=1 - while read -r line - do - mode="OFF" - if [[ $firstloop -eq 1 ]]; then - firstloop=0 - mode="ON" - fi - interfacesArray+=("$line" "available" "$mode") - done <<< "$availableInterfaces" + while read -r line + do + mode="OFF" + if [[ $firstloop -eq 1 ]]; then + firstloop=0 + mode="ON" + fi + interfacesArray+=("$line" "available" "$mode") + done <<< "$availableInterfaces" - # Find out how many interfaces are available to choose from - interfaceCount=$(echo "$availableInterfaces" | wc -l) - chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount) - chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - for desiredInterface in $chooseInterfaceOptions - do - piholeInterface=$desiredInterface - echo "::: Using interface: $piholeInterface" - echo "${piholeInterface}" > /tmp/piholeINT - done - else - echo "::: Cancel selected, exiting...." - exit 1 - fi + # Find out how many interfaces are available to choose from + interfaceCount=$(echo "$availableInterfaces" | wc -l) + chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface" $r $c $interfaceCount) + chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]]; then + for desiredInterface in $chooseInterfaceOptions + do + piholeInterface=$desiredInterface + echo "::: Using interface: $piholeInterface" + echo "${piholeInterface}" > /tmp/piholeINT + done + else + echo "::: Cancel selected, exiting...." + exit 1 + fi } cleanupIPv6() { - # Removes IPv6 indicator file if we are not using IPv6 - if [ -f "/etc/pihole/.useIPv6" ] && [ ! "$useIPv6" ]; then - rm /etc/pihole/.useIPv6 - fi + # 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 - cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) - options=(IPv4 "Block ads over IPv4" on - IPv6 "Block ads over IPv6" off) - choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - for choice in $choices - do - case $choice in - IPv4 ) useIPv4=true;; - IPv6 ) useIPv6=true;; - esac - done + # Let use select IPv4 and/or IPv6 + cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) + options=(IPv4 "Block ads over IPv4" on + IPv6 "Block ads over IPv6" off) + choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]];then + for choice in $choices + do + case $choice in + IPv4 ) useIPv4=true;; + IPv6 ) useIPv6=true;; + esac + done - if [ $useIPv4 ] && [ ! $useIPv6 ]; then - getStaticIPv4Settings - setStaticIPv4 - echo "::: Using IPv4 on $IPv4addr" - echo "::: IPv6 will NOT be used." - fi - if [ ! $useIPv4 ] && [ $useIPv6 ]; then - useIPv6dialog - echo "::: IPv4 will NOT be used." - echo "::: Using IPv6 on $piholeIPv6" - fi - if [ $useIPv4 ] && [ $useIPv6 ]; then - getStaticIPv4Settings - setStaticIPv4 - useIPv6dialog - echo "::: Using IPv4 on $IPv4addr" - echo "::: Using IPv6 on $piholeIPv6" - fi - if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then - echo "::: Cannot continue, neither IPv4 or IPv6 selected" - echo "::: Exiting" - exit 1 - fi - cleanupIPv6 - else - echo "::: Cancel selected. Exiting..." - exit 1 - fi + if [ $useIPv4 ] && [ ! $useIPv6 ]; then + getStaticIPv4Settings + setStaticIPv4 + echo "::: Using IPv4 on $IPv4addr" + echo "::: IPv6 will NOT be used." + fi + if [ ! $useIPv4 ] && [ $useIPv6 ]; then + useIPv6dialog + echo "::: IPv4 will NOT be used." + echo "::: Using IPv6 on $piholeIPv6" + fi + if [ $useIPv4 ] && [ $useIPv6 ]; then + getStaticIPv4Settings + setStaticIPv4 + useIPv6dialog + echo "::: Using IPv4 on $IPv4addr" + echo "::: Using IPv6 on $piholeIPv6" + fi + if [ ! $useIPv4 ] && [ ! $useIPv6 ]; then + echo "::: Cannot continue, neither IPv4 or IPv6 selected" + echo "::: Exiting" + exit 1 + fi + cleanupIPv6 + else + echo "::: Cancel selected. Exiting..." + exit 1 + fi } useIPv6dialog() { - # Show the IPv6 address used for blocking - piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') - whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c + # Show the IPv6 address used for blocking + piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') + whiptail --msgbox --backtitle "IPv6..." --title "IPv6 Supported" "$piholeIPv6 will be used to block ads." $r $c - $SUDO touch /etc/pihole/.useIPv6 + $SUDO touch /etc/pihole/.useIPv6 } getStaticIPv4Settings() { - # Ask if the user wants to use DHCP settings as their static IP - if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address? - IP address: $IPv4addr - Gateway: $IPv4gw" $r $c) then - # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. - whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. - If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. - It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c - # Nothing else to do since the variables are already set above - else - # Otherwise, we need to ask the user to input their desired settings. - # Start by getting the IPv4 address (pre-filling it with info gathered from DHCP) - # Start a loop to let the user enter their information with the chance to go back and edit it if necessary - until [[ $ipSettingsCorrect = True ]] - do - # Ask for the IPv4 address - IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3) - if [[ $? = 0 ]];then - echo "::: Your static IPv4 address: $IPv4addr" - # Ask for the gateway - IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3) - if [[ $? = 0 ]];then - echo "::: Your static IPv4 gateway: $IPv4gw" - # Give the user a chance to review their settings before moving on - if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct? - IP address: $IPv4addr - Gateway: $IPv4gw" $r $c)then - # If the settings are correct, then we need to set the piholeIP - # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script - echo "${IPv4addr%/*}" > /tmp/piholeIP - echo "$piholeInterface" > /tmp/piholeINT - # After that's done, the loop ends and we move on - ipSettingsCorrect=True - else - # If the settings are wrong, the loop continues - ipSettingsCorrect=False - fi - else - # Cancelling gateway settings window - ipSettingsCorrect=False - echo "::: Cancel selected. Exiting..." - exit 1 - fi - else - # Cancelling IPv4 settings window - ipSettingsCorrect=False - echo "::: Cancel selected. Exiting..." - exit 1 - fi - done - # End the if statement for DHCP vs. static - fi + # Ask if the user wants to use DHCP settings as their static IP + if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Do you want to use your current network settings as a static address? + IP address: $IPv4addr + Gateway: $IPv4gw" $r $c) then + # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. + whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. + If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. + It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c + # Nothing else to do since the variables are already set above + else + # Otherwise, we need to ask the user to input their desired settings. + # Start by getting the IPv4 address (pre-filling it with info gathered from DHCP) + # Start a loop to let the user enter their information with the chance to go back and edit it if necessary + until [[ $ipSettingsCorrect = True ]] + do + # Ask for the IPv4 address + IPv4addr=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 address" --inputbox "Enter your desired IPv4 address" $r $c "$IPv4addr" 3>&1 1>&2 2>&3) + if [[ $? = 0 ]];then + echo "::: Your static IPv4 address: $IPv4addr" + # Ask for the gateway + IPv4gw=$(whiptail --backtitle "Calibrating network interface" --title "IPv4 gateway (router)" --inputbox "Enter your desired IPv4 default gateway" $r $c "$IPv4gw" 3>&1 1>&2 2>&3) + if [[ $? = 0 ]];then + echo "::: Your static IPv4 gateway: $IPv4gw" + # Give the user a chance to review their settings before moving on + if (whiptail --backtitle "Calibrating network interface" --title "Static IP Address" --yesno "Are these settings correct? + IP address: $IPv4addr + Gateway: $IPv4gw" $r $c)then + # If the settings are correct, then we need to set the piholeIP + # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script + echo "${IPv4addr%/*}" > /tmp/piholeIP + echo "$piholeInterface" > /tmp/piholeINT + # After that's done, the loop ends and we move on + ipSettingsCorrect=True + else + # If the settings are wrong, the loop continues + ipSettingsCorrect=False + fi + else + # Cancelling gateway settings window + ipSettingsCorrect=False + echo "::: Cancel selected. Exiting..." + exit 1 + fi + else + # Cancelling IPv4 settings window + ipSettingsCorrect=False + echo "::: Cancel selected. Exiting..." + exit 1 + fi + done + # End the if statement for DHCP vs. static + fi } setDHCPCD() { - # Append these lines to dhcpcd.conf to enable a static IP - echo "::: interface $piholeInterface - static ip_address=$IPv4addr - static routers=$IPv4gw - static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null + # Append these lines to dhcpcd.conf to enable a static IP + echo "::: interface $piholeInterface + static ip_address=$IPv4addr + static routers=$IPv4gw + static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null } setStaticIPv4() { - # Tries to set the IPv4 address - if grep -q "$IPv4addr" $dhcpcdFile; then - # address already set, noop - : - else - setDHCPCD - $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" - echo ":::" - echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." - echo ":::" - fi + # Tries to set the IPv4 address + if grep -q "$IPv4addr" $dhcpcdFile; then + # address already set, noop + : + else + setDHCPCD + $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" + echo ":::" + echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" + fi } function valid_ip() { - local ip=$1 - local stat=1 + 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 + 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 - OpenDNS "" off - Level3 "" off - Norton "" off - Comodo "" off - Custom "" off) - DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) - if [[ $? = 0 ]];then - case $DNSchoices in - Google) - echo "::: Using Google DNS servers." - piholeDNS1="8.8.8.8" - piholeDNS2="8.8.4.4" - ;; - OpenDNS) - echo "::: Using OpenDNS servers." - 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" - ;; - Custom) - until [[ $DNSSettingsCorrect = True ]] - do - - strInvalid="Invalid" - - if [ ! $piholeDNS1 ]; then - if [ ! $piholeDNS2 ]; then - prePopulate="" - else - prePopulate=", $piholeDNS2" - fi - 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}') - - 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 - - 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 - ;; - esac - else - echo "::: Cancel selected. Exiting..." - exit 1 - fi + 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 + Custom "" off) + DNSchoices=$("${DNSChoseCmd[@]}" "${DNSChooseOptions[@]}" 2>&1 >/dev/tty) + if [[ $? = 0 ]];then + case $DNSchoices in + Google) + echo "::: Using Google DNS servers." + piholeDNS1="8.8.8.8" + piholeDNS2="8.8.4.4" + ;; + OpenDNS) + echo "::: Using OpenDNS servers." + 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" + ;; + Custom) + until [[ $DNSSettingsCorrect = True ]] + do + strInvalid="Invalid" + if [ ! $piholeDNS1 ]; then + if [ ! $piholeDNS2 ]; then + prePopulate="" + else + prePopulate=", $piholeDNS2" + fi + 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}') + 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 + 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 + ;; + esac + else + echo "::: Cancel selected. Exiting..." + exit 1 + fi } versionCheckDNSmasq(){ - # Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory - dnsFile1="/etc/dnsmasq.conf" - dnsFile2="/etc/dnsmasq.conf.orig" - dnsSearch="addn-hosts=/etc/pihole/gravity.list" + # Check if /etc/dnsmasq.conf is from pihole. If so replace with an original and install new in .d directory + 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" - 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 + echo " it is from a previous pi-hole install." + echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..." + $SUDO mv -f $dnsFile1 $dnsFile2 + echo " done." + echo -n "::: Restoring default dnsmasq.conf..." + $SUDO cp $defaultFile $dnsFile1 + echo " done." + else + 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 - if [ -f $dnsFile1 ]; then - echo -n "::: Existing dnsmasq.conf found..." - if grep -q $dnsSearch $dnsFile1; then - echo " it is from a previous pi-hole install." - echo -n "::: Backing up dnsmasq.conf to dnsmasq.conf.orig..." - $SUDO mv -f $dnsFile1 $dnsFile2 - echo " done." - echo -n "::: Restoring default dnsmasq.conf..." - $SUDO cp $defaultFile $dnsFile1 - echo " done." - else - 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." - $SUDO sed -i "s/@INT@/$piholeInterface/" $newFileFinalLocation - if [[ "$piholeDNS1" != "" ]]; then - $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation - else - $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation - fi - if [[ "$piholeDNS2" != "" ]]; then - $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation - else - $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation - fi + 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 + if [[ "$piholeDNS1" != "" ]]; then + $SUDO sed -i "s/@DNS1@/$piholeDNS1/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS1@/d' $newFileFinalLocation + fi + if [[ "$piholeDNS2" != "" ]]; then + $SUDO sed -i "s/@DNS2@/$piholeDNS2/" $newFileFinalLocation + else + $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation + fi } installScripts() { - # Install the scripts from /etc/.pihole to their various locations - $SUDO echo ":::" - $SUDO echo -n "::: Installing scripts to /opt/pihole..." - if [ ! -d /opt/pihole ]; then - $SUDO mkdir /opt/pihole - $SUDO chown "$USER":root /opt/pihole - $SUDO chmod u+srwx /opt/pihole - fi - $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh - $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh - $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh - $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh - $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh - $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh - $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh - $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole - $SUDO chmod 755 /usr/local/bin/pihole - $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole - . /etc/bash_completion.d/pihole + # Install the scripts from /etc/.pihole to their various locations + $SUDO echo ":::" + $SUDO echo -n "::: Installing scripts to /opt/pihole..." + if [ ! -d /opt/pihole ]; then + $SUDO mkdir /opt/pihole + $SUDO chown "$USER":root /opt/pihole + $SUDO chmod u+srwx /opt/pihole + fi + $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh + $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh + $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/blacklist.sh /opt/pihole/blacklist.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeDebug.sh /opt/pihole/piholeDebug.sh + $SUDO cp /etc/.pihole/advanced/Scripts/piholeLogFlush.sh /opt/pihole/piholeLogFlush.sh + $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh + $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh + $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh + $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole + $SUDO chmod 755 /usr/local/bin/pihole + $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole + . /etc/bash_completion.d/pihole - #Tidy up /usr/local/bin directory if installing over previous install. - oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug) - for i in "${oldFiles[@]}"; do - if [ -f "/usr/local/bin/$i.sh" ]; then - $SUDO rm /usr/local/bin/"$i".sh - fi - done + #Tidy up /usr/local/bin directory if installing over previous install. + oldFiles=( gravity chronometer whitelist blacklist piholeLogFlush updateDashboard uninstall setupLCD piholeDebug) + for i in "${oldFiles[@]}"; do + if [ -f "/usr/local/bin/$i.sh" ]; then + $SUDO rm /usr/local/bin/"$i".sh + fi + done - $SUDO echo " done." + $SUDO echo " done." } installConfigs() { - # Install the configs from /etc/.pihole to their various locations - $SUDO echo ":::" - $SUDO echo "::: Installing configs..." - versionCheckDNSmasq - if [ ! -d "/etc/lighttpd" ]; then - $SUDO mkdir /etc/lighttpd - $SUDO chown "$USER":root /etc/lighttpd - $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig - fi - $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf + # Install the configs from /etc/.pihole to their various locations + $SUDO echo ":::" + $SUDO echo "::: Installing configs..." + versionCheckDNSmasq + if [ ! -d "/etc/lighttpd" ]; then + $SUDO mkdir /etc/lighttpd + $SUDO chown "$USER":root /etc/lighttpd + $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig + fi + $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf } stopServices() { - # Stop dnsmasq and lighttpd - $SUDO echo ":::" - $SUDO echo -n "::: Stopping services..." - #$SUDO service dnsmasq stop & spinner $! || true - $SUDO service lighttpd stop & spinner $! || true - $SUDO echo " done." + # Stop dnsmasq and lighttpd + $SUDO echo ":::" + $SUDO echo -n "::: Stopping services..." + #$SUDO service dnsmasq stop & spinner $! || true + $SUDO service lighttpd stop & spinner $! || true + $SUDO echo " done." } checkForDependencies() { - #Running apt-get update/upgrade with minimal output can cause some issues with - #requiring user input (e.g password for phpmyadmin see #218) - #We'll change the logic up here, to check to see if there are any updates availible and - # if so, advise the user to run apt-get update/upgrade at their own discretion + #Running apt-get update/upgrade with minimal output can cause some issues with + #requiring user input (e.g password for phpmyadmin see #218) + #We'll change the logic up here, to check to see if there are any updates availible and + # if so, advise the user to run apt-get update/upgrade at their own discretion + #Check to see if apt-get update has already been run today + # it needs to have been run at least once on new installs! - #Check to see if apt-get update has already been run today - # it needs to have been run at least once on new installs! + timestamp=$(stat -c %Y /var/cache/apt/) + timestampAsDate=$(date -d @"$timestamp" "+%b %e") + today=$(date "+%b %e") - timestamp=$(stat -c %Y /var/cache/apt/) - timestampAsDate=$(date -d @"$timestamp" "+%b %e") - today=$(date "+%b %e") - - if [ ! "$today" == "$timestampAsDate" ]; then - #update package lists - echo ":::" - echo -n "::: apt-get update has not been run today. Running now..." - $SUDO apt-get -qq update & spinner $! - echo " done!" - fi - echo ":::" - echo -n "::: Checking apt-get for upgraded packages...." + if [ ! "$today" == "$timestampAsDate" ]; then + #update package lists + echo ":::" + echo -n "::: apt-get update has not been run today. Running now..." + $SUDO apt-get -qq update & spinner $! + echo " done!" + fi + echo ":::" + echo -n "::: Checking apt-get for upgraded packages...." updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) echo " done!" echo ":::" if [[ $updatesToInstall -eq "0" ]]; then - echo "::: Your pi is up to date! Continuing with pi-hole installation..." + echo "::: Your pi is up to date! Continuing with pi-hole installation..." else - echo "::: There are $updatesToInstall updates availible for your pi!" - echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " - echo ":::" + echo "::: There are $updatesToInstall updates availible for your pi!" + echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " + echo ":::" fi echo ":::" echo "::: Checking dependencies:" dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) - for i in "${dependencies[@]}"; do - echo -n "::: Checking for $i..." - if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then - echo -n " Not found! Installing...." - $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! - echo " done!" - else - echo " already installed!" - fi - done + for i in "${dependencies[@]}"; do + echo -n "::: Checking for $i..." + if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi + done } getGitFiles() { - # Setup git repos for base files and web admin - echo ":::" - echo "::: Checking for existing base files..." - if is_repo $piholeFilesDir; then - make_repo $piholeFilesDir $piholeGitUrl - else - update_repo $piholeFilesDir - fi + # Setup git repos for base files and web admin + echo ":::" + echo "::: Checking for existing base files..." + if is_repo $piholeFilesDir; then + make_repo $piholeFilesDir $piholeGitUrl + else + update_repo $piholeFilesDir + fi - echo ":::" - echo "::: Checking for existing web interface..." - if is_repo $webInterfaceDir; then - make_repo $webInterfaceDir $webInterfaceGitUrl - else - update_repo $webInterfaceDir - fi + echo ":::" + echo "::: Checking for existing web interface..." + if is_repo $webInterfaceDir; then + make_repo $webInterfaceDir $webInterfaceGitUrl + else + update_repo $webInterfaceDir + fi } is_repo() { - # If the directory does not have a .git folder it is not a repo - echo -n "::: Checking $1 is a repo..." - if [ -d "$1/.git" ]; then - echo " OK!" - return 1 - fi - echo " not found!!" - return 0 + # If the directory does not have a .git folder it is not a repo + echo -n "::: Checking $1 is a repo..." + if [ -d "$1/.git" ]; then + echo " OK!" + return 1 + fi + echo " not found!!" + return 0 } make_repo() { @@ -618,101 +606,101 @@ update_repo() { CreateLogFile() { - # Create logfiles if necessary - echo ":::" - $SUDO echo -n "::: Creating log file and changing owner to dnsmasq..." - if [ ! -f /var/log/pihole.log ]; then - $SUDO touch /var/log/pihole.log - $SUDO chmod 644 /var/log/pihole.log - $SUDO chown dnsmasq:root /var/log/pihole.log - $SUDO echo " done!" - else - $SUDO echo " already exists!" - fi + # Create logfiles if necessary + echo ":::" + $SUDO echo -n "::: Creating log file and changing owner to dnsmasq..." + if [ ! -f /var/log/pihole.log ]; then + $SUDO touch /var/log/pihole.log + $SUDO chmod 644 /var/log/pihole.log + $SUDO chown dnsmasq:root /var/log/pihole.log + $SUDO echo " done!" + else + $SUDO echo " already exists!" + fi } installPiholeWeb() { - # Install the web interface - $SUDO echo ":::" - $SUDO echo -n "::: Installing pihole custom index page..." - if [ -d "/var/www/html/pihole" ]; then - $SUDO echo " Existing page detected, not overwriting" - else - $SUDO mkdir /var/www/html/pihole - if [ -f /var/www/html/index.lighttpd.html ]; then - $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig - else - printf "\n:::\tNo default index.lighttpd.html file found... not backing up" - fi - $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. - $SUDO echo " done!" - fi + # Install the web interface + $SUDO echo ":::" + $SUDO echo -n "::: Installing pihole custom index page..." + if [ -d "/var/www/html/pihole" ]; then + $SUDO echo " Existing page detected, not overwriting" + else + $SUDO mkdir /var/www/html/pihole + if [ -f /var/www/html/index.lighttpd.html ]; then + $SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig + else + printf "\n:::\tNo default index.lighttpd.html file found... not backing up" + fi + $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. + $SUDO echo " done!" + fi } installCron() { - # Install the cron job - $SUDO echo ":::" - $SUDO echo -n "::: Installing latest Cron script..." - $SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole - $SUDO echo " done!" + # Install the cron job + $SUDO echo ":::" + $SUDO echo -n "::: Installing latest Cron script..." + $SUDO cp /etc/.pihole/advanced/pihole.cron /etc/cron.d/pihole + $SUDO echo " done!" } runGravity() { - # Rub gravity.sh to build blacklists - $SUDO echo ":::" - $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)" - $SUDO rm /etc/pihole/list.* - fi - echo "::: Running gravity.sh" - $SUDO /opt/pihole/gravity.sh + # Rub gravity.sh to build blacklists + $SUDO echo ":::" + $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)" + $SUDO rm /etc/pihole/list.* + fi + echo "::: Running gravity.sh" + $SUDO /opt/pihole/gravity.sh } 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 + # 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() { - # Install base files and web interface - checkForDependencies # done - stopServices - setUser - $SUDO mkdir -p /etc/pihole/ - if [ ! -d "/var/www/html" ]; then - $SUDO mkdir -p /var/www/html - fi - $SUDO chown www-data:www-data /var/www/html - $SUDO chmod 775 /var/www/html - $SUDO usermod -a -G www-data pihole - $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null + # Install base files and web interface + checkForDependencies # done + stopServices + setUser + $SUDO mkdir -p /etc/pihole/ + if [ ! -d "/var/www/html" ]; then + $SUDO mkdir -p /var/www/html + fi + $SUDO chown www-data:www-data /var/www/html + $SUDO chmod 775 /var/www/html + $SUDO usermod -a -G www-data pihole + $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null - getGitFiles - installScripts - installConfigs - CreateLogFile - installPiholeWeb - installCron - runGravity + getGitFiles + installScripts + installConfigs + CreateLogFile + installPiholeWeb + installCron + runGravity } displayFinalMessage() { - # Final completion message to user - whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: + # Final completion message to user + whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: -$IPv4addr -$piholeIPv6 + $IPv4addr + $piholeIPv6 -If you set a new IP address, you should restart the Pi. + If you set a new IP address, you should restart the Pi. -The install log is in /etc/pihole." $r $c + The install log is in /etc/pihole." $r $c } ######## SCRIPT ############ From 22ea384ac822349ce0eac4f61264815fc6534dce Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 3 Apr 2016 18:05:11 -0500 Subject: [PATCH 164/311] Fix whiptail spacing --- automated install/basic-install.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cd408887..139a7a4b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -110,7 +110,8 @@ welcomeDialogs() { # 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. - In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c + +In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } @@ -174,7 +175,7 @@ cleanupIPv6() { use4andor6() { # Let use select IPv4 and/or IPv6 - cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) + cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" $r $c 2) options=(IPv4 "Block ads over IPv4" on IPv6 "Block ads over IPv6" off) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) @@ -232,8 +233,8 @@ getStaticIPv4Settings() { Gateway: $IPv4gw" $r $c) then # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. - If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. - It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c +If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. +It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c # Nothing else to do since the variables are already set above else # Otherwise, we need to ask the user to input their desired settings. @@ -695,12 +696,12 @@ displayFinalMessage() { # Final completion message to user whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: - $IPv4addr - $piholeIPv6 +IPv4: $IPv4addr +IPv6: $piholeIPv6 - If you set a new IP address, you should restart the Pi. +If you set a new IP address, you should restart the Pi. - The install log is in /etc/pihole." $r $c +The install log is in /etc/pihole." $r $c } ######## SCRIPT ############ From 5347ee48969e9e6306c644d9d9337a052df66215 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 4 Apr 2016 00:59:24 -0500 Subject: [PATCH 165/311] Write verbose status of processes to debug log & Minor UI Fixes --- advanced/Scripts/piholeDebug.sh | 20 +++++++++++++++++++- automated install/uninstall.sh | 6 +++--- gravity.sh | 14 +++++++------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index e9d95234..7a995c99 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -116,6 +116,24 @@ function testNslookup { echo >> $DEBUG_LOG } +function checkProcesses { + echo "#######################################" >> $DEBUG_LOG + echo "########### Processes Check ###########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + echo ":::" + echo "::: Logging status of lighttpd and dnsmasq..." + PROCESSES=( lighttpd dnsmasq ) + for i in "${PROCESSES[@]}" + do + echo "" >> $DEBUG_LOG + echo -n $i >> $DEBUG_LOG + echo " processes status:" >> $DEBUG_LOG + $SUDO systemctl -l status $i >> $DEBUG_LOG + done +} + +### END FUNCTIONS ### + ### Check Pi internet connections ### # Log the IP addresses of this Pi IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e') @@ -130,10 +148,10 @@ echo "Gateway check:" >> $DEBUG_LOG echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG -# Test the nslookup here compareWhitelist compareBlacklist testNslookup +checkProcesses echo "::: Writing dnsmasq.conf to debug log..." echo "#######################################" >> $DEBUG_LOG diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 7082713a..484a544d 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -51,8 +51,8 @@ echo ":::" read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn case $yn in [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "done!\n"; break;; - [Nn]* ) printf ":::\tSkipping %s" "$i"; break;; - * ) printf "::: You must answer yes or no!";; + [Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;; + * ) printf "::: You must answer yes or no!\n";; esac done else @@ -127,7 +127,7 @@ function removeNoPurge { echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n" - printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n" + printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L https://install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n" printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!\n" } diff --git a/gravity.sh b/gravity.sh index c8a0d842..d741ac80 100755 --- a/gravity.sh +++ b/gravity.sh @@ -124,13 +124,13 @@ function gravity_collapse() { # Temporary hack to allow non-root access to pihole directory # Will update later, needed for existing installs, new installs should # create this directory as non-root - find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! - echo ":::" - else - echo -n "::: Creating pihole directory..." - mkdir $piholeDir & spinner $! $SUDO chmod 777 $piholeDir - echo " done!" + echo ":::" + echo "::: Existing pihole directory found" + else + echo "::: Creating pihole directory..." + mkdir $piholeDir + $SUDO chmod 777 $piholeDir fi } @@ -174,7 +174,7 @@ function gravity_transport() { # spinup - main gravity function function gravity_spinup() { - echo "::: " + echo ":::" # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do From 7e06769d4427640ebca0af98b216b474a19c9aad Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 4 Apr 2016 01:03:05 -0500 Subject: [PATCH 166/311] Double quoting --- advanced/Scripts/piholeDebug.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 7a995c99..03d1498a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -126,9 +126,9 @@ function checkProcesses { for i in "${PROCESSES[@]}" do echo "" >> $DEBUG_LOG - echo -n $i >> $DEBUG_LOG + echo -n $i >> "$DEBUG_LOG" echo " processes status:" >> $DEBUG_LOG - $SUDO systemctl -l status $i >> $DEBUG_LOG + $SUDO systemctl -l status $i >> "$DEBUG_LOG" done } From 4f0835978686a462fb6e154dac6b437ec4f8a616 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 21:08:45 +0100 Subject: [PATCH 167/311] Make blacklist honour pihole.conf file --- advanced/Scripts/blacklist.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 2b194630..20329f1e 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then fi #globals -blacklist=/etc/pihole/blacklist.txt -adList=/etc/pihole/gravity.list +basename=pihole +piholeDir=/etc/$basename +adList=$piholeDir/gravity.list +blacklist=$piholeDir/blacklist.txt reload=true addmode=true force=false versbose=true + domList=() domToRemoveList=() @@ -42,6 +45,12 @@ piholeIP=${piholeIPCIDR%/*} modifyHost=false +# After setting defaults, check if there's local overrides +if [[ -r $piholeDir/pihole.conf ]];then + echo "::: Local calibration requested..." + . $piholeDir/pihole.conf +fi + if [[ -f $piholeIPv6file ]];then # If the file exists, then the user previously chose to use IPv6 in the automated installer From 0bbfb323b1e13bb2ed3b4c06bd287f455d4526da Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 21:08:56 +0100 Subject: [PATCH 168/311] make whitelist honour pihole.conf file --- advanced/Scripts/whitelist.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 8b57b250..d457d3d7 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then fi #globals -whitelist=/etc/pihole/whitelist.txt -adList=/etc/pihole/gravity.list +basename=pihole +piholeDir=/etc/$basename +adList=$piholeDir/gravity.list +whitelist=$piholeDir/whitelist.txt reload=true addmode=true force=false versbose=true + domList=() domToRemoveList=() @@ -42,6 +45,11 @@ piholeIP=${piholeIPCIDR%/*} modifyHost=false +# After setting defaults, check if there's local overrides +if [[ -r $piholeDir/pihole.conf ]];then + echo "::: Local calibration requested..." + . $piholeDir/pihole.conf +fi if [[ -f $piholeIPv6file ]];then # If the file exists, then the user previously chose to use IPv6 in the automated installer @@ -127,10 +135,10 @@ function ModifyHostFile(){ awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp awk -F':' '{print $1}' $whitelist | while read -r 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 - rm /etc/pihole/gravity.list - mv /etc/pihole/gravity.tmp /etc/pihole/gravity.list - rm /etc/pihole/whitelist.tmp + grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp + rm $adList + mv $piholeDir/gravity.tmp $adList + rm $piholeDir/whitelist.tmp echo " done!" fi From c6405bc93be04a248526a1e029281883bae9e253 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 23:38:46 +0100 Subject: [PATCH 169/311] Ensure addn-hosts value is updated in /etc/dnsmasq.d/01-pihole.conf if user has a custom value set in pihole.conf --- gravity.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gravity.sh b/gravity.sh index d741ac80..7d03ae7f 100755 --- a/gravity.sh +++ b/gravity.sh @@ -321,6 +321,12 @@ function gravity_reload() { # Reload hosts file echo ":::" echo -n "::: Refresh lists in dnsmasq..." + + #ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list! + #First escape forward slashes in the path: + adList=${adList//\//\\\/} + #Now replace the line in dnsmasq file + $SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adlist/" /etc/dnsmasq.d/01-pihole.conf dnsmasqPid=$(pidof dnsmasq) find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! From 0c0dd914f7950d54fc8573ce02730d0d31ed456e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 23:48:34 +0100 Subject: [PATCH 170/311] Fix source lists not being skipped if they are already up to date --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 7d03ae7f..80f80553 100755 --- a/gravity.sh +++ b/gravity.sh @@ -165,7 +165,7 @@ 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" # Cleanup From 47cc757ed08dc7d93779d18657a9a947f30bf625 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 5 Apr 2016 00:03:24 +0100 Subject: [PATCH 171/311] Fix incorrect echo --- advanced/Scripts/whitelist.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index d457d3d7..1d33e41a 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -90,7 +90,7 @@ function AddDomain(){ if $bool; then #domain not found in the whitelist file, add it! if $versbose; then - echo -n "::: Adding $1 to whitelist.txt..." + echo -n "::: Adding $1 to $whitelist..." fi echo "$1" >> $whitelist modifyHost=true @@ -99,7 +99,7 @@ function AddDomain(){ fi else if $versbose; then - echo "::: $1 already exists in whitelist.txt, no need to add!" + echo "::: $1 already exists in $whitelist, no need to add!" fi fi } @@ -157,7 +157,7 @@ function ModifyHostFile(){ echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList echo " done!" fi - echo -n "::: Removing $rdom from whitelist.txt..." + echo -n "::: Removing $rdom from $whitelist..." echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist echo " done!" done From 849185d3c9cc1618e37e80d0e4e63746cea57bd3 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 5 Apr 2016 00:03:49 +0100 Subject: [PATCH 172/311] Fix incorrect echo --- advanced/Scripts/blacklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 20329f1e..9e5d557b 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -96,7 +96,7 @@ function AddDomain(){ echo " done!" else if $versbose; then - echo "::: $1 already exists in blacklist.txt! No need to add" + echo "::: $1 already exists in $blacklist! No need to add" fi fi } From 8514f42d0d23d6c726c4fd15a9cd45e6285555c6 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 5 Apr 2016 08:53:52 +0100 Subject: [PATCH 173/311] Correct variable name (Missing capital letter! whoops!) --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 80f80553..d77d75cf 100755 --- a/gravity.sh +++ b/gravity.sh @@ -326,7 +326,7 @@ function gravity_reload() { #First escape forward slashes in the path: adList=${adList//\//\\\/} #Now replace the line in dnsmasq file - $SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adlist/" /etc/dnsmasq.d/01-pihole.conf + $SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf dnsmasqPid=$(pidof dnsmasq) find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! From 9c94af04cc537c4caf050394a1297c15e9fe9426 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 5 Apr 2016 14:22:10 +0100 Subject: [PATCH 174/311] Fixes #432. Thanks to @VDRrulez and @jradwan for pointing it out... --- advanced/pihole.cron | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 9d390143..712679ac 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -11,16 +11,16 @@ # Pi-hole: Update the ad sources once a week on Sunday at 01:59 # Download any updates from the adlists -59 1 * * 7 root /usr/local/bin/gravity.sh +59 1 * * 7 root /usr/local/bin/pihole updateGravity # Pi-hole: Update the Web interface shortly after gravity runs # This should also update the version number if it is changed in the dashboard repo -30 2 * * 7 root /usr/local/bin/updateDashboard.sh +30 2 * * 7 root /usr/local/bin/pihole updateDashboard # Pi-hole: Parse the log file before it is flushed and save the stats to a database # This will be used for a historical view of your Pi-hole's performance -#50 23 * * * root /usr/local/bin/dailyLog.sh +#50 23 * * * root /usr/local/bin/dailyLog.sh # note: this is outdated # Pi-hole: Flush the log daily at 11:58 so it doesn't get out of control # Stats will be viewable in the Web interface thanks to the cron job above -58 23 * * * root /usr/local/bin/piholeLogFlush.sh +58 23 * * * root /usr/local/bin/pihole flush From 3877f6fd9485cea9a9be17a58634d4dbcee4e597 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:27:46 +0100 Subject: [PATCH 175/311] Fix arguments not being passed through to chronometer.sh --- pihole | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 66f967dc..add8a04a 100755 --- a/pihole +++ b/pihole @@ -63,7 +63,8 @@ function setupLCDFunction { } function chronometerFunc { - $SUDO /opt/pihole/chronometer.sh + shift + $SUDO /opt/pihole/chronometer.sh "$@" exit 1 } @@ -106,7 +107,7 @@ case "$1" in "-u" | "updateDashboard" ) updateDashboardFunc;; "-g" | "updateGravity" ) updateGravityFunc;; "-s" | "setupLCD" ) setupLCDFunction;; -"-c" | "chronometer" ) chronometerFunc;; +"-c" | "chronometer" ) chronometerFunc "$@";; "-h" | "help" ) helpFunc;; "uninstall" ) uninstallFunc;; * ) helpFunc;; From 96f3f863e584f9de57300a1ae14d6a5cd4759d90 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:28:24 +0100 Subject: [PATCH 176/311] Clean up output. Commented out un-needed root/sudo notification --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index add8a04a..29e85309 100755 --- a/pihole +++ b/pihole @@ -12,9 +12,9 @@ # Must be root to use this tool if [[ $EUID -eq 0 ]];then - echo "::: You are root." + #echo "::: You are root." else - echo "::: Sudo will be used for this tool." + #echo "::: Sudo will be used for this tool." # Check if it is actually installed # If it isn't, exit because the pihole cannot be invoked without privileges. if [[ $(dpkg-query -s sudo) ]];then From e074c721301b86e4595ee75a24f83e195ae9ff99 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:32:36 +0100 Subject: [PATCH 177/311] Move help output to function helpFunc, add -h argument. --- advanced/Scripts/whitelist.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 1d33e41a..bf58b100 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -11,16 +11,7 @@ # (at your option) any later version. if [[ $# = 0 ]]; then - echo "::: Immediately whitelists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" - echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - exit 1 + helpFunc fi #globals @@ -57,6 +48,21 @@ if [[ -f $piholeIPv6file ]];then fi +function helpFunc() +{ + echo "::: Immediately whitelists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the whitelist" + echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + exit 1 +} + 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/') @@ -188,7 +194,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) versbose=false;; + "-h" | "--help" ) helpFunc;; * ) HandleOther "$var";; esac done From 391dea445a1271f6c54f79ee0e7c8613ffae1258 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:34:05 +0100 Subject: [PATCH 178/311] Move help output to function, add -h argument --- advanced/Scripts/blacklist.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 9e5d557b..fe6d42f3 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -11,16 +11,7 @@ # (at your option) any later version. if [[ $# = 0 ]]; then - echo "::: Immediately blacklists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the blacklist" - echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - exit 1 + helpFunc fi #globals @@ -58,6 +49,21 @@ if [[ -f $piholeIPv6file ]];then fi +function helpFunc() +{ + echo "::: Immediately blacklists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the blacklist" + echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + exit 1 +} + 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/') @@ -175,7 +181,8 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) versbose=false;; + "-h" | "--help" ) helpFunc;; * ) HandleOther "$var";; esac done From 0b480c2d3f78f5d04c60fc0bcced20abddb75eae Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:36:41 +0100 Subject: [PATCH 179/311] remove redundant else, add ! to if logic. --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 29e85309..5ff26246 100755 --- a/pihole +++ b/pihole @@ -11,9 +11,9 @@ # (at your option) any later version. # Must be root to use this tool -if [[ $EUID -eq 0 ]];then +if [[ ! $EUID -eq 0 ]];then #echo "::: You are root." -else +#else #echo "::: Sudo will be used for this tool." # Check if it is actually installed # If it isn't, exit because the pihole cannot be invoked without privileges. From 70dadfba28f8f5862d0b3d8453bebae19656d0d9 Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Thu, 7 Apr 2016 21:52:47 -0400 Subject: [PATCH 180/311] add list options requested from issue#442 --- advanced/Scripts/blacklist.sh | 17 ++++++++++++++++- advanced/Scripts/whitelist.sh | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index fe6d42f3..11d13c5b 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,6 +61,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -173,6 +174,19 @@ function Reload() { echo " done!" } +function DisplayBlist() { +clear +echo -e " Displaying Gravity Affected Domains \n" + +GRD="$blacklist" +count=1 +while IFS= read -r RD +do + echo "${count}: $RD" +count=$((count+1)) +done < "$blacklist" +} + ################################################### for var in "$@" @@ -182,7 +196,8 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; + "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index bf58b100..6ecb7715 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,6 +60,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -186,6 +187,19 @@ function Reload() { echo " done!" } +function DisplayWlist() { +clear +echo -e " Displaying Gravity Resistant Domains \n" + +GRD="$whitelist" +count=1 +while IFS= read -r RD +do + echo "${count}: $RD" +count=$((count+1)) +done < "$whitelist" +} + ################################################### for var in "$@" @@ -195,7 +209,8 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; + "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; esac done From bdfc86f850175c75a575cb1dd08d6e52c4e4f89b Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Thu, 7 Apr 2016 21:58:57 -0400 Subject: [PATCH 181/311] fix formatting --- advanced/Scripts/blacklist.sh | 4 ++-- advanced/Scripts/whitelist.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 11d13c5b..f06cd138 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,7 +61,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -197,7 +197,7 @@ do "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; "-h" | "--help" ) helpFunc;; - "-l" | "--list" ) DisplayBlist;; + "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 6ecb7715..a19a175f 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,7 +60,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" + echo "::: -l, --list Display your whitelisted domains" exit 1 } From 9a4c5cef8620e45ae5e31a66aad27c9d281e5827 Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Fri, 8 Apr 2016 10:14:17 -0400 Subject: [PATCH 182/311] fix indentations --- advanced/Scripts/blacklist.sh | 20 +++++++++----------- advanced/Scripts/whitelist.sh | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f06cd138..418b5a4c 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,7 +61,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -175,16 +175,14 @@ function Reload() { } function DisplayBlist() { -clear -echo -e " Displaying Gravity Affected Domains \n" - -GRD="$blacklist" -count=1 -while IFS= read -r RD -do - echo "${count}: $RD" -count=$((count+1)) -done < "$blacklist" + clear + echo -e " Displaying Gravity Affected Domains \n" + count=1 + while IFS= read -r AD + do + echo "${count}: $AD" + count=$((count+1)) + done < "$blacklist" } ################################################### diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index a19a175f..ea9b33ad 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,7 +60,7 @@ function helpFunc() echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -q, --quiet output is less verbose" echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -188,16 +188,14 @@ function Reload() { } function DisplayWlist() { -clear -echo -e " Displaying Gravity Resistant Domains \n" - -GRD="$whitelist" -count=1 -while IFS= read -r RD -do - echo "${count}: $RD" -count=$((count+1)) -done < "$whitelist" + clear + echo -e " Displaying Gravity Resistant Domains \n" + count=1 + while IFS= read -r RD + do + echo "${count}: $RD" + count=$((count+1)) + done < "$whitelist" } ################################################### @@ -209,7 +207,7 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; esac From 6c87698f1a9a38ae1583bf4d0190aedcc54e43dd Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:10:10 +0100 Subject: [PATCH 183/311] fix spelling in name of variable ($versbose -> $verbose) --- advanced/Scripts/whitelist.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index ea9b33ad..b9d14541 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -22,7 +22,7 @@ whitelist=$piholeDir/whitelist.txt reload=true addmode=true force=false -versbose=true +verbose=true domList=() domToRemoveList=() @@ -96,16 +96,16 @@ function AddDomain(){ grep -Ex -q "$1" $whitelist || bool=true if $bool; then #domain not found in the whitelist file, add it! - if $versbose; then + if $verbose; then echo -n "::: Adding $1 to $whitelist..." fi echo "$1" >> $whitelist modifyHost=true - if $versbose; then + if $verbose; then echo " done!" fi else - if $versbose; then + if $verbose; then echo "::: $1 already exists in $whitelist, no need to add!" fi fi @@ -117,12 +117,12 @@ function RemoveDomain(){ grep -Ex -q "$1" $whitelist || bool=true if $bool; then #Domain is not in the whitelist file, no need to Remove - if $versbose; then + if $verbose; then echo "::: $1 is NOT whitelisted! No need to remove" fi else #Domain is in the whitelist file, add to a temporary array and remove from whitelist file - #if $versbose; then + #if $verbose; then #echo "::: Un-whitelisting $dom..." #fi domToRemoveList=("${domToRemoveList[@]}" $1) @@ -206,7 +206,7 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) verbose=false;; "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; @@ -218,7 +218,7 @@ PopWhitelistFile if $modifyHost || $force; then ModifyHostFile else - if $versbose; then + if $verbose; then echo ":::" echo "::: No changes need to be made" exit 1 From c0aadeab3d4df173ac0a2c4039d233877f8d5e3c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:10:27 +0100 Subject: [PATCH 184/311] fix spelling in name of variable ($versbose -> $verbose) --- advanced/Scripts/blacklist.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 418b5a4c..db91a146 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -22,7 +22,7 @@ blacklist=$piholeDir/blacklist.txt reload=true addmode=true force=false -versbose=true +verbose=true domList=() domToRemoveList=() @@ -95,14 +95,14 @@ function AddDomain(){ grep -Ex -q "$1" $blacklist || bool=true if $bool; then #domain not found in the blacklist file, add it! - if $versbose; then + if $verbose; then echo -n "::: Adding $1 to blacklist file..." fi echo "$1" >> $blacklist modifyHost=true echo " done!" else - if $versbose; then + if $verbose; then echo "::: $1 already exists in $blacklist! No need to add" fi fi @@ -114,12 +114,12 @@ function RemoveDomain(){ grep -Ex -q "$1" $blacklist || bool=true if $bool; then #Domain is not in the blacklist file, no need to Remove - if $versbose; then + if $verbose; then echo "::: $1 is NOT blacklisted! No need to remove" fi else #Domain is in the blacklist file, add to a temporary array - if $versbose; then + if $verbose; then echo "::: Un-blacklisting $dom..." fi domToRemoveList=("${domToRemoveList[@]}" $1) @@ -193,7 +193,7 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) verbose=false;; "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; @@ -205,7 +205,7 @@ PopBlacklistFile if $modifyHost || $force; then ModifyHostFile else - if $versbose; then + if $verbose; then echo "::: No changes need to be made" fi exit 1 From 8e04f1c03e8701e5fbd91cb10d17c109d211c486 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:11:39 +0100 Subject: [PATCH 185/311] Remove clear in DisplayBlist and forse verbose to false to tidy up output. --- advanced/Scripts/blacklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index db91a146..f36f5efa 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -175,7 +175,7 @@ function Reload() { } function DisplayBlist() { - clear + verbose=false echo -e " Displaying Gravity Affected Domains \n" count=1 while IFS= read -r AD From 3154a378a686a5e1ad43e645f62926a86edf7088 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:12:30 +0100 Subject: [PATCH 186/311] Remove clear in DisplayWlist and force verbose to false to tidy up output. --- advanced/Scripts/whitelist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b9d14541..852e319d 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -188,7 +188,7 @@ function Reload() { } function DisplayWlist() { - clear + verbose=false echo -e " Displaying Gravity Resistant Domains \n" count=1 while IFS= read -r RD From ab99e80333f795b6ea4b7a6ae68eaa0bec17d2b0 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 23:00:46 +0100 Subject: [PATCH 187/311] indent --- advanced/Scripts/blacklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f36f5efa..04d4d60f 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -206,7 +206,7 @@ if $modifyHost || $force; then ModifyHostFile else if $verbose; then - echo "::: No changes need to be made" + echo "::: No changes need to be made" fi exit 1 fi From 107e0404de91309ebfef9fbf06ad51306b2a85e1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 23:01:13 +0100 Subject: [PATCH 188/311] Move `exit 1` outside of `if` block on verbose check to stop dnsmasq reloading --- advanced/Scripts/whitelist.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 852e319d..00556476 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -219,10 +219,10 @@ if $modifyHost || $force; then ModifyHostFile else if $verbose; then - echo ":::" - echo "::: No changes need to be made" - exit 1 + echo ":::" + echo "::: No changes need to be made" fi + exit 1 fi if $reload; then From be79281418424cefd6dfc7d651792871b4e68d0e Mon Sep 17 00:00:00 2001 From: notracking Date: Sun, 10 Apr 2016 16:12:40 +0800 Subject: [PATCH 189/311] Added hosts-blocklists lists The hosts-blocklist is a semi-automatically updated list, based on various well known public sources, for more details read: https://github.com/notracking/hosts-blocklists/ Please be aware that one file is for domain blocking and the other file for hostname based blocking, these lists are complimentary and should therefore be used simultaneously. --- adlists.default | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adlists.default b/adlists.default index 8a396729..837f612a 100644 --- a/adlists.default +++ b/adlists.default @@ -48,3 +48,6 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt #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 +# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/) +#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt +#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt From 05e0003555e2b681cb80b1f855468641c96e376f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:17:58 +0100 Subject: [PATCH 190/311] Fixes issue #453 --- advanced/Scripts/blacklist.sh | 24 ++++++++++++------------ advanced/Scripts/chronometer.sh | 2 +- advanced/Scripts/whitelist.sh | 14 +++++++------- pihole | 22 +++++++++++----------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 04d4d60f..7d4edb95 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -53,15 +53,15 @@ function helpFunc() { echo "::: Immediately blacklists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" + echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" echo ":::" echo "::: Options:" - echo "::: -d, --delmode Remove domains from the blacklist" + echo "::: -d, --delmode Remove domains from the blacklist" echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -70,7 +70,7 @@ function HandleOther(){ 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 } @@ -134,12 +134,12 @@ function ModifyHostFile(){ 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 ":::" @@ -148,7 +148,7 @@ function ModifyHostFile(){ #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 diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 58bf300b..1c8a53c9 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -120,7 +120,7 @@ function normalChrono(){ function displayHelp(){ echo "::: Displays stats about your piHole!" echo ":::" - echo "::: Usage: sudo pihole.sh -c [optional:-j]" + echo "::: Usage: sudo pihole -c [optional:-j]" echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" echo ":::" echo "::: Options:" diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 00556476..b6901249 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -52,15 +52,15 @@ function helpFunc() { echo "::: Immediately whitelists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" + echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" echo ":::" echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" + echo "::: -d, --delmode Remove domains from the whitelist" echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -220,7 +220,7 @@ if $modifyHost || $force; then else if $verbose; then echo ":::" - echo "::: No changes need to be made" + echo "::: No changes need to be made" fi exit 1 fi diff --git a/pihole b/pihole index 5ff26246..d9d52e0c 100755 --- a/pihole +++ b/pihole @@ -77,20 +77,20 @@ function uninstallFunc { function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" - echo "::: Usage: pihole.sh [options]" + echo "::: Usage: pihole [options]" printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo ":::" echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" - echo "::: uninstall Uninstall Pi-Hole from your system!" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" + echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 48fa83c9ac5140f8d4665a668fdf6ef56010ab4a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:36:33 +0100 Subject: [PATCH 191/311] Fix whitespace --- advanced/Scripts/blacklist.sh | 24 ++++++++++++------------ advanced/Scripts/whitelist.sh | 24 ++++++++++++------------ pihole | 20 ++++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 7d4edb95..aa98f011 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -51,18 +51,18 @@ fi function helpFunc() { - echo "::: Immediately blacklists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the blacklist" - echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" - exit 1 + echo "::: Immediately blacklists one or more domains in the hosts file" + echo ":::" + echo ":::" + echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the blacklist" + echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your blacklisted domains" + exit 1 } function HandleOther(){ diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b6901249..e69e8804 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -50,18 +50,18 @@ fi function helpFunc() { - echo "::: Immediately whitelists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" - echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" - exit 1 + echo "::: Immediately whitelists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the whitelist" + echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your whitelisted domains" + exit 1 } function HandleOther(){ diff --git a/pihole b/pihole index d9d52e0c..5b785978 100755 --- a/pihole +++ b/pihole @@ -81,16 +81,16 @@ function helpFunc { printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo ":::" echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" - echo "::: uninstall Uninstall Pi-Hole from your system!" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" + echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 1c10a801dc077f8ce5e4a58420482c491ea0b9ee Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:39:44 +0100 Subject: [PATCH 192/311] Fix whitespace... --- pihole | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pihole b/pihole index 5b785978..03e07d6e 100755 --- a/pihole +++ b/pihole @@ -75,23 +75,23 @@ function uninstallFunc { } function helpFunc { - echo "::: Control all PiHole specific functions!" - echo ":::" - echo "::: Usage: pihole [options]" - printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" - echo ":::" - echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: Control all PiHole specific functions!" + echo ":::" + echo "::: Usage: pihole [options]" + printf "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" + echo ":::" + echo "::: Options:" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -h, help Show this help dialog" echo "::: uninstall Uninstall Pi-Hole from your system!" - exit 1 + exit 1 } if [[ $# = 0 ]]; then From 1ce888e828b4a9a80896794e3cb3a9f60de4020a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:41:46 +0100 Subject: [PATCH 193/311] more whitespace fixes...... --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pihole b/pihole index 03e07d6e..59fe1383 100755 --- a/pihole +++ b/pihole @@ -78,7 +78,7 @@ function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" echo "::: Usage: pihole [options]" - printf "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" + echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" echo ":::" echo "::: Options:" echo "::: -w, whitelist Whitelist domains" From b6e1b3bff0e22480984e8d9afbb756171f7ca32a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:43:12 +0100 Subject: [PATCH 194/311] Last one, promise! tabs are behaving strangely here... --- pihole | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pihole b/pihole index 59fe1383..1c348b71 100755 --- a/pihole +++ b/pihole @@ -85,11 +85,11 @@ function helpFunc { echo "::: -b, blacklist Blacklist domains" echo "::: -d, debug Start a debugging session if having trouble" echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" + echo "::: -h, help Show this help dialog" echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 99a5b3a98ab71693426daf15254ad8c64936f867 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 11 Apr 2016 11:29:14 +0100 Subject: [PATCH 195/311] remove all mentions of spinner --- gravity.sh | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/gravity.sh b/gravity.sh index d77d75cf..ac9cd629 100755 --- a/gravity.sh +++ b/gravity.sh @@ -12,6 +12,7 @@ # Run this script as root or under sudo echo ":::" + if [[ $EUID -eq 0 ]];then echo "::: You are root." else @@ -71,20 +72,6 @@ if [[ -r $piholeDir/pihole.conf ]];then . $piholeDir/pihole.conf fi -spinner() { - local pid=$1 - local delay=0.50 - local spinstr='/-|' - while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do - local temp=${spinstr#?} - printf " [%c] " "$spinstr" - local spinstr=$temp${spinstr%"$temp"} - sleep $delay - printf "\b\b\b\b\b\b" - done - printf " \b\b\b\b" -} - ########################### # collapse - begin formation of pihole function gravity_collapse() { @@ -214,7 +201,7 @@ 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 for i in "${activeDomains[@]}" do cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight @@ -225,7 +212,7 @@ function gravity_Schwarzchild() { 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 $! + $blacklistScript -f -nr -q > /dev/null numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s @@ -247,7 +234,7 @@ function gravity_Whitelist() { echo " done!" echo -n "::: Running whitelist script to update HOSTS file...." - $whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $! + $whitelistScript -f -nr -q "${urls[@]}" > /dev/null numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s echo " $numWhitelisted domain${plural} whitelisted!" @@ -256,7 +243,7 @@ function gravity_Whitelist() { function gravity_unique() { # Sort and remove duplicates echo -n "::: Removing duplicate domains...." - sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $! + sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon echo " done!" numberOf=$(wc -l < $piholeDir/$eventHorizon) echo "::: $numberOf unique domains trapped in the event horizon." @@ -302,7 +289,7 @@ function gravity_advanced() { # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo -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 $! + awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova echo " done!" numberOf=$(wc -l < $piholeDir/$supernova) @@ -329,14 +316,14 @@ function gravity_reload() { $SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf dnsmasqPid=$(pidof dnsmasq) - find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! + find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" & spinner $! + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - $SUDO service dnsmasq start & spinner $! + $SUDO service dnsmasq start fi echo " done!" } From 2f4f5a6ad2c6557b21ffab66f4403c2a2f1d8fc3 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 11 Apr 2016 18:35:44 -0500 Subject: [PATCH 196/311] Added lighttpd error.log to debug output --- advanced/Scripts/piholeDebug.sh | 60 ++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 03d1498a..364abde4 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log" DNSMASQFILE="/etc/dnsmasq.conf" PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf" +LIGHTTPDERRFILE="/var/log/lighttpd/error.log" GRAVITYFILE="/etc/pihole/gravity.list" HOSTSFILE="/etc/hosts" WHITELISTFILE="/etc/pihole/whitelist.txt" @@ -126,12 +127,44 @@ function checkProcesses { for i in "${PROCESSES[@]}" do echo "" >> $DEBUG_LOG - echo -n $i >> "$DEBUG_LOG" + echo -n "$i" >> "$DEBUG_LOG" echo " processes status:" >> $DEBUG_LOG - $SUDO systemctl -l status $i >> "$DEBUG_LOG" + $SUDO systemctl -l status "$i" >> "$DEBUG_LOG" done } +function debugLighttpd { + echo "::: Writing lighttpd to debug log..." + echo "#######################################" >> $DEBUG_LOG + echo "############ lighttpd.conf ############" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + if [ -e "$LIGHTTPDFILE" ] + then + while read -r line; do + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + fi + done < "$LIGHTTPDFILE" + echo >> $DEBUG_LOG + else + echo "No lighttpd.conf file found!" >> $DEBUG_LOG + printf ":::\tNo lighttpd.conf file found\n" + fi + + if [ -e "$LIGHTTPDERRFILE" ] + then + echo "#######################################" >> $DEBUG_LOG + echo "######### lighttpd error.log ##########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG + else + echo "No lighttpd error.log file found!" >> $DEBUG_LOG + printf ":::\tNo lighttpd error.log file found\n" + fi + echo >> $DEBUG_LOG +} + ### END FUNCTIONS ### ### Check Pi internet connections ### @@ -152,6 +185,7 @@ compareWhitelist compareBlacklist testNslookup checkProcesses +debugLighttpd echo "::: Writing dnsmasq.conf to debug log..." echo "#######################################" >> $DEBUG_LOG @@ -178,7 +212,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG if [ -e "$PIHOLECONFFILE" ] then - #cat "$PIHOLECONFFILE" >> $DEBUG_LOG while read -r line; do if [ ! -z "$line" ]; then [[ "$line" =~ ^#.*$ ]] && continue @@ -191,25 +224,6 @@ else printf ":::\tNo 01-pihole.conf file found\n" fi -echo "::: Writing lighttpd.conf to debug log..." -echo "#######################################" >> $DEBUG_LOG -echo "############ lighttpd.conf ############" >> $DEBUG_LOG -echo "#######################################" >> $DEBUG_LOG -if [ -e "$LIGHTTPDFILE" ] -then - #cat "$PIHOLECONFFILE" >> $DEBUG_LOG - while read -r line; do - if [ ! -z "$line" ]; then - [[ "$line" =~ ^#.*$ ]] && continue - echo "$line" >> $DEBUG_LOG - fi - done < "$LIGHTTPDFILE" - echo >> $DEBUG_LOG -else - echo "No lighttpd.conf file found!" >> $DEBUG_LOG - printf ":::\tNo lighttpd.conf file found\n" -fi - echo "::: Writing size of gravity.list to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############ gravity.list #############" >> $DEBUG_LOG @@ -283,7 +297,7 @@ fi # Continuously append the pihole.log file to the pihole_debug.log file function dumpPiHoleLog { - trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT + trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo "#######################################" >> $DEBUG_LOG echo "############# pihole.log ##############" >> $DEBUG_LOG From a6bee76581a144cc170df47e59a63d99d7bb8f9f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 12 Apr 2016 08:24:34 +0100 Subject: [PATCH 197/311] add location of debug log output file! --- advanced/Scripts/piholeDebug.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 364abde4..0796310a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -316,7 +316,8 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "::: Finshed debugging!" + echo "::: Finshed debugging!" + echo "::: Debug log can be found at : /var/log/pihole_debug.log" } trap finalWork EXIT From d10e9b1b6e06ed9d109094234e08b285618c7b46 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 12 Apr 2016 08:47:30 +0100 Subject: [PATCH 198/311] add pihole/webui version numbers --- advanced/Scripts/piholeDebug.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 0796310a..263fe9cd 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -54,6 +54,19 @@ else fi ### Private functions exist here ### +function versionCheck { + echo "#######################################" >> $DEBUG_LOG + echo "########## Versions Section ###########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + + TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) + echo "Pi-hole Version: $TMP" >> $DEBUG_LOG + + TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0) + echo "WebUI Version: $TMP" >> $DEBUG_LOG + echo >> $DEBUG_LOG +} + function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then $SUDO touch $WHITELISTMATCHES @@ -181,6 +194,7 @@ echo "Gateway check:" >> $DEBUG_LOG echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG +versionCheck compareWhitelist compareBlacklist testNslookup From 4c890ab2022e2adfbe368ee02c643947cd812bac Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 13 Apr 2016 15:50:48 +0100 Subject: [PATCH 199/311] Add root check to blacklist script --- advanced/Scripts/blacklist.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index aa98f011..c178d9a1 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -10,6 +10,21 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +#rootcheck +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 + if [[ $# = 0 ]]; then helpFunc fi @@ -54,7 +69,7 @@ function helpFunc() echo "::: Immediately blacklists one or more domains in the hosts file" echo ":::" echo ":::" - echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" + echo "::: Usage: pihole -b domain1 [domain2 ...]" echo "::: Options:" echo "::: -d, --delmode Remove domains from the blacklist" echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" @@ -166,10 +181,10 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - sudo service dnsmasq start + $SUDO service dnsmasq start fi echo " done!" } From 77f4126f9b06596f967d4dd61fd0c3c823b95244 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 13 Apr 2016 15:51:48 +0100 Subject: [PATCH 200/311] add root check to whitelist script --- advanced/Scripts/whitelist.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index e69e8804..651ff4d4 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -10,6 +10,21 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +#rootcheck +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 + if [[ $# = 0 ]]; then helpFunc fi @@ -52,7 +67,7 @@ function helpFunc() { echo "::: Immediately whitelists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" + echo "::: Usage: pihole -w domain1 [domain2 ...]" echo ":::" echo "::: Options:" echo "::: -d, --delmode Remove domains from the whitelist" @@ -179,10 +194,10 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - sudo service dnsmasq start + $SUDO service dnsmasq start fi echo " done!" } From 3d4bff9414342cb20380749bf1509dc744491e55 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 10:56:49 +0100 Subject: [PATCH 201/311] Add -s switch to kill command to increase compatability --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index c178d9a1..a2f71db7 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 651ff4d4..801ab9a2 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index ac9cd629..1a45de45 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start From 4941a657bf9e1abfa27df85a4f79981afc03a6ac Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 12:59:40 +0100 Subject: [PATCH 202/311] remove -s switch, as it turns out it worked afterall. --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index a2f71db7..c178d9a1 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 801ab9a2..651ff4d4 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index 1a45de45..ac9cd629 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start From ad574f5e9084f65a1b5450bb95807f035174de5e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 15:52:38 +0100 Subject: [PATCH 203/311] Replace kill with killall --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index c178d9a1..033289ba 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 651ff4d4..a525b24a 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index ac9cd629..ffcbf342 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start From b58519b974251e3bba7a40df78e1229d2c2482eb Mon Sep 17 00:00:00 2001 From: Mayur Raiturkar Date: Sun, 17 Apr 2016 18:21:32 +0530 Subject: [PATCH 204/311] fixed helpFunc 1 --- advanced/Scripts/blacklist.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index aa98f011..ae9cee16 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -10,9 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -if [[ $# = 0 ]]; then - helpFunc -fi #globals basename=pihole @@ -65,6 +62,10 @@ function helpFunc() exit 1 } +if [[ $# = 0 ]]; then + helpFunc +fi + 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/') From 56ac04c48e8c867a1ec2b1b1cdd1b0571b749735 Mon Sep 17 00:00:00 2001 From: Mayur Raiturkar Date: Sun, 17 Apr 2016 18:22:06 +0530 Subject: [PATCH 205/311] fixed helpFunc 2 --- advanced/Scripts/whitelist.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index e69e8804..8e9fa9c7 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -10,9 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -if [[ $# = 0 ]]; then - helpFunc -fi #globals basename=pihole @@ -64,6 +61,10 @@ function helpFunc() exit 1 } +if [[ $# = 0 ]]; then + helpFunc +fi + 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/') From c7141966475985a5675597428b8d136b6dd8268d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 17 Apr 2016 22:46:06 -0400 Subject: [PATCH 206/311] Add Sudoer file for WebUI --- advanced/pihole.sudo | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 advanced/pihole.sudo diff --git a/advanced/pihole.sudo b/advanced/pihole.sudo new file mode 100755 index 00000000..ef06249a --- /dev/null +++ b/advanced/pihole.sudo @@ -0,0 +1,12 @@ +# Pi-hole: A black hole for Internet advertisements +# (c) 2015, 2016 by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# Allows the WebUI to use Pi-hole commands +# +# 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. + +www-data ALL=NOPASSWD: /usr/local/bin/pihole From d7abbbfac43bad3aa4c7bfd8db742140981e0a43 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 17 Apr 2016 22:49:47 -0400 Subject: [PATCH 207/311] Change mode of sudoer file --- advanced/pihole.sudo | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 advanced/pihole.sudo diff --git a/advanced/pihole.sudo b/advanced/pihole.sudo old mode 100755 new mode 100644 From 09cdf5081c8f7a1f728c2932aea24b8d547fbcf7 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 17 Apr 2016 23:03:12 -0400 Subject: [PATCH 208/311] Install sudoer file --- automated install/basic-install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 139a7a4b..ca8f1aae 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -636,6 +636,11 @@ installPiholeWeb() { $SUDO cp /etc/.pihole/advanced/index.* /var/www/html/pihole/. $SUDO echo " done!" fi + # Install Sudoer file + echo -n "::: Installing sudoer file..." + $SUDO cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole + $SUDO chmod 0440 /etc/sudoers.d/pihole + echo " done!" } installCron() { From 24de6d6fc9a82dbbbb74ecc1225ba92b5ca5ded9 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 20 Apr 2016 21:43:01 -0400 Subject: [PATCH 209/311] Allow sudoers file to be uninstalled --- automated install/uninstall.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 484a544d..19f416b2 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -122,8 +122,9 @@ function removeNoPurge { $SUDO rm -rf /etc/.pihole/ &> /dev/null $SUDO rm -rf /opt/pihole/ &> /dev/null $SUDO rm /usr/local/bin/pihole &> /dev/null - $SUDO rm /etc/bash_completion.d/pihole - + $SUDO rm /etc/bash_completion.d/pihole &> /dev/null + $SUDO rm /etc/sudoers.d/pihole &> /dev/null + echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n" From 81fdfcba22868357017aa8288473bd17baa762b2 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Thu, 21 Apr 2016 23:40:38 +0800 Subject: [PATCH 210/311] Update whitelist.sh --- advanced/Scripts/whitelist.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 92db9afe..23a72fae 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -42,12 +42,19 @@ verbose=true domList=() domToRemoveList=() +piholeIPfile=/tmp/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 -# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script -IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') -piholeIP=${piholeIPCIDR%/*} +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 + piholeIP=$(cat $piholeIPfile) + #rm $piholeIPfile +else + # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script + IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') + piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') + piholeIP=${piholeIPCIDR%/*} +fi modifyHost=false From a5ad48aa1843e4b24eec63fdd0411769b0fa16a5 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Thu, 21 Apr 2016 23:40:44 +0800 Subject: [PATCH 211/311] Update gravity.sh --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ffcbf342..0538405e 100755 --- a/gravity.sh +++ b/gravity.sh @@ -38,7 +38,7 @@ blacklistScript=/opt/pihole/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 piholeIP=$(cat $piholeIPfile) - rm $piholeIPfile + #rm $piholeIPfile else # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') From 08e95ed606bbb0d1e027d8b3ccbcc16793f45556 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Fri, 22 Apr 2016 01:40:42 +0800 Subject: [PATCH 212/311] Update gravity.sh Change piholeIPfile to a permanent location. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 0538405e..ce04e181 100755 --- a/gravity.sh +++ b/gravity.sh @@ -27,7 +27,7 @@ else fi fi -piholeIPfile=/tmp/piholeIP +piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 adListFile=/etc/pihole/adlists.list From 10066209e72d50b01e601f315661c381642ec93f Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Fri, 22 Apr 2016 01:41:11 +0800 Subject: [PATCH 213/311] Update whitelist.sh Change piholeIPfile to a permanent location. --- advanced/Scripts/whitelist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 23a72fae..b927615e 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -42,7 +42,7 @@ verbose=true domList=() domToRemoveList=() -piholeIPfile=/tmp/piholeIP +piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 if [[ -f $piholeIPfile ]];then From 08e6f60941f3a6486e038421b5d887c324664728 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Fri, 22 Apr 2016 01:42:43 +0800 Subject: [PATCH 214/311] Update blacklist.sh --- advanced/Scripts/blacklist.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f7a18eae..e28188eb 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -42,12 +42,19 @@ verbose=true domList=() domToRemoveList=() +piholeIPfile=/etc/pihole/piholeIP piholeIPv6file=/etc/pihole/.useIPv6 -# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script -IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') -piholeIP=${piholeIPCIDR%/*} +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 + piholeIP=$(cat $piholeIPfile) + #rm $piholeIPfile +else + # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script + IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') + piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') + piholeIP=${piholeIPCIDR%/*} +fi modifyHost=false From 221b72439b2b3069735af706a611b44119ab9de4 Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Fri, 22 Apr 2016 01:46:27 +0800 Subject: [PATCH 215/311] Update basic-install.sh --- 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 139a7a4b..0f05ab63 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -255,8 +255,8 @@ It is also possible to use a DHCP reservation, but if you are going to do that, IP address: $IPv4addr Gateway: $IPv4gw" $r $c)then # If the settings are correct, then we need to set the piholeIP - # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script - echo "${IPv4addr%/*}" > /tmp/piholeIP + # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script. piholeIP is saved to a permanent file so gravity.sh can use it when updating + echo "${IPv4addr%/*}" > /etc/pihole/piholeIP echo "$piholeInterface" > /tmp/piholeINT # After that's done, the loop ends and we move on ipSettingsCorrect=True From d7de5b2afabf35c8c0175875c2fc991be65c3757 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 23 Apr 2016 15:56:14 -0500 Subject: [PATCH 216/311] link to pihole menubar --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 851e1639..940fe636 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) [![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) ## Pi-hole Projects +- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) - [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/) - [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) - [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) From 00cc480bc1f69eb00e79b26769b7993079d9697d Mon Sep 17 00:00:00 2001 From: Jim Liu Date: Tue, 26 Apr 2016 16:10:51 +0800 Subject: [PATCH 217/311] Update basic-install.sh --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0f05ab63..bf3d855a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -235,6 +235,8 @@ getStaticIPv4Settings() { whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c + #piholeIP is saved to a permanent file so gravity.sh can use it when updating + echo "${IPv4addr%/*}" > /etc/pihole/piholeIP # Nothing else to do since the variables are already set above else # Otherwise, we need to ask the user to input their desired settings. From 2209beff8a05f5d56e929b3eb3574f9734236863 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 29 Apr 2016 21:09:41 -0500 Subject: [PATCH 218/311] adding links to optimal.com Also added image of Pi-hole's stats from Optimal.com and a bitcoin donation address per some user requests. --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 851e1639..e9c68882 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,15 @@ chmod +x 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 -[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") +Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. + +| Paypal | Bitcoin | Optimal.com | +| ------ | ------- | -------- | +| [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") |
![1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX](http://todobom.com/images/bitcoin-donations.png)
1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX
| Sign up for [Optimal.com using our link](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) to provide us with a small monthly amount. Your money will also support content-creators. + +[![Support Pi-hole by using Optimal.com](http://i.imgur.com/m8GN3Zv.png)](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) +![](http) + ## Catch us out on the net: Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) @@ -61,7 +69,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) ## Partnering With Optimal.com -Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/). +Sign up for Optimal.com's service [using our link](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F). This service splits your money between your favorite ad blockers and free Websites. This allows you to block ads while still supporting those sites that currently depend on ads for revenue. ## Technical Details From 7bc2844b9d01269db9af6e4d2a57a7640d0dc826 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 2 May 2016 18:51:02 -0400 Subject: [PATCH 219/311] Remove X-Pi-hole header Also adds `X-Frame-Options: DENY` for the admin directory, so that an ad can't load it into a frame --- advanced/lighttpd.conf | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf index 124371a9..761f9a24 100644 --- a/advanced/lighttpd.conf +++ b/advanced/lighttpd.conf @@ -46,13 +46,11 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl" # If the URL starts with /admin, it is the Web interface $HTTP["url"] =~ "^/admin/" { # Create a response header for debugging using curl -I - setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" ) + setenv.add-response-header = ( "X-Frame-Options" => "DENY" ) } # If the URL does not start with /admin, then it is a query for an ad domain $HTTP["url"] =~ "^(?!/admin)/.*" { - # Create a response header for debugging using curl -I - setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) - # rewrite only js requests - url.rewrite = ("(.*).js" => "pihole/index.js") + # rewrite only js requests + url.rewrite = ("(.*).js" => "pihole/index.js") } From f03303e5aa4523071b92ef44ccc2ee5c1c9281fe Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 3 May 2016 11:58:13 -0400 Subject: [PATCH 220/311] Add X-Pi-hole header --- advanced/lighttpd.conf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf index 761f9a24..f899350a 100644 --- a/advanced/lighttpd.conf +++ b/advanced/lighttpd.conf @@ -46,11 +46,16 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl" # If the URL starts with /admin, it is the Web interface $HTTP["url"] =~ "^/admin/" { # Create a response header for debugging using curl -I - setenv.add-response-header = ( "X-Frame-Options" => "DENY" ) + setenv.add-response-header = ( + "X-Pi-hole" => "The Pi-hole Web interface is working!", + "X-Frame-Options" => "DENY" + ) } # If the URL does not start with /admin, then it is a query for an ad domain $HTTP["url"] =~ "^(?!/admin)/.*" { + # Create a response header for debugging using curl -I + setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) # rewrite only js requests url.rewrite = ("(.*).js" => "pihole/index.js") } From c0e1772e211da9cfdcf3266c18401e1d23720326 Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Sat, 7 May 2016 11:44:18 -0700 Subject: [PATCH 221/311] Replace toilet with echo --- advanced/Scripts/chronometer.sh | 6 +++++- automated install/basic-install.sh | 2 +- automated install/uninstall.sh | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 1c8a53c9..806093e1 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -84,7 +84,11 @@ function normalChrono(){ do clear # Displays a colorful Pi-hole logo - toilet -f small -F gay Pi-hole + echo " ___ _ _ _" + echo "| _ (_)___| |_ ___| |___" + echo "| _/ |___| ' \/ _ \ / -_)" + echo "|_| |_| |_||_\___/_\___|" + echo "" echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" echo "" uptime | cut -d' ' -f11- diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bf3d855a..84b05342 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -548,7 +548,7 @@ checkForDependencies() { echo ":::" echo "::: Checking dependencies:" - dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) for i in "${dependencies[@]}"; do echo -n "::: Checking for $i..." if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 484a544d..2d32b52d 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -44,7 +44,7 @@ function removeAndPurge { # Purge dependencies echo ":::" # Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common - dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common git curl unzip wget ) + dependencies=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget ) for i in "${dependencies[@]}"; do if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then while true; do From b7e27bf6b45c2063d8372beea9b4187dc205e0f9 Mon Sep 17 00:00:00 2001 From: David Torcivia Date: Wed, 11 May 2016 18:24:43 -0400 Subject: [PATCH 222/311] Fix basic install for Proxmox LXC Fixed basic installer to properly bind to eth0 when install to a Proxmox LXC. --- 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 bf3d855a..528c46bf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -43,7 +43,7 @@ IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1 IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') -availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1) +availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1) dhcpcdFile=/etc/dhcpcd.conf ######## FIRST CHECK ######## From 892a90bf5117079d692dcf4972c211fce6d8b610 Mon Sep 17 00:00:00 2001 From: crazy-max Date: Sun, 15 May 2016 13:51:35 +0200 Subject: [PATCH 223/311] New URL for Windows 10 Telemetry list. --- adlists.default | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adlists.default b/adlists.default index 837f612a..e535f5d7 100644 --- a/adlists.default +++ b/adlists.default @@ -1,7 +1,7 @@ -## Pi-hole ad-list default sources. Updated 21/02/2016 ######################### +## Pi-hole ad-list default sources. Updated 15/05/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 # # # @@ -32,7 +32,7 @@ http://hosts-file.net/ad_servers.txt #http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt # Windows 10 telemetry list -#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt +#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hosts/hostsBlockWindowsSpy.txt # Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc) #http://securemecca.com/Downloads/hosts.txt From b5529e5138a173633a037176534d63fe417858ab Mon Sep 17 00:00:00 2001 From: crazy-max Date: Sun, 22 May 2016 01:30:32 +0200 Subject: [PATCH 224/311] Update 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 e535f5d7..bf7197e6 100644 --- a/adlists.default +++ b/adlists.default @@ -1,4 +1,4 @@ -## Pi-hole ad-list default sources. Updated 15/05/2016 ######################### +## Pi-hole ad-list default sources. Updated 22/05/2016 ######################### # # # To make changes to this file: # # 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` # @@ -32,7 +32,7 @@ http://hosts-file.net/ad_servers.txt #http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt # Windows 10 telemetry list -#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hosts/hostsBlockWindowsSpy.txt +#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hosts/windows10_spy.txt # Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc) #http://securemecca.com/Downloads/hosts.txt From 3fda2d9ac3017b5adb2b011ef06c43d3e73801bb Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 25 May 2016 17:07:12 -0400 Subject: [PATCH 225/311] Fix helpfunc not found error --- advanced/Scripts/blacklist.sh | 37 +++++++++++++++-------------------- advanced/Scripts/whitelist.sh | 37 +++++++++++++++-------------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index e28188eb..7e99f830 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -25,6 +25,22 @@ else fi fi +function helpFunc() +{ + echo "::: Immediately blacklists one or more domains in the hosts file" + echo ":::" + echo ":::" + echo "::: Usage: pihole -b domain1 [domain2 ...]" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the blacklist" + echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your blacklisted domains" + exit 1 +} + if [[ $# = 0 ]]; then helpFunc fi @@ -70,27 +86,6 @@ if [[ -f $piholeIPv6file ]];then piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') fi - -function helpFunc() -{ - echo "::: Immediately blacklists one or more domains in the hosts file" - echo ":::" - echo ":::" - echo "::: Usage: pihole -b domain1 [domain2 ...]" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the blacklist" - echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your blacklisted domains" - exit 1 -} - -if [[ $# = 0 ]]; then - helpFunc -fi - 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/') diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b927615e..37b4ade4 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -25,6 +25,22 @@ else fi fi +function helpFunc() +{ + echo "::: Immediately whitelists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: pihole -w domain1 [domain2 ...]" + echo ":::" + echo "::: Options:" + echo "::: -d, --delmode Remove domains from the whitelist" + echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" + echo "::: -f, --force Force updating of the hosts files, even if there are no changes" + echo "::: -q, --quiet output is less verbose" + echo "::: -h, --help Show this help dialog" + echo "::: -l, --list Display your whitelisted domains" + exit 1 +} + if [[ $# = 0 ]]; then helpFunc fi @@ -69,27 +85,6 @@ if [[ -f $piholeIPv6file ]];then piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') fi - -function helpFunc() -{ - echo "::: Immediately whitelists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: pihole -w domain1 [domain2 ...]" - echo ":::" - echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" - echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" - echo "::: -f, --force Force updating of the hosts files, even if there are no changes" - echo "::: -q, --quiet output is less verbose" - echo "::: -h, --help Show this help dialog" - echo "::: -l, --list Display your whitelisted domains" - exit 1 -} - -if [[ $# = 0 ]]; then - helpFunc -fi - 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/') From 6cf446032f488fb43249ef4e3f9980712a2a9aa4 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 25 May 2016 18:55:36 -0400 Subject: [PATCH 226/311] Show web interface URL after install --- automated install/basic-install.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8db92fd4..05db1681 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -698,12 +698,13 @@ displayFinalMessage() { # Final completion message to user whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: -IPv4: $IPv4addr +IPv4: ${IPv4addr%/*} IPv6: $piholeIPv6 If you set a new IP address, you should restart the Pi. -The install log is in /etc/pihole." $r $c +The install log is in /etc/pihole. +View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" $r $c } ######## SCRIPT ############ @@ -740,10 +741,10 @@ echo " done." echo ":::" echo "::: Installation Complete! Configure your devices to use the Pi-hole as their DNS server using:" -echo "::: $IPv4addr" +echo "::: ${IPv4addr%/*}" echo "::: $piholeIPv6" echo ":::" echo "::: If you set a new IP address, you should restart the Pi." -echo "::: " +echo ":::" echo "::: The install log is located at: /etc/pihole/install.log" - +echo "::: View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" From 4541da1f17965c98f7218e0611a66c060f73ecbb Mon Sep 17 00:00:00 2001 From: crazy-max Date: Fri, 3 Jun 2016 17:10:36 +0200 Subject: [PATCH 227/311] Update URL for Windows 10 Telemetry list --- adlists.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adlists.default b/adlists.default index bf7197e6..02d9b92c 100644 --- a/adlists.default +++ b/adlists.default @@ -32,7 +32,7 @@ http://hosts-file.net/ad_servers.txt #http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt # Windows 10 telemetry list -#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hosts/windows10_spy.txt +#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt # Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc) #http://securemecca.com/Downloads/hosts.txt From dc2a537f6bf4891008d69c5d97b6fa1641740c7a Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 10 Jun 2016 17:47:27 -0500 Subject: [PATCH 228/311] copy sudoers file necessary for Web interface white/black list functionality. --- 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 8d6fde69..55f886b3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -110,7 +110,7 @@ welcomeDialogs() { # 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. - + In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } @@ -466,6 +466,7 @@ installScripts() { $SUDO chown "$USER":root /opt/pihole $SUDO chmod u+srwx /opt/pihole fi + $SUDO cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh From 1c53ad68763e8900ab4b92396354af1a72ca438b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 10 Jun 2016 18:20:53 -0500 Subject: [PATCH 229/311] mcat is smarter than me He already added this. --- automated install/basic-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 55f886b3..c9262835 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -466,7 +466,6 @@ installScripts() { $SUDO chown "$USER":root /opt/pihole $SUDO chmod u+srwx /opt/pihole fi - $SUDO cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole $SUDO cp /etc/.pihole/gravity.sh /opt/pihole/gravity.sh $SUDO cp /etc/.pihole/advanced/Scripts/chronometer.sh /opt/pihole/chronometer.sh $SUDO cp /etc/.pihole/advanced/Scripts/whitelist.sh /opt/pihole/whitelist.sh From 1e0666d1ef232910e637fc4a84db719974b8cc62 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Fri, 10 Jun 2016 18:51:38 -0500 Subject: [PATCH 230/311] make folder so file can be deployed --- automated install/basic-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c9262835..6d757964 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -640,6 +640,7 @@ installPiholeWeb() { fi # Install Sudoer file echo -n "::: Installing sudoer file..." + $SUDO mkdir -p /etc/sudoers.d/ $SUDO cp /etc/.pihole/advanced/pihole.sudo /etc/sudoers.d/pihole $SUDO chmod 0440 /etc/sudoers.d/pihole echo " done!" From 1194e48bd848d3c901cb8331e39c11a68137539a Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 11 Jun 2016 13:08:43 -0500 Subject: [PATCH 231/311] install sudo sudo is needed for the sudoers file to work, which is how the Web interface executes the pihole commands. --- 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 6d757964..7a8fad40 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -58,7 +58,7 @@ else if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else - echo "::: Please install sudo or run this as root." + echo "::: sudo will be installed. It is needed for the Web interface to run pihole commands." exit 1 fi fi @@ -548,7 +548,7 @@ checkForDependencies() { echo ":::" echo "::: Checking dependencies:" - dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo) for i in "${dependencies[@]}"; do echo -n "::: Checking for $i..." if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then From 13a479a9f6cdb4daa4f9335246eb1a928519ee1c Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 11 Jun 2016 13:21:08 -0500 Subject: [PATCH 232/311] tell user to run as root since you can't install sudo as a non-root user, the script needs to be run as root in order to install it. --- 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 7a8fad40..699f68ee 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -58,7 +58,7 @@ else if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else - echo "::: sudo will be installed. It is needed for the Web interface to run pihole commands." + echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed." exit 1 fi fi From 366fcf76f6213a9ac8cd1ca2d58a098c3d6b038a Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 11 Jun 2016 15:05:11 -0500 Subject: [PATCH 233/311] simplified and new additions I tried to simplify the readme page a bit. I also added some new links to some helper videos and added some screenshots of the whitelist editor. --- README.md | 107 +++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 3f120f2b..6f848f28 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ # Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) - -[![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - 1. Install Raspbian 2. Run the command below @@ -19,6 +16,15 @@ chmod +x 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/). +## How To Install Pi-hole + +[![60-second install tutorial](http://i.imgur.com/lVyNWTC.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) + +## How Does It Work? +**Watch the 60-second video below to get a quick overview** + +[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://youtu.be/L2iVKs0v0Tk) + ## Pi-hole Is Free, But Powered By Your Donations Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. @@ -26,19 +32,51 @@ Send a one-time donation or sign up for Optimal.com's service using our link bel | ------ | ------- | -------- | | [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") |
![1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX](http://todobom.com/images/bitcoin-donations.png)
1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX
| Sign up for [Optimal.com using our link](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) to provide us with a small monthly amount. Your money will also support content-creators. -[![Support Pi-hole by using Optimal.com](http://i.imgur.com/m8GN3Zv.png)](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) -![](http) +## Get Help Or Connect With Us On The Web +- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) +- [/r/pihole](https://www.reddit.com/r/pihole/) +- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) +- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) +- [FAQs](https://pi-hole.net/help/) +- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -## Catch us out on the net: -Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) +## Technical Details -reddit: [/r/pihole](https://www.reddit.com/r/pihole/) +The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. -## How Does It Work? -**Watch the 60-second video below to get a quick overview** +### Gravity +The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). -[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) +## Web Interface +The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: + +`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` + +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) + +### Whitelist and blacklist + +Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details +![Whitelist editor in the Web interface](http://i.imgur.com/Anj1GzO.png) + +## API + +A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: +```JSON +{ + "domains_being_blocked": "136708", + "dns_queries_today": "18108", + "ads_blocked_today": "14648", + "ads_percentage_today": "80.89" +} +``` +The same output can be acheived on the CLI by running `chronometer.sh -j` + +## Real-time Statistics + +You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). +![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) ## Pi-hole Projects - [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) @@ -68,52 +106,5 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) - [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) - [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) -## Partnering With Optimal.com - -Sign up for Optimal.com's service [using our link](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F). This service splits your money between your favorite ad blockers and free Websites. This allows you to block ads while still supporting those sites that currently depend on ads for revenue. - -## Technical Details - -The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. - -A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). - -## Gravity -The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). - -## Whitelist and blacklist -Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details - -## Web Interface -The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: - -`http://192.168.1.x/admin/index.php` - -![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) - -### API - -A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: -```JSON -{ - "domains_being_blocked": "136708", - "dns_queries_today": "18108", - "ads_blocked_today": "14648", - "ads_percentage_today": "80.89" -} -``` -The same output can be acheived on the CLI by running `chronometer.sh -j` - -![Web](http://i.imgur.com/m114SCn.png) - -## Real-time Statistics - -You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). -![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) - -## Help -- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details -- There is also an [FAQ section on pi-hole.net](http://pi-hole.net) - ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. From 42afaa9f66668de4900997b1393e98bed0635bad Mon Sep 17 00:00:00 2001 From: bcambl Date: Mon, 25 Apr 2016 17:31:00 -0600 Subject: [PATCH 234/311] remove dpkg-query dependency from sudo check --- 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 699f68ee..3cff09a6 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -55,7 +55,7 @@ else echo "::: sudo will be used for the install." # Check if it is actually installed # If it isn't, exit because the install cannot complete - if [[ $(dpkg-query -s sudo) ]];then + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: sudo is needed for the Web interface to run pihole commands. Please run this script as root and it will be automatically installed." From 063e3e85e16620bf15c48f4cd25a0953bb472af5 Mon Sep 17 00:00:00 2001 From: bcambl Date: Mon, 25 Apr 2016 22:51:00 -0600 Subject: [PATCH 235/311] Fedora compatibility variables and dependencies --- automated install/basic-install.sh | 58 ++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3cff09a6..edc9ee74 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -63,6 +63,35 @@ else fi fi +# Compatability +if [ -x "$(command -v rpm)" ];then + # Fedora Family + if [ -x "$(command -v dnf)" ];then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi + PKG_CACHE="/var/cache/$PKG_MANAGER" + PKG_UPDATE="$PKG_MANAGER update -y" + PKG_INSTALL="$PKG_MANAGER install -y" + PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) + package_check() { + rpm -qa | grep ^$1- > /dev/null + } +elif [ -x "$(command -v apt-get)" ];then + # Debian Family + PKG_MANAGER="apt-get" + PKG_CACHE="/var/cache/apt" + PKG_UPDATE="apt-get -qq update" + PKG_INSTALL="apt-get -y -qq install" + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + package_check() { + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" + } +else + echo "OS distribution not supported" + exit +fi ####### FUNCTIONS ########## spinner() @@ -521,16 +550,15 @@ checkForDependencies() { # if so, advise the user to run apt-get update/upgrade at their own discretion #Check to see if apt-get update has already been run today # it needs to have been run at least once on new installs! - - timestamp=$(stat -c %Y /var/cache/apt/) + timestamp=$(stat -c %Y $PKG_CACHE) timestampAsDate=$(date -d @"$timestamp" "+%b %e") today=$(date "+%b %e") if [ ! "$today" == "$timestampAsDate" ]; then #update package lists echo ":::" - echo -n "::: apt-get update has not been run today. Running now..." - $SUDO apt-get -qq update & spinner $! + echo -n "::: $PKG_MANAGER update has not been run today. Running now..." + $SUDO $PKG_UPDATE & spinner $! echo " done!" fi echo ":::" @@ -548,17 +576,17 @@ checkForDependencies() { echo ":::" echo "::: Checking dependencies:" - dependencies=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo) - for i in "${dependencies[@]}"; do - echo -n "::: Checking for $i..." - if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then - echo -n " Not found! Installing...." - $SUDO apt-get -y -qq install "$i" > /dev/null & spinner $! - echo " done!" - else - echo " already installed!" - fi - done + for i in "${PIHOLE_DEPS[@]}"; do + echo -n "::: Checking for $i..." + package_check $i > /dev/null + if ! [ $? -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO $PKG_INSTALL "$i" > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi + done } getGitFiles() { From 37dda79db28b85210e82b27ff47883c38a703753 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 30 Apr 2016 18:11:37 -0600 Subject: [PATCH 236/311] install dependencies for install script --- automated install/basic-install.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index edc9ee74..60482f8a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -72,8 +72,9 @@ if [ -x "$(command -v rpm)" ];then PKG_MANAGER="yum" fi PKG_CACHE="/var/cache/$PKG_MANAGER" - PKG_UPDATE="$PKG_MANAGER update -y" + PKG_UPDATE="$PKG_MANAGER check-update -q" PKG_INSTALL="$PKG_MANAGER install -y" + INSTALLER_DEPS=( iproute procps-ng newt ) PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) package_check() { rpm -qa | grep ^$1- > /dev/null @@ -84,6 +85,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_CACHE="/var/cache/apt" PKG_UPDATE="apt-get -qq update" PKG_INSTALL="apt-get -y -qq install" + INSTALLER_DEPS=( apt-utils whiptail ) PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" @@ -93,6 +95,20 @@ else exit fi +echo "::: Checking installer dependencies..." +for i in "${INSTALLER_DEPS[@]}"; do + echo -n "::: Checking for $i..." + package_check $i > /dev/null + if ! [ $? -eq 0 ]; then + $SUDO $PKG_UPDATE + echo -n " Not found! Installing...." + $SUDO $PKG_INSTALL "$i" > /dev/null + echo " done!" + else + echo " already installed!" + fi +done + ####### FUNCTIONS ########## spinner() { From 29d48bbd9a5c015c20b4c7dd12a933824e38a2be Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 30 Apr 2016 20:27:38 -0600 Subject: [PATCH 237/311] move IP/route discovery to a function Defer use of 'ip' utility until after install script dependencies have been satisfied. --- automated install/basic-install.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 60482f8a..dd916191 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -36,16 +36,6 @@ columns=$(tput cols) r=$(( rows / 2 )) c=$(( columns / 2 )) - -# Find IP used to route to outside world - -IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') -IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') -IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') - -availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1) -dhcpcdFile=/etc/dhcpcd.conf - ######## FIRST CHECK ######## # Must be root to install echo ":::" @@ -75,7 +65,7 @@ if [ -x "$(command -v rpm)" ];then PKG_UPDATE="$PKG_MANAGER check-update -q" PKG_INSTALL="$PKG_MANAGER install -y" INSTALLER_DEPS=( iproute procps-ng newt ) - PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) + PIHOLE_DEPS=( dhcpcd bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) package_check() { rpm -qa | grep ^$1- > /dev/null } @@ -125,6 +115,15 @@ spinner() printf " \b\b\b\b" } +findIPRoute() { + # Find IP used to route to outside world + IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') + IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') + IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') + availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1) + dhcpcdFile=/etc/dhcpcd.conf +} + backupLegacyPihole() { # This function detects and backups the pi-hole v1 files. It will not do anything to the current version files. if [[ -f /etc/dnsmasq.d/adList.conf ]];then @@ -767,6 +766,8 @@ 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 IP used to route to outside world +findIPRoute # Find interfaces and let the user choose one chooseInterface # Let the user decide if they want to block ads over IPv4 and/or IPv6 From ffaf243160c8c4abf808a3c722b412343ae69811 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 00:27:46 -0600 Subject: [PATCH 238/311] split dependency installations into two separate functions - installerDependencies: - updates the package manager list/cache - installs dependencies for install script - checkForDependencies: - install dependencies for Pi-Hole --- automated install/basic-install.sh | 58 +++++++++++++++++------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index dd916191..28ebd4f3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -62,8 +62,10 @@ if [ -x "$(command -v rpm)" ];then PKG_MANAGER="yum" fi PKG_CACHE="/var/cache/$PKG_MANAGER" - PKG_UPDATE="$PKG_MANAGER check-update -q" + UPDATE_PKG_CACHE="$PKG_MANAGER check-update -q" + PKG_UPDATE="$PKG_MANAGER update -y" PKG_INSTALL="$PKG_MANAGER install -y" + PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt ) PIHOLE_DEPS=( dhcpcd bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) package_check() { @@ -73,10 +75,12 @@ elif [ -x "$(command -v apt-get)" ];then # Debian Family PKG_MANAGER="apt-get" PKG_CACHE="/var/cache/apt" - PKG_UPDATE="apt-get -qq update" + UPDATE_PKG_CACHE="apt-get -qq update" + PKG_UPDATE="$PKG_MANAGER upgrade" PKG_INSTALL="apt-get -y -qq install" + PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail ) - PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } @@ -85,20 +89,6 @@ else exit fi -echo "::: Checking installer dependencies..." -for i in "${INSTALLER_DEPS[@]}"; do - echo -n "::: Checking for $i..." - package_check $i > /dev/null - if ! [ $? -eq 0 ]; then - $SUDO $PKG_UPDATE - echo -n " Not found! Installing...." - $SUDO $PKG_INSTALL "$i" > /dev/null - echo " done!" - else - echo " already installed!" - fi -done - ####### FUNCTIONS ########## spinner() { @@ -558,7 +548,7 @@ stopServices() { $SUDO echo " done." } -checkForDependencies() { +installerDependencies() { #Running apt-get update/upgrade with minimal output can cause some issues with #requiring user input (e.g password for phpmyadmin see #218) #We'll change the logic up here, to check to see if there are any updates availible and @@ -573,23 +563,39 @@ checkForDependencies() { #update package lists echo ":::" echo -n "::: $PKG_MANAGER update has not been run today. Running now..." - $SUDO $PKG_UPDATE & spinner $! + $SUDO $UPDATE_PKG_CACHE > /dev/null 2>&1 echo " done!" fi echo ":::" - echo -n "::: Checking apt-get for upgraded packages...." - updatesToInstall=$($SUDO apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) - echo " done!" + echo -n "::: Checking $PKG_MANAGER for upgraded packages...." + updatesToInstall=$(eval "$SUDO $PKG_COUNT") + echo " done!" echo ":::" if [[ $updatesToInstall -eq "0" ]]; then echo "::: Your pi is up to date! Continuing with pi-hole installation..." else echo "::: There are $updatesToInstall updates availible for your pi!" - echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " + echo "::: We recommend you run '$PKG_UPDATE' after installing Pi-Hole! " echo ":::" fi echo ":::" - echo "::: Checking dependencies:" + echo "::: Checking installer dependencies..." + for i in "${INSTALLER_DEPS[@]}"; do + echo -n "::: Checking for $i..." + package_check $i > /dev/null + if ! [ $? -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO $PKG_INSTALL "$i" > /dev/null 2>&1 + echo " done!" + else + echo " already installed!" + fi + done +} + +checkForDependencies() { + # Install dependencies for Pi-Hole + echo "::: Checking Pi-Hole dependencies:" for i in "${PIHOLE_DEPS[@]}"; do echo -n "::: Checking for $i..." @@ -759,6 +765,10 @@ View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" $ ######## SCRIPT ############ # Start the installer $SUDO mkdir -p /etc/pihole/ + +# Install packages used by this installation script +installerDependencies + welcomeDialogs # Verify there is enough disk space for the install From f4228b04f8ef450d96c67a97315ad0a262d2a917 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 00:45:21 -0600 Subject: [PATCH 239/311] additional fedora dependancies based on current fedora (23 at this moment) docker image --- 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 28ebd4f3..cd16ca5c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt ) - PIHOLE_DEPS=( dhcpcd bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget ) + PIHOLE_DEPS=( dhcpcd bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget findutils cronie ) package_check() { rpm -qa | grep ^$1- > /dev/null } From 7af0029175c03814de5466cccce04da2bd5fa603 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 08:45:41 -0600 Subject: [PATCH 240/311] check for systemctl for systemd service management --- automated install/basic-install.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cd16ca5c..a346edd4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -544,7 +544,11 @@ stopServices() { $SUDO echo ":::" $SUDO echo -n "::: Stopping services..." #$SUDO service dnsmasq stop & spinner $! || true - $SUDO service lighttpd stop & spinner $! || true + if [ -x "$(command -v systemctl)" ]; then + $SUDO systemctl stop lighttpd & spinner $! || true + else + $SUDO service lighttpd stop & spinner $! || true + fi $SUDO echo " done." } @@ -796,8 +800,15 @@ displayFinalMessage echo -n "::: Restarting services..." # Start services -$SUDO service dnsmasq restart -$SUDO service lighttpd start + +if [ -x "$(command -v systemctl)" ]; then + $SUDO systemctl restart dnsmasq + $SUDO systemctl start lighttpd +else + $SUDO service dnsmasq restart + $SUDO service lighttpd start +fi + echo " done." echo ":::" From 94f131a0b76ef756726a5c787002b321fc9b7144 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 10:52:46 -0600 Subject: [PATCH 241/311] update deps and package manager variables --- automated install/basic-install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a346edd4..40116ca2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -66,8 +66,8 @@ if [ -x "$(command -v rpm)" ];then PKG_UPDATE="$PKG_MANAGER update -y" PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" - INSTALLER_DEPS=( iproute procps-ng newt ) - PIHOLE_DEPS=( dhcpcd bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget findutils cronie ) + INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) + PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget findutils cronie ) package_check() { rpm -qa | grep ^$1- > /dev/null } @@ -75,9 +75,9 @@ elif [ -x "$(command -v apt-get)" ];then # Debian Family PKG_MANAGER="apt-get" PKG_CACHE="/var/cache/apt" - UPDATE_PKG_CACHE="apt-get -qq update" + UPDATE_PKG_CACHE="$PKG_MANAGER -qq update" PKG_UPDATE="$PKG_MANAGER upgrade" - PKG_INSTALL="apt-get -y -qq install" + PKG_INSTALL="$PKG_MANAGER -y -qq install" PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail ) PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) From d67957d015657a6328cefc418650c8370ba0f85c Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 14:22:51 -0600 Subject: [PATCH 242/311] add fedora lighttpd.conf template --- advanced/lighttpd.conf.fedora | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 advanced/lighttpd.conf.fedora diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora new file mode 100644 index 00000000..7d38f95b --- /dev/null +++ b/advanced/lighttpd.conf.fedora @@ -0,0 +1,77 @@ +# Pi-hole: A black hole for Internet advertisements +# (c) 2015, 2016 by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# lighttpd config for 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. + +server.modules = ( + "mod_access", + "mod_fastcgi", + "mod_accesslog", + "mod_expire", + "mod_compress", + "mod_redirect", + "mod_setenv", + "mod_rewrite" +) + +server.document-root = "/var/www/html" +server.error-handler-404 = "pihole/index.html" +server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) +server.errorlog = "/var/log/lighttpd/error.log" +server.pid-file = "/var/run/lighttpd.pid" +server.username = "lighttpd" +server.groupname = "lighttpd" +server.port = 80 +accesslog.filename = "/var/log/lighttpd/access.log" +accesslog.format = "%{%s}t|%V|%r|%s|%b" + + +index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) +url.access-deny = ( "~", ".inc" ) +static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) + +compress.cache-dir = "/var/cache/lighttpd/compress/" +compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) + +mimetype.assign = ( ".png" => "image/png", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".html" => "text/html", + ".css" => "text/css; charset=utf-8", + ".js" => "application/javascript", + ".json" => "application/json", + ".txt" => "text/plain" ) + +# default listening port for IPv6 falls back to the IPv4 port +#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port +#include_shell "/usr/share/lighttpd/create-mime.assign.pl" +#include_shell "/usr/share/lighttpd/include-conf-enabled.pl" + +fastcgi.server = ( ".php" => + ( "localhost" => + ( + "socket" => "/var/run/lighttpd/php-fastcgi.socket", + "bin-path" => "/usr/bin/php-cgi" + ) + ) + ) + +# If the URL starts with /admin, it is the Web interface +$HTTP["url"] =~ "^/admin/" { + # Create a response header for debugging using curl -I + setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" ) +} + +# If the URL does not start with /admin, then it is a query for an ad domain +$HTTP["url"] =~ "^(?!/admin)/.*" { + # Create a response header for debugging using curl -I + setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." ) + # rewrite only js requests + url.rewrite = ("(.*).js" => "pihole/index.js") +} From b3ec3b487c4d3dc87a21ce601c4b7bc827a6a7b1 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 14:26:43 -0600 Subject: [PATCH 243/311] add Fedora dependency: lighttpd-fastcgi --- 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 40116ca2..495eea5d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) - PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd php-common php-cli php git curl unzip wget findutils cronie ) + PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) package_check() { rpm -qa | grep ^$1- > /dev/null } From 6f2117d786acaf51938718871f58826fe8e790b8 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 15:06:57 -0600 Subject: [PATCH 244/311] append '.debian' to lighttpd.conf for compatability --- advanced/{lighttpd.conf => lighttpd.conf.debian} | 6 +++--- automated install/basic-install.sh | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) rename advanced/{lighttpd.conf => lighttpd.conf.debian} (97%) diff --git a/advanced/lighttpd.conf b/advanced/lighttpd.conf.debian similarity index 97% rename from advanced/lighttpd.conf rename to advanced/lighttpd.conf.debian index f899350a..c6a9af69 100644 --- a/advanced/lighttpd.conf +++ b/advanced/lighttpd.conf.debian @@ -14,9 +14,9 @@ server.modules = ( "mod_accesslog", "mod_expire", "mod_compress", - "mod_redirect", - "mod_setenv", - "mod_rewrite" + "mod_redirect", + "mod_setenv", + "mod_rewrite" ) server.document-root = "/var/www/html" diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 495eea5d..ea186887 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -68,6 +68,7 @@ if [ -x "$(command -v rpm)" ];then PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) + LIGHTTPD_CFG="lighttpd.conf.fedora" package_check() { rpm -qa | grep ^$1- > /dev/null } @@ -81,6 +82,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail ) PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + LIGHTTPD_CFG="lighttpd.conf.debian" package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } @@ -536,7 +538,7 @@ installConfigs() { $SUDO chown "$USER":root /etc/lighttpd $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig fi - $SUDO cp /etc/.pihole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf + $SUDO cp /etc/.pihole/advanced/$LIGHTTPD_CFG /etc/lighttpd/lighttpd.conf } stopServices() { From 8198f06073de3e8d1cde6785191bce916664b989 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 17:23:33 -0600 Subject: [PATCH 245/311] ensure dnsmasq conf-dir is configured for /etc/dnsmasq.d --- automated install/basic-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ea186887..b226750c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -491,6 +491,7 @@ versionCheckDNSmasq(){ else $SUDO sed -i '/^server=@DNS2@/d' $newFileFinalLocation fi + $SUDO sed -i 's/^#conf-dir=\/etc\/dnsmasq.d$/conf-dir=\/etc\/dnsmasq.d/' $dnsFile1 } installScripts() { From 62fa9c0f6e8b1ede103d74d4a108997e5fb24cdb Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 17:46:15 -0600 Subject: [PATCH 246/311] fixing whitespace --- advanced/lighttpd.conf.debian | 4 ++-- automated install/basic-install.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian index c6a9af69..8b62f448 100644 --- a/advanced/lighttpd.conf.debian +++ b/advanced/lighttpd.conf.debian @@ -15,8 +15,8 @@ server.modules = ( "mod_expire", "mod_compress", "mod_redirect", - "mod_setenv", - "mod_rewrite" + "mod_setenv", + "mod_rewrite" ) server.document-root = "/var/www/html" diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index b226750c..53b8280f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -577,15 +577,15 @@ installerDependencies() { echo -n "::: Checking $PKG_MANAGER for upgraded packages...." updatesToInstall=$(eval "$SUDO $PKG_COUNT") echo " done!" - echo ":::" - if [[ $updatesToInstall -eq "0" ]]; then + echo ":::" + if [[ $updatesToInstall -eq "0" ]]; then echo "::: Your pi is up to date! Continuing with pi-hole installation..." - else + else echo "::: There are $updatesToInstall updates availible for your pi!" echo "::: We recommend you run '$PKG_UPDATE' after installing Pi-Hole! " echo ":::" - fi - echo ":::" + fi + echo ":::" echo "::: Checking installer dependencies..." for i in "${INSTALLER_DEPS[@]}"; do echo -n "::: Checking for $i..." From c4234f4542593e1bf33dd6e642645fd101059135 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 1 May 2016 20:39:35 -0600 Subject: [PATCH 247/311] ensure ownership/existence of /var/cache/lighttpd/compress --- automated install/basic-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 53b8280f..31b7a3be 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -68,6 +68,7 @@ if [ -x "$(command -v rpm)" ];then PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) + LIGHTTPD_USER="lighttpd:lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" package_check() { rpm -qa | grep ^$1- > /dev/null @@ -82,6 +83,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail ) PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + LIGHTTPD_USER="www-data:www-data" LIGHTTPD_CFG="lighttpd.conf.debian" package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" @@ -540,6 +542,8 @@ installConfigs() { $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig fi $SUDO cp /etc/.pihole/advanced/$LIGHTTPD_CFG /etc/lighttpd/lighttpd.conf + $SUDO mkdir -p /var/cache/lighttpd/compress + $SUDO chown $LIGHTTPD_USER /var/cache/lighttpd/compress } stopServices() { From c160b2e54b0f4f14e61832c1c69174d9772208cb Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 4 May 2016 02:01:38 -0400 Subject: [PATCH 248/311] fix lighttpd user/group variables --- automated install/basic-install.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 31b7a3be..21e03321 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -68,7 +68,8 @@ if [ -x "$(command -v rpm)" ];then PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) - LIGHTTPD_USER="lighttpd:lighttpd" + LIGHTTPD_USER="lighttpd" + LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" package_check() { rpm -qa | grep ^$1- > /dev/null @@ -83,7 +84,8 @@ elif [ -x "$(command -v apt-get)" ];then PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail ) PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) - LIGHTTPD_USER="www-data:www-data" + LIGHTTPD_USER="www-data" + LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" @@ -543,7 +545,7 @@ installConfigs() { fi $SUDO cp /etc/.pihole/advanced/$LIGHTTPD_CFG /etc/lighttpd/lighttpd.conf $SUDO mkdir -p /var/cache/lighttpd/compress - $SUDO chown $LIGHTTPD_USER /var/cache/lighttpd/compress + $SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/cache/lighttpd/compress } stopServices() { @@ -746,9 +748,9 @@ installPihole() { if [ ! -d "/var/www/html" ]; then $SUDO mkdir -p /var/www/html fi - $SUDO chown www-data:www-data /var/www/html + $SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/www/html $SUDO chmod 775 /var/www/html - $SUDO usermod -a -G www-data pihole + $SUDO usermod -a -G $LIGHTTPD_GROUP pihole $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null getGitFiles From c74af2c21f46176f2796f59aca50ca61e3a97522 Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 4 May 2016 02:03:07 -0400 Subject: [PATCH 249/311] warn if lighty-enable-mod utility is not available Fastcgi can be enabled via lighttpd configuration. This step may not be required for all distributions. --- automated install/basic-install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 21e03321..f128e470 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -751,7 +751,11 @@ installPihole() { $SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/www/html $SUDO chmod 775 /var/www/html $SUDO usermod -a -G $LIGHTTPD_GROUP pihole - $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null + if [ -x "$(command -v lighty-enable-mod)" ]; then + $SUDO lighty-enable-mod fastcgi fastcgi-php > /dev/null + else + printf "\n:::\tWarning: 'lighty-enable-mod' utility not found. Please ensure fastcgi is enabled if you experience issues.\n" + fi getGitFiles installScripts From b31931c907f960e1420c863bdb24182a7c15e9a5 Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 4 May 2016 00:24:19 -0600 Subject: [PATCH 250/311] add epel-release for CentOS support --- 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 f128e470..6a583892 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) - PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) + PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" From 9c26bdd676c021d14e8cd555fe1b32b26dfaa4dc Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 4 May 2016 22:50:48 -0600 Subject: [PATCH 251/311] ensure fastcgi socket directory and permissions --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6a583892..6b6999d9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -544,6 +544,8 @@ installConfigs() { $SUDO mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig fi $SUDO cp /etc/.pihole/advanced/$LIGHTTPD_CFG /etc/lighttpd/lighttpd.conf + $SUDO mkdir -p /var/run/lighttpd + $SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/run/lighttpd $SUDO mkdir -p /var/cache/lighttpd/compress $SUDO chown $LIGHTTPD_USER:$LIGHTTPD_GROUP /var/cache/lighttpd/compress } From 65638973eaa0b97f0a13fc605557d3df56672c58 Mon Sep 17 00:00:00 2001 From: bcambl Date: Thu, 5 May 2016 00:15:00 -0600 Subject: [PATCH 252/311] correct dhcpcd package name to dhcpcd5 move dhcpcd5 to installer dependencies --- 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 6b6999d9..71186a5f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -82,8 +82,8 @@ elif [ -x "$(command -v apt-get)" ];then PKG_UPDATE="$PKG_MANAGER upgrade" PKG_INSTALL="$PKG_MANAGER -y -qq install" PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" - INSTALLER_DEPS=( apt-utils whiptail ) - PIHOLE_DEPS=( dhcpcd dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + INSTALLER_DEPS=( apt-utils whiptail dhcpcd5) + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" From 04e375a52324ff446d0397abe402f719d88f8572 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 14 May 2016 16:29:56 -0600 Subject: [PATCH 253/311] enable lighttpd and dnsmasq via systemd --- 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 71186a5f..347b29f0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -815,9 +815,10 @@ displayFinalMessage echo -n "::: Restarting services..." # Start services - if [ -x "$(command -v systemctl)" ]; then + $SUDO systemctl enable dnsmasq $SUDO systemctl restart dnsmasq + $SUDO systemctl enable lighttpd $SUDO systemctl start lighttpd else $SUDO service dnsmasq restart From 66724826f5800169513d315922a92833fdb5e03d Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 14 May 2016 16:35:40 -0600 Subject: [PATCH 254/311] moved php-fastcgi.socket to /tmp on Fedora fastcgi is spawned by lighttpd (lighttpd user). /var/run is owned by root, so we will put the socket in /tmp --- advanced/lighttpd.conf.fedora | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 7d38f95b..30784b1a 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -56,7 +56,7 @@ mimetype.assign = ( ".png" => "image/png", fastcgi.server = ( ".php" => ( "localhost" => ( - "socket" => "/var/run/lighttpd/php-fastcgi.socket", + "socket" => "/tmp/php-fastcgi.socket", "bin-path" => "/usr/bin/php-cgi" ) ) From e6634531c743f8698604f96f7eff6682b609523b Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 14 May 2016 17:05:40 -0600 Subject: [PATCH 255/311] basic firewalld/iptables configuration --- 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 347b29f0..98668a3d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -741,6 +741,22 @@ setUser(){ fi } +configureFirewall() { + # Allow HTTP and DNS traffic + if [ -x "$(command -v firewall-cmd)" ]; then + $SUDO echo "::: Configuring firewalld for httpd and dnsmasq.." + $SUDO firewall-cmd --zone=public --permanent --add-service=http + $SUDO firewall-cmd --zone=public --permanent --add-service=dns + $SUDO firewall-cmd --reload + elif [ -x "$(command -v iptables)" ]; then + $SUDO echo "::: Configuring iptables for httpd and dnsmasq.." + $SUDO iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT + $SUDO iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT + else + $SUDO echo "::: No firewall detected.. skipping firewall configuration." + fi +} + installPihole() { # Install base files and web interface checkForDependencies # done @@ -766,6 +782,7 @@ installPihole() { installPiholeWeb installCron runGravity + configureFirewall } displayFinalMessage() { From 4fc40d96d90ce2b96ecc36e5224b7277b13414ce Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 14 May 2016 19:51:05 -0600 Subject: [PATCH 256/311] ensure firewalld is running before configuration --- automated install/basic-install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 98668a3d..d47a5fe5 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -744,10 +744,13 @@ setUser(){ configureFirewall() { # Allow HTTP and DNS traffic if [ -x "$(command -v firewall-cmd)" ]; then - $SUDO echo "::: Configuring firewalld for httpd and dnsmasq.." - $SUDO firewall-cmd --zone=public --permanent --add-service=http - $SUDO firewall-cmd --zone=public --permanent --add-service=dns - $SUDO firewall-cmd --reload + $SUDO firewall-cmd --state > /dev/null + if [[ $? -eq 0 ]]; then + $SUDO echo "::: Configuring firewalld for httpd and dnsmasq.." + $SUDO firewall-cmd --zone=public --permanent --add-service=http + $SUDO firewall-cmd --zone=public --permanent --add-service=dns + $SUDO firewall-cmd --reload + fi elif [ -x "$(command -v iptables)" ]; then $SUDO echo "::: Configuring iptables for httpd and dnsmasq.." $SUDO iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT From 376eb81181c2f0e101e19962115e410356580c9d Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 5 Jun 2016 14:43:18 -0600 Subject: [PATCH 257/311] SELinux Support --- advanced/selinux/pihole.te | 87 ++++++++++++++++++++++++++++++ automated install/basic-install.sh | 29 ++++++++++ 2 files changed, 116 insertions(+) create mode 100644 advanced/selinux/pihole.te diff --git a/advanced/selinux/pihole.te b/advanced/selinux/pihole.te new file mode 100644 index 00000000..595755dd --- /dev/null +++ b/advanced/selinux/pihole.te @@ -0,0 +1,87 @@ +module pihole 1.0; + +require { + type var_log_t; + type unconfined_t; + type init_t; + type auditd_t; + type syslogd_t; + type NetworkManager_t; + type mdadm_t; + type tuned_t; + type avahi_t; + type irqbalance_t; + type system_dbusd_t; + type kernel_t; + type httpd_sys_script_t; + type systemd_logind_t; + type httpd_t; + type policykit_t; + type dnsmasq_t; + type udev_t; + type postfix_pickup_t; + type sshd_t; + type crond_t; + type getty_t; + type lvm_t; + type postfix_qmgr_t; + type postfix_master_t; + class dir { getattr search }; + class file { read open setattr }; +} + +#============= dnsmasq_t ============== +allow dnsmasq_t var_log_t:file { open setattr }; + +#============= httpd_t ============== +allow httpd_t var_log_t:file { read open }; + +#============= httpd_sys_script_t (class: dir) ============== +allow httpd_sys_script_t NetworkManager_t:dir { getattr search }; +allow httpd_sys_script_t auditd_t:dir { getattr search }; +allow httpd_sys_script_t avahi_t:dir { getattr search }; +allow httpd_sys_script_t crond_t:dir { getattr search }; +allow httpd_sys_script_t dnsmasq_t:dir { getattr search }; +allow httpd_sys_script_t getty_t:dir { getattr search }; +allow httpd_sys_script_t httpd_t:dir { getattr search }; +allow httpd_sys_script_t init_t:dir { getattr search }; +allow httpd_sys_script_t irqbalance_t:dir { getattr search }; +allow httpd_sys_script_t kernel_t:dir { getattr search }; +allow httpd_sys_script_t lvm_t:dir { getattr search }; +allow httpd_sys_script_t mdadm_t:dir { getattr search }; +allow httpd_sys_script_t policykit_t:dir { getattr search }; +allow httpd_sys_script_t postfix_master_t:dir { getattr search }; +allow httpd_sys_script_t postfix_pickup_t:dir { getattr search }; +allow httpd_sys_script_t postfix_qmgr_t:dir { getattr search }; +allow httpd_sys_script_t sshd_t:dir { getattr search }; +allow httpd_sys_script_t syslogd_t:dir { getattr search }; +allow httpd_sys_script_t system_dbusd_t:dir { getattr search }; +allow httpd_sys_script_t systemd_logind_t:dir { getattr search }; +allow httpd_sys_script_t tuned_t:dir { getattr search }; +allow httpd_sys_script_t udev_t:dir { getattr search }; +allow httpd_sys_script_t unconfined_t:dir { getattr search }; + +#============= httpd_sys_script_t (class: file) ============== +allow httpd_sys_script_t NetworkManager_t:file { read open }; +allow httpd_sys_script_t auditd_t:file { read open }; +allow httpd_sys_script_t avahi_t:file { read open }; +allow httpd_sys_script_t crond_t:file { read open }; +allow httpd_sys_script_t dnsmasq_t:file { read open }; +allow httpd_sys_script_t getty_t:file { read open }; +allow httpd_sys_script_t httpd_t:file { read open }; +allow httpd_sys_script_t init_t:file { read open }; +allow httpd_sys_script_t irqbalance_t:file { read open }; +allow httpd_sys_script_t kernel_t:file { read open }; +allow httpd_sys_script_t lvm_t:file { read open }; +allow httpd_sys_script_t mdadm_t:file { read open }; +allow httpd_sys_script_t policykit_t:file { read open }; +allow httpd_sys_script_t postfix_master_t:file { read open }; +allow httpd_sys_script_t postfix_pickup_t:file { read open }; +allow httpd_sys_script_t postfix_qmgr_t:file { read open }; +allow httpd_sys_script_t sshd_t:file { read open }; +allow httpd_sys_script_t syslogd_t:file { read open }; +allow httpd_sys_script_t system_dbusd_t:file { read open }; +allow httpd_sys_script_t systemd_logind_t:file { read open }; +allow httpd_sys_script_t tuned_t:file { read open }; +allow httpd_sys_script_t udev_t:file { read open }; +allow httpd_sys_script_t unconfined_t:file { read open }; diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d47a5fe5..1006bd10 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -788,6 +788,32 @@ installPihole() { configureFirewall } +configureSelinux() { + if [ -x "$(command -v getenforce)" ]; then + printf "\n::: SELinux Detected\n" + printf ":::\tChecking for SELinux policy development packages..." + package_check "selinux-policy-devel" > /dev/null + if ! [ $? -eq 0 ]; then + echo -n " Not found! Installing...." + $SUDO $PKG_INSTALL "selinux-policy-devel" > /dev/null & spinner $! + echo " done!" + else + echo " already installed!" + fi + printf ":::\tCompiling Pi-Hole SELinux policy..\n" + $SUDO checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te + $SUDO semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod + $SUDO semodule -i /etc/pihole/pihole.pp + $SUDO rm -f /etc/pihole/pihole.mod + $SUDO semodule -l | grep pihole > /dev/null + if [ $? -eq 0 ]; then + printf "::: Successfully installed Pi-Hole SELinux policy\n" + else + printf "::: Warning: Pi-Hole SELinux policy did not install correctly!\n" + fi + fi +} + displayFinalMessage() { # Final completion message to user whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: @@ -831,6 +857,9 @@ installPihole | tee $tmpLog # Move the log file into /etc/pihole for storage $SUDO mv $tmpLog $instalLogLoc +# Configure SELinux (if applicable) +configureSelinux + displayFinalMessage echo -n "::: Restarting services..." From 682113892a40cb99d108166b78e7aabcbace38a0 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 5 Jun 2016 15:24:33 -0600 Subject: [PATCH 258/311] enable SELinux boolean for httpd server side includes (SSI) --- automated install/basic-install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1006bd10..6f837df0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -800,6 +800,11 @@ configureSelinux() { else echo " already installed!" fi + printf "::: Enabling httpd server side includes (SSI).. " + $SUDO setsebool -P httpd_ssi_exec on + if [ $? -eq 0 ]; then + echo -n "Success\n" + fi printf ":::\tCompiling Pi-Hole SELinux policy..\n" $SUDO checkmodule -M -m -o /etc/pihole/pihole.mod /etc/.pihole/advanced/selinux/pihole.te $SUDO semodule_package -o /etc/pihole/pihole.pp -m /etc/pihole/pihole.mod From 5e27ccc37c7ee6705385db48fb3efb6df5d916ff Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 8 Jun 2016 00:00:20 -0600 Subject: [PATCH 259/311] firewalld: specify ports and use default zone --- 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 6f837df0..5096c8e7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -747,8 +747,8 @@ configureFirewall() { $SUDO firewall-cmd --state > /dev/null if [[ $? -eq 0 ]]; then $SUDO echo "::: Configuring firewalld for httpd and dnsmasq.." - $SUDO firewall-cmd --zone=public --permanent --add-service=http - $SUDO firewall-cmd --zone=public --permanent --add-service=dns + $SUDO firewall-cmd --permanent --add-port=80/tcp + $SUDO firewall-cmd --permanent --add-port=53/tcp $SUDO firewall-cmd --reload fi elif [ -x "$(command -v iptables)" ]; then From 97737ee9e37a90f4d91237849e10701bc02a36b5 Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 8 Jun 2016 12:21:35 -0600 Subject: [PATCH 260/311] move SELinux config to installPihole() for logging --- automated install/basic-install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5096c8e7..922f3d77 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -786,6 +786,7 @@ installPihole() { installCron runGravity configureFirewall + configureSelinux } configureSelinux() { @@ -862,9 +863,6 @@ installPihole | tee $tmpLog # Move the log file into /etc/pihole for storage $SUDO mv $tmpLog $instalLogLoc -# Configure SELinux (if applicable) -configureSelinux - displayFinalMessage echo -n "::: Restarting services..." From d0b6ff2d083b075b8c78b3a8787f61e5cb2d4a9d Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 8 Jun 2016 21:42:08 -0600 Subject: [PATCH 261/311] add udp port 53 to iptables/firewalld configuration --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 922f3d77..73a45365 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -749,12 +749,14 @@ configureFirewall() { $SUDO echo "::: Configuring firewalld for httpd and dnsmasq.." $SUDO firewall-cmd --permanent --add-port=80/tcp $SUDO firewall-cmd --permanent --add-port=53/tcp + $SUDO firewall-cmd --permanent --add-port=53/udp $SUDO firewall-cmd --reload fi elif [ -x "$(command -v iptables)" ]; then $SUDO echo "::: Configuring iptables for httpd and dnsmasq.." $SUDO iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT $SUDO iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT + $SUDO iptables -A INPUT -p tcp -m udp --dport 53 -j ACCEPT else $SUDO echo "::: No firewall detected.. skipping firewall configuration." fi From 27a964209031fc6211993f8de94452aecd4a4548 Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 10 Jun 2016 12:30:43 -0600 Subject: [PATCH 262/311] check for sudo via 'command -v' instead of dkpg-query --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/piholeDebug.sh | 2 +- advanced/Scripts/setupLCD.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- automated install/uninstall.sh | 2 +- gravity.sh | 2 +- pihole | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 7e99f830..d83ca867 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -17,7 +17,7 @@ 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 + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this script as root." diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 263fe9cd..a5958bbd 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -36,7 +36,7 @@ if [[ $EUID -eq 0 ]]; then else echo "::: Sudo will be used for debugging." # Check if sudo is actually installed - if [[ $(dpkg-query -s sudo) ]]; then + if [ -x "$(command -v sudo)" ]; then export SUDO="sudo" else echo "::: Please install sudo or run this as root." diff --git a/advanced/Scripts/setupLCD.sh b/advanced/Scripts/setupLCD.sh index df2be704..03be4e0a 100755 --- a/advanced/Scripts/setupLCD.sh +++ b/advanced/Scripts/setupLCD.sh @@ -19,7 +19,7 @@ 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 + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this script as root." diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 37b4ade4..266ac49e 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -17,7 +17,7 @@ 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 + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this script as root." diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 83168d6a..749bf799 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -17,7 +17,7 @@ else echo "::: Sudo will be used for the uninstall." # Check if it is actually installed # If it isn't, exit because the unnstall cannot complete - if [[ $(dpkg-query -s sudo) ]];then + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this as root." diff --git a/gravity.sh b/gravity.sh index ce04e181..ff85fd21 100755 --- a/gravity.sh +++ b/gravity.sh @@ -19,7 +19,7 @@ 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 + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this script as root." diff --git a/pihole b/pihole index 1c348b71..bbcb82d0 100755 --- a/pihole +++ b/pihole @@ -17,7 +17,7 @@ if [[ ! $EUID -eq 0 ]];then #echo "::: Sudo will be used for this tool." # Check if it is actually installed # If it isn't, exit because the pihole cannot be invoked without privileges. - if [[ $(dpkg-query -s sudo) ]];then + if [ -x "$(command -v sudo)" ];then export SUDO="sudo" else echo "::: Please install sudo or run this as root." From 943f7c06b57efbdea85ce9b094d3084afbe68224 Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 10 Jun 2016 18:01:13 -0600 Subject: [PATCH 263/311] uninstaller support for Fedora/CentOS --- automated install/uninstall.sh | 53 ++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 749bf799..5730c531 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -25,6 +25,39 @@ else fi fi +# Compatability +if [ -x "$(command -v rpm)" ];then + # Fedora Family + if [ -x "$(command -v dnf)" ];then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi + PKG_REMOVE="$PKG_MANAGER remove -y" + PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils ) + package_check() { + rpm -qa | grep ^$1- > /dev/null + } + package_cleanup() { + $SUDO $PKG_MANAGER -y autoremove + } +elif [ -x "$(command -v apt-get)" ];then + # Debian Family + PKG_MANAGER="apt-get" + PKG_REMOVE="$PKG_MANAGER -y remove --purge" + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget ) + package_check() { + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" + } + package_cleanup() { + $SUDO $PKG_MANAGER -y autoremove + $SUDO $PKG_MANAGER -y autoclean + } +else + echo "OS distribution not supported" + exit +fi + spinner() { local pid=$1 @@ -43,14 +76,13 @@ spinner() function removeAndPurge { # Purge dependencies echo ":::" - # Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common - dependencies=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget ) - for i in "${dependencies[@]}"; do - if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then + for i in "${PIHOLE_DEPS[@]}"; do + package_check $i > /dev/null + if [ $? -eq 0 ]; then while true; do read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn case $yn in - [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "done!\n"; break;; + [Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO $PKG_REMOVE "$i" &> /dev/null & spinner $!; printf "done!\n"; break;; [Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;; * ) printf "::: You must answer yes or no!\n";; esac @@ -65,10 +97,8 @@ echo ":::" $SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null # Take care of any additional package cleaning - printf "::: Auto removing remaining dependencies..." - $SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "done!\n"; - printf "::: Auto cleaning remaining dependencies..." - $SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "done!\n"; + printf "::: Auto removing & cleaning remaining dependencies..." + package_cleanup &> /dev/null & spinner $!; printf "done!\n"; # Call removeNoPurge to remove PiHole specific files removeNoPurge @@ -107,7 +137,8 @@ function removeNoPurge { fi echo "::: Removing config files and scripts..." - if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then + package_check $i > /dev/null + if [ $? -eq 1 ]; then $SUDO rm -rf /etc/lighttpd/ &> /dev/null else if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then @@ -143,5 +174,3 @@ while true; do [Nn]* ) removeNoPurge; break;; esac done - - From afdf3ae7a1c5d45300e4662fb8b1127c0d65343f Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 16:10:31 -0600 Subject: [PATCH 264/311] add sudo package to PIHOLE_DEPS --- 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 73a45365..b1141676 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) - PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie ) + PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" @@ -83,7 +83,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_INSTALL="$PKG_MANAGER -y -qq install" PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail dhcpcd5) - PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget ) + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo ) LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" From 3d619d9ccce8423e08b2fe1dfe7bc79d7c0b0a67 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 17:04:45 -0600 Subject: [PATCH 265/311] fix iptables udp rule fixes dmesg: ip_tables: udp match: only valid for protocol 17 --- 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 b1141676..6a6acfae 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -756,7 +756,7 @@ configureFirewall() { $SUDO echo "::: Configuring iptables for httpd and dnsmasq.." $SUDO iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT $SUDO iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT - $SUDO iptables -A INPUT -p tcp -m udp --dport 53 -j ACCEPT + $SUDO iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT else $SUDO echo "::: No firewall detected.. skipping firewall configuration." fi From 5c79184d3b58a956f360315bf5d1c48700a1925f Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 17:17:12 -0600 Subject: [PATCH 266/311] add ifconfig dependency for Fedora install --- 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 6a6acfae..80e50b1d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -66,7 +66,7 @@ if [ -x "$(command -v rpm)" ];then PKG_UPDATE="$PKG_MANAGER update -y" PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" - INSTALLER_DEPS=( iproute procps-ng newt dhcpcd ) + INSTALLER_DEPS=( iproute net-tools procps-ng newt dhcpcd ) PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" From 0d9a8d70bf25112048d3b40ff9e8089900982beb Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 17:28:57 -0600 Subject: [PATCH 267/311] configureSelinux prior to installPihole --- automated install/basic-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 80e50b1d..a8a47bae 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -788,7 +788,6 @@ installPihole() { installCron runGravity configureFirewall - configureSelinux } configureSelinux() { @@ -859,6 +858,9 @@ use4andor6 # Decide what upstream DNS Servers to use setDNS +# Configure SELinux (if applicable) +configureSelinux + # Install and log everything to a file installPihole | tee $tmpLog From 3ba05d027413ba0a4bf215483ebf486767b02ba6 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 22:08:18 -0600 Subject: [PATCH 268/311] configure static IP on Fedora via sysconfig script --- automated install/basic-install.sh | 55 +++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a8a47bae..ed7b57ba 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -66,7 +66,7 @@ if [ -x "$(command -v rpm)" ];then PKG_UPDATE="$PKG_MANAGER update -y" PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" - INSTALLER_DEPS=( iproute net-tools procps-ng newt dhcpcd ) + INSTALLER_DEPS=( iproute net-tools procps-ng newt ) PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" @@ -117,7 +117,6 @@ findIPRoute() { IPv4addr=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1) - dhcpcdFile=/etc/dhcpcd.conf } backupLegacyPihole() { @@ -328,20 +327,52 @@ setDHCPCD() { echo "::: interface $piholeInterface static ip_address=$IPv4addr static routers=$IPv4gw - static domain_name_servers=$IPv4gw" | $SUDO tee -a $dhcpcdFile >/dev/null + static domain_name_servers=$IPv4gw" | $SUDO tee -a /etc/dhcpcd.conf >/dev/null } setStaticIPv4() { - # Tries to set the IPv4 address - if grep -q "$IPv4addr" $dhcpcdFile; then - # address already set, noop - : + if [[ -f /etc/dhcpcd.conf ]];then + # Debian Family + if grep -q "$IPv4addr" /etc/dhcpcd.conf; then + echo "::: Static IP already configured" + else + setDHCPCD + $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" + echo ":::" + echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" + fi + elif [[ -f /etc/sysconfig/network-scripts/ifcfg-$piholeInterface ]];then + # Fedora Family + IFCFG_FILE=/etc/sysconfig/network-scripts/ifcfg-$piholeInterface + if grep -q "$IPv4addr" $IFCFG_FILE; then + echo "::: Static IP already configured" + else + IPADDR=$(echo $IPv4addr | cut -f1 -d/) + CIDR=$(echo $IPv4addr | cut -f2 -d/) + # Backup existing interface configuration: + cp $IFCFG_FILE $IFCFG_FILE.backup-$(date +%Y-%m-%d-%H%M%S) + # Build Interface configuration file: + $SUDO echo "# Configured via Pi-Hole installer" > $IFCFG_FILE + $SUDO echo "DEVICE=$piholeInterface" >> $IFCFG_FILE + $SUDO echo "BOOTPROTO=none" >> $IFCFG_FILE + $SUDO echo "ONBOOT=yes" >> $IFCFG_FILE + $SUDO echo "IPADDR=$IPADDR" >> $IFCFG_FILE + $SUDO echo "PREFIX=$CIDR" >> $IFCFG_FILE + $SUDO echo "USERCTL=no" >> $IFCFG_FILE + $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" + if [ -x "$(command -v nmcli)" ];then + # Tell NetworkManager to read our new sysconfig file + $SUDO nmcli con load $IFCFG_FILE > /dev/null + fi + echo ":::" + echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" + + fi else - setDHCPCD - $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" - echo ":::" - echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." - echo ":::" + echo "::: Warning: Unable to locate configuration file to set static IPv4 address!" + exit 1 fi } From fa89bd830aa8612cde04f8a887d0d9c7316bf612 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 11 Jun 2016 22:33:44 -0600 Subject: [PATCH 269/311] re-order when SELinux gets configured configure SELinux *after* git clone/pull & file setup and *before* service configuration --- automated install/basic-install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ed7b57ba..f8e2c426 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -815,6 +815,7 @@ installPihole() { installScripts installConfigs CreateLogFile + configureSelinux installPiholeWeb installCron runGravity @@ -889,9 +890,6 @@ use4andor6 # Decide what upstream DNS Servers to use setDNS -# Configure SELinux (if applicable) -configureSelinux - # Install and log everything to a file installPihole | tee $tmpLog From 9ccf9d57a8df9c278baa320e58316db5832c6bd2 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 13 Jun 2016 06:49:03 -0500 Subject: [PATCH 270/311] updated dashboard pic --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f848f28..497e86e2 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb `http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` -![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/CQlEnDy.png) ### Whitelist and blacklist From 46df6e7dd390d9631f30727854eb8c98320eb166 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 16 Jun 2016 10:11:55 +0100 Subject: [PATCH 271/311] Update adlists.default Add C&C malware list from #528 --- adlists.default | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adlists.default b/adlists.default index 02d9b92c..6e9cec50 100644 --- a/adlists.default +++ b/adlists.default @@ -43,6 +43,8 @@ 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 +# List of known C&C malware servers (see https://github.com/pi-hole/pi-hole/issues/528) +https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt # Untested Lists: #https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt From 3c4a30597601854d1aeb624ba6adf00689894554 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 17 Jun 2016 16:05:17 +0100 Subject: [PATCH 272/311] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 497e86e2..261f0353 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 1. Install Raspbian -2. Run the command below +2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) ### ```curl -L https://install.pi-hole.net | bash``` @@ -13,6 +13,8 @@ wget -O basic-install.sh https://install.pi-hole.net chmod +x basic-install.sh ./basic-install.sh ``` +If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer + 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/). From fd92752f5215a496f22e7627474b6a265f3e374c Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Mon, 20 Jun 2016 19:10:06 +0200 Subject: [PATCH 273/311] Fix link for spam404scamlist.txt The redirect `http://spam404bl.com/spam404scamlist.txt` resolves to `https://raw.githubusercontent.com/spam404scamlist.txt/Dawsey21/Lists/master/main-blacklist.txt`, which is wrong. Instead, use `https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt`directly. --- adlists.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adlists.default b/adlists.default index 6e9cec50..0aeee73b 100644 --- a/adlists.default +++ b/adlists.default @@ -48,7 +48,7 @@ https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt # Untested Lists: #https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt -#http://spam404bl.com/spam404scamlist.txt +#https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt #http://malwaredomains.lehigh.edu/files/domains.txt # Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/) #https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt From 0250e03b868a7a457edee6469f5cd3d750fb1e23 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 20 Jun 2016 15:47:05 -0500 Subject: [PATCH 274/311] simplified donation section --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 261f0353..03335593 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,14 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei ## Pi-hole Is Free, But Powered By Your Donations Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. +* ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) +* ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) +* ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL +* ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission) | Paypal | Bitcoin | Optimal.com | | ------ | ------- | -------- | -| [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") |
![1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX](http://todobom.com/images/bitcoin-donations.png)
1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX
| Sign up for [Optimal.com using our link](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) to provide us with a small monthly amount. Your money will also support content-creators. +| [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") |
![1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX](http://todobom.com/images/bitcoin-donations.png)
1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX
| ## Get Help Or Connect With Us On The Web From 2ce47f49b1b272db25f9acbac03570a34c62b52d Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 20 Jun 2016 15:55:23 -0500 Subject: [PATCH 275/311] forgot to remove the old donation stuff --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 03335593..b9fff53c 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,6 @@ Send a one-time donation or sign up for Optimal.com's service using our link bel * ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL * ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission) -| Paypal | Bitcoin | Optimal.com | -| ------ | ------- | -------- | -| [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") |
![1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX](http://todobom.com/images/bitcoin-donations.png)
1hXEKGKExiPAQ7y5CFPwWiEXUXB6wDuqX
| ## Get Help Or Connect With Us On The Web From 1f130b6550c8f72a61f8a55439eada864b734aa5 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 21 Jun 2016 19:16:11 -0400 Subject: [PATCH 276/311] Fix missing permissions on piholeIP Without sudo/root privileges, the echo command is unable to write to the file. --- 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 699f68ee..d26c33cc 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -236,7 +236,7 @@ getStaticIPv4Settings() { If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c #piholeIP is saved to a permanent file so gravity.sh can use it when updating - echo "${IPv4addr%/*}" > /etc/pihole/piholeIP + $SUDO echo "${IPv4addr%/*}" > /etc/pihole/piholeIP # Nothing else to do since the variables are already set above else # Otherwise, we need to ask the user to input their desired settings. @@ -258,8 +258,8 @@ It is also possible to use a DHCP reservation, but if you are going to do that, Gateway: $IPv4gw" $r $c)then # If the settings are correct, then we need to set the piholeIP # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script. piholeIP is saved to a permanent file so gravity.sh can use it when updating - echo "${IPv4addr%/*}" > /etc/pihole/piholeIP - echo "$piholeInterface" > /tmp/piholeINT + $SUDO echo "${IPv4addr%/*}" > /etc/pihole/piholeIP + $SUDO echo "$piholeInterface" > /tmp/piholeINT # After that's done, the loop ends and we move on ipSettingsCorrect=True else From caaee40889d572a85921b8ad0f49d738bc25cd05 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 23 Jun 2016 17:38:26 -0700 Subject: [PATCH 277/311] Hosts-file.net moved to https --- adlists.default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adlists.default b/adlists.default index 02d9b92c..2bb9d9f2 100644 --- a/adlists.default +++ b/adlists.default @@ -22,7 +22,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt # hosts-file.net list. Updated frequently, but has been known to block legitimate sites. -http://hosts-file.net/ad_servers.txt +https://hosts-file.net/ad_servers.txt # Mahakala list. Has been known to block legitimage domains including the entire .com range. # Warning: Due to the sheer size of this list, the web admin console will be unresponsive. From 636a9123b83d8d8a229e82898f58bf36b7dcc8aa Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 23 Jun 2016 18:37:45 -0700 Subject: [PATCH 278/311] Have `curl` auto-redirect This should solve the redirection issue if a list is moved. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ce04e181..130c5409 100755 --- a/gravity.sh +++ b/gravity.sh @@ -152,7 +152,7 @@ function gravity_transport() { fi # Silently curl url - curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer + curl -s -L $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer # Check for list updates gravity_patternCheck "$patternBuffer" # Cleanup From 7670b4e380e4526099eac53d0725b56c9dac99f1 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 25 Jun 2016 06:00:49 -0700 Subject: [PATCH 279/311] Mahakala User Agen modernization Update Curl User Agent for Maha list. --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ce04e181..8fa93e22 100755 --- a/gravity.sh +++ b/gravity.sh @@ -181,7 +181,7 @@ function gravity_spinup() { # to complete properly and reset the user agent when required case "$domain" in "adblock.mahakala.is") - agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0' + agent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' cmd_ext="-e http://forum.xda-developers.com/" ;; From 0e143f727561b96c8c1fe879907be6dd59ed1918 Mon Sep 17 00:00:00 2001 From: Matth Date: Sat, 25 Jun 2016 15:45:51 +0200 Subject: [PATCH 280/311] Update adlists.default --- adlists.default | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adlists.default b/adlists.default index 0aeee73b..d2b5e798 100644 --- a/adlists.default +++ b/adlists.default @@ -53,3 +53,5 @@ https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt # Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/) #https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt #https://raw.github.com/notracking/hosts-blocklists/master/domains.txt +# Combination of serveral host files on the internet (warning some facebook domains are also blocked but you can go to facebook.com). See https://github.com/mat1th/Dns-add-block for more information. +#https://raw.githubusercontent.com/mat1th/Dns-add-block/master/hosts From 9b8efe1b27f296fafc88652b43e46afd6bd4223a Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 3 Jul 2016 19:50:42 -0400 Subject: [PATCH 281/311] Upload log to sprunge.us --- advanced/Scripts/piholeDebug.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index a5958bbd..dfe9f4ac 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -330,8 +330,16 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "::: Finshed debugging!" - echo "::: Debug log can be found at : /var/log/pihole_debug.log" + echo "::: Finshed debugging!" + SPRUNGE=$(cat /var/log/pihole_debug.log | curl --silent --connect-timeout 5 -F 'sprunge=<-' http://sprunge.us) + + # Check if sprunge.us is reachable. When it's not, point to local log instead + if [ -n "$SPRUNGE" ] + then + echo "::: Debug log can be found at : $SPRUNGE" + else + echo "::: Debug log can be found at : /var/log/pihole_debug.log" + fi } trap finalWork EXIT From 2b0ba281a4b3e1e390b801d9f888f7a431180238 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Jul 2016 15:35:46 -0400 Subject: [PATCH 282/311] Repairs apt-get incorrect options --- 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 a61c5e9b..9474d729 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -80,7 +80,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_CACHE="/var/cache/apt" UPDATE_PKG_CACHE="$PKG_MANAGER -qq update" PKG_UPDATE="$PKG_MANAGER upgrade" - PKG_INSTALL="$PKG_MANAGER -y -qq install" + PKG_INSTALL="$PKG_MANAGER --yes --quiet install" PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail dhcpcd5) PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo ) From c1d8496b93c5d1d91573fd33f70b05e81c1bb27f Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Wed, 6 Jul 2016 08:37:30 -0500 Subject: [PATCH 283/311] removed pihole berry from images also added adafruit livestream video --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9fff53c..600420cd 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei ## How To Install Pi-hole -[![60-second install tutorial](http://i.imgur.com/lVyNWTC.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) +[![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) ## How Does It Work? **Watch the 60-second video below to get a quick overview** -[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://youtu.be/L2iVKs0v0Tk) +[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/L2iVKs0v0Tk) ## Pi-hole Is Free, But Powered By Your Donations Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. @@ -56,12 +56,12 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb `http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` -![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/CQlEnDy.png) +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/gTq2GbS.png) ### Whitelist and blacklist Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details -![Whitelist editor in the Web interface](http://i.imgur.com/Anj1GzO.png) +![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png) ## API @@ -96,6 +96,7 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage +- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI) - [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) - [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) From 412c0a172d08476a79bbb7ff399010121c52cd33 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 8 Jul 2016 22:58:27 +0100 Subject: [PATCH 284/311] Update README.md update "How does it work" video --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 600420cd..deea666e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei ## How Does It Work? **Watch the 60-second video below to get a quick overview** -[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/L2iVKs0v0Tk) +[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho) ## Pi-hole Is Free, But Powered By Your Donations Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. From f45eb84d6bbb8946c01315812bbd1631ad685c29 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 14 Jul 2016 11:27:47 -0700 Subject: [PATCH 285/311] Add distribution Check --- advanced/Scripts/piholeDebug.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index dfe9f4ac..8d0d3fa7 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -67,6 +67,14 @@ function versionCheck { echo >> $DEBUG_LOG } +function distroCheck { + echo "#######################################" >> $DEBUG_LOG + echo "######## Distribution Section #########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + + TMP=$(cat /etc/lsb-release/ || echo "Failed to find lsb") + echo "Distribution Version: $TMP" >> $DEBUG_LOG + function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then $SUDO touch $WHITELISTMATCHES @@ -195,6 +203,7 @@ echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG versionCheck +distroCheck compareWhitelist compareBlacklist testNslookup From b011e5f838e74e808856a426fa11b2cfc08339cb Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 14 Jul 2016 11:35:52 -0700 Subject: [PATCH 286/311] Add os-release check --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 8d0d3fa7..86bff3c2 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -72,7 +72,7 @@ function distroCheck { echo "######## Distribution Section #########" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG - TMP=$(cat /etc/lsb-release/ || echo "Failed to find lsb") + TMP=$(cat /etc/lsb-release/ || cat /etc/os-release || echo "Failed to find release") echo "Distribution Version: $TMP" >> $DEBUG_LOG function compareWhitelist { From 11f2524b9b2d8ad2a4d423d00dc37727c91803de Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 14 Jul 2016 20:47:27 +0200 Subject: [PATCH 287/311] Instead of an or, cat *release --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 86bff3c2..fdb7847d 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -72,7 +72,7 @@ function distroCheck { echo "######## Distribution Section #########" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG - TMP=$(cat /etc/lsb-release/ || cat /etc/os-release || echo "Failed to find release") + TMP=$(cat /etc/*release/ || echo "Failed to find release") echo "Distribution Version: $TMP" >> $DEBUG_LOG function compareWhitelist { From f0a2248c81a790c72f9ccc927627f5fcd8c4eb6a Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 15 Jul 2016 10:27:40 -0700 Subject: [PATCH 288/311] Change comment to hash Change format of comment to hash/octothorpe to clearly delineate that it's a comment. Looks better than `:::` which causes confusion. --- 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 9474d729..6424f828 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -324,7 +324,7 @@ It is also possible to use a DHCP reservation, but if you are going to do that, setDHCPCD() { # Append these lines to dhcpcd.conf to enable a static IP - echo "::: interface $piholeInterface + echo "## interface $piholeInterface static ip_address=$IPv4addr static routers=$IPv4gw static domain_name_servers=$IPv4gw" | $SUDO tee -a /etc/dhcpcd.conf >/dev/null From 6f068e0b9c3696d1ecbb0fbc139e2cca696ad3f1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 15 Jul 2016 19:32:49 +0100 Subject: [PATCH 289/311] Replace sprunge.us with termbin, which appears to be more reliable. --- advanced/Scripts/piholeDebug.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index fdb7847d..87a87f88 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -340,12 +340,12 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { echo "::: Finshed debugging!" - SPRUNGE=$(cat /var/log/pihole_debug.log | curl --silent --connect-timeout 5 -F 'sprunge=<-' http://sprunge.us) + TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) - # Check if sprunge.us is reachable. When it's not, point to local log instead - if [ -n "$SPRUNGE" ] + # Check if termbin.com is reachable. When it's not, point to local log instead + if [ -n "$TERMBIN" ] then - echo "::: Debug log can be found at : $SPRUNGE" + echo "::: Debug log can be found at : $TERMBIN" else echo "::: Debug log can be found at : /var/log/pihole_debug.log" fi From e106ff0fef36682da16c26fe3b43559d2f24e25f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 15 Jul 2016 19:58:26 +0100 Subject: [PATCH 290/311] Add netcat to dependencies for termbin.com. Should be installed by default, but JUST IN CASE. --- 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 9474d729..bd6722ee 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute net-tools procps-ng newt ) - PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo ) + PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo netcat ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" @@ -83,7 +83,7 @@ elif [ -x "$(command -v apt-get)" ];then PKG_INSTALL="$PKG_MANAGER --yes --quiet install" PKG_COUNT="$PKG_MANAGER -s -o Debug::NoLocking=true upgrade | grep -c ^Inst" INSTALLER_DEPS=( apt-utils whiptail dhcpcd5) - PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo ) + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-cgi php5 git curl unzip wget sudo netcat ) LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" From e942440bb7c558f62e3684b9ca5a9d76be905fe3 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 15 Jul 2016 21:11:10 +0100 Subject: [PATCH 291/311] Dan forgot this : `}` --- advanced/Scripts/piholeDebug.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 87a87f88..e22a36aa 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -74,6 +74,7 @@ function distroCheck { TMP=$(cat /etc/*release/ || echo "Failed to find release") echo "Distribution Version: $TMP" >> $DEBUG_LOG +} function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then From 61ff12e8d42f7a473180c7331ed55c0c2379c7dd Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 15 Jul 2016 21:17:16 +0100 Subject: [PATCH 292/311] Change header to match the rest of the scripts. --- advanced/Scripts/piholeDebug.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index e22a36aa..c5b52daf 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -10,9 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# Nate Brandeburg -# nate@ubiquisoft.com -# 3/24/2016 ######## GLOBAL VARS ######## DEBUG_LOG="/var/log/pihole_debug.log" From a32ad0dbf2240fe876f226506556d11db70b323f Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 15 Jul 2016 21:43:23 -0600 Subject: [PATCH 293/311] fix centos nc dependency --- 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 bd6722ee..4df009bc 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -67,7 +67,7 @@ if [ -x "$(command -v rpm)" ];then PKG_INSTALL="$PKG_MANAGER install -y" PKG_COUNT="$PKG_MANAGER check-update | grep -v ^Last | grep -c ^[a-zA-Z0-9]" INSTALLER_DEPS=( iproute net-tools procps-ng newt ) - PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo netcat ) + PIHOLE_DEPS=( epel-release bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-cli php git curl unzip wget findutils cronie sudo nmap-ncat ) LIGHTTPD_USER="lighttpd" LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" From ce8f07750f04409bbc6354cb46dd604688dfa01b Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 15 Jul 2016 22:46:21 -0700 Subject: [PATCH 294/311] Remove trailing slash on os-release check Fixes #CLOSED Remove trailing slash that would cause an os-check to always fail out. --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index c5b52daf..36ae15bc 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -69,7 +69,7 @@ function distroCheck { echo "######## Distribution Section #########" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG - TMP=$(cat /etc/*release/ || echo "Failed to find release") + TMP=$(cat /etc/*release || echo "Failed to find release") echo "Distribution Version: $TMP" >> $DEBUG_LOG } From 3affa73257bcd7cb711a1448019d8e6fc6f0cb0d Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 20 Jul 2016 12:43:30 -0500 Subject: [PATCH 295/311] Only re-block whitelist deletions if in adlists * Prevent blocking benign/untracked domains deleted off whitelist * Issue #581 --- advanced/Scripts/whitelist.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 266ac49e..d43f2e45 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -175,20 +175,23 @@ function ModifyHostFile(){ echo ":::" echo "::: Modifying HOSTS file to un-whitelist domains..." for rdom in "${domToRemoveList[@]}" - 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 - echo " done!" - else - echo -n "::: Un-whitelisting $rdom on IPv4" - echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - echo " done!" - fi - echo -n "::: Removing $rdom from $whitelist..." - echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist - echo " done!" - done + do + if grep -q "$rdom" /etc/pihole/*.domains; then + echo "::: AdLists contain $rdom, re-adding block" + if [[ -n $piholeIPv6 ]];then + echo -n "::: Restoring block for $rdom on IPv4 and IPv6..." + echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList + echo " done!" + else + echo -n "::: Restoring block for $rdom on IPv4" + echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList + echo " done!" + fi + fi + echo -n "::: Removing $rdom from $whitelist..." + echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist + echo " done!" + done fi } From 5fb6c5b01209fe7c99e3e6e271e814272c44a270 Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 20 Jul 2016 12:53:31 -0500 Subject: [PATCH 296/311] Making the whitelist re-block echo consistent with other WL/BL echos --- advanced/Scripts/whitelist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index d43f2e45..5195aa83 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -183,7 +183,7 @@ function ModifyHostFile(){ echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList echo " done!" else - echo -n "::: Restoring block for $rdom on IPv4" + echo -n "::: Restoring block for $rdom on IPv4..." echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList echo " done!" fi From 941525d1e0fe2916cf8d4ee74a51ecd65eeff758 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 22 Jul 2016 11:54:17 +0100 Subject: [PATCH 297/311] Development out of sync with master. (#588) * adding links to optimal.com Also added image of Pi-hole's stats from Optimal.com and a bitcoin donation address per some user requests. * simplified and new additions I tried to simplify the readme page a bit. I also added some new links to some helper videos and added some screenshots of the whitelist editor. * updated dashboard pic * Update README.md * simplified donation section * forgot to remove the old donation stuff * Hosts-file.net moved to https * removed pihole berry from images also added adafruit livestream video * Update README.md update "How does it work" video --- README.md | 119 +++++++++++++++++++++++++----------------------- adlists.default | 2 +- 2 files changed, 62 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 940fe636..deea666e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,9 @@ # Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) - -[![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - 1. Install Raspbian -2. Run the command below +2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) ### ```curl -L https://install.pi-hole.net | bash``` @@ -16,21 +13,73 @@ wget -O basic-install.sh https://install.pi-hole.net chmod +x basic-install.sh ./basic-install.sh ``` +If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer + 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 -[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") +## How To Install Pi-hole -## Catch us out on the net: -Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) - -reddit: [/r/pihole](https://www.reddit.com/r/pihole/) +[![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) ## How Does It Work? **Watch the 60-second video below to get a quick overview** -[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) +[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho) + +## Pi-hole Is Free, But Powered By Your Donations +Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. +* ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) +* ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) +* ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL +* ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission) + + +## Get Help Or Connect With Us On The Web + +- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) +- [/r/pihole](https://www.reddit.com/r/pihole/) +- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) +- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) +- [FAQs](https://pi-hole.net/help/) +- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Technical Details + +The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. + +### Gravity +The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). + +## Web Interface +The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: + +`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` + +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/gTq2GbS.png) + +### Whitelist and blacklist + +Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details +![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png) + +## API + +A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: +```JSON +{ + "domains_being_blocked": "136708", + "dns_queries_today": "18108", + "ads_blocked_today": "14648", + "ads_percentage_today": "80.89" +} +``` +The same output can be acheived on the CLI by running `chronometer.sh -j` + +## Real-time Statistics + +You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). +![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) ## Pi-hole Projects - [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) @@ -47,6 +96,7 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage +- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI) - [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) - [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) @@ -60,52 +110,5 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/) - [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) - [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) -## Partnering With Optimal.com - -Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/). - -## Technical Details - -The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. - -A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). - -## Gravity -The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). - -## Whitelist and blacklist -Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details - -## Web Interface -The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: - -`http://192.168.1.x/admin/index.php` - -![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) - -### API - -A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: -```JSON -{ - "domains_being_blocked": "136708", - "dns_queries_today": "18108", - "ads_blocked_today": "14648", - "ads_percentage_today": "80.89" -} -``` -The same output can be acheived on the CLI by running `chronometer.sh -j` - -![Web](http://i.imgur.com/m114SCn.png) - -## Real-time Statistics - -You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). -![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) - -## Help -- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details -- There is also an [FAQ section on pi-hole.net](http://pi-hole.net) - ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. diff --git a/adlists.default b/adlists.default index d2b5e798..2c171e87 100644 --- a/adlists.default +++ b/adlists.default @@ -22,7 +22,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt # hosts-file.net list. Updated frequently, but has been known to block legitimate sites. -http://hosts-file.net/ad_servers.txt +https://hosts-file.net/ad_servers.txt # Mahakala list. Has been known to block legitimage domains including the entire .com range. # Warning: Due to the sheer size of this list, the web admin console will be unresponsive. From 51dcc2bc0f07fbe472d7280bb2ec0484e90c505d Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 22 Jul 2016 11:56:54 +0100 Subject: [PATCH 298/311] Update README.md Add badge for bountysource to show avtive bounties. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index deea666e..3d849a9d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=3011939)](https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE) + # Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) From 60aad3f19b910734ae22683f358d951a72b1e2d0 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 22 Jul 2016 11:59:19 +0100 Subject: [PATCH 299/311] Revert "Development out of sync with master." --- README.md | 119 +++++++++++++++++++++++------------------------- adlists.default | 2 +- 2 files changed, 59 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index deea666e..940fe636 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # Automated Install ##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) + +[![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + 1. Install Raspbian -2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) +2. Run the command below ### ```curl -L https://install.pi-hole.net | bash``` @@ -13,73 +16,21 @@ wget -O basic-install.sh https://install.pi-hole.net chmod +x basic-install.sh ./basic-install.sh ``` -If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer - 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/). -## How To Install Pi-hole +## Pi-hole Is Free, But Powered By Your Donations +[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "Free, but powered by donations")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") -[![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) +## Catch us out on the net: +Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) + +reddit: [/r/pihole](https://www.reddit.com/r/pihole/) ## How Does It Work? **Watch the 60-second video below to get a quick overview** -[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho) - -## Pi-hole Is Free, But Powered By Your Donations -Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. -* ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) -* ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) -* ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL -* ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission) - - -## Get Help Or Connect With Us On The Web - -- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) -- [/r/pihole](https://www.reddit.com/r/pihole/) -- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) -- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) -- [FAQs](https://pi-hole.net/help/) -- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -## Technical Details - -The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. - -### Gravity -The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). - -## Web Interface -The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: - -`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` - -![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/gTq2GbS.png) - -### Whitelist and blacklist - -Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details -![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png) - -## API - -A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: -```JSON -{ - "domains_being_blocked": "136708", - "dns_queries_today": "18108", - "ads_blocked_today": "14648", - "ads_percentage_today": "80.89" -} -``` -The same output can be acheived on the CLI by running `chronometer.sh -j` - -## Real-time Statistics - -You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). -![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) +[![Pi-hole exlplained](http://i.imgur.com/qNybJDX.png)](https://vimeo.com/135965232) ## Pi-hole Projects - [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) @@ -96,7 +47,6 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage -- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI) - [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) - [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) @@ -110,5 +60,52 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) - [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) +## Partnering With Optimal.com + +Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/). + +## Technical Details + +The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. + +A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0). + +## Gravity +The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). + +## Whitelist and blacklist +Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details + +## Web Interface +The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: + +`http://192.168.1.x/admin/index.php` + +![Pi-hole Advanced Stats Dashboard](http://i.imgur.com/rTlLYPh.png) + +### API + +A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: +```JSON +{ + "domains_being_blocked": "136708", + "dns_queries_today": "18108", + "ads_blocked_today": "14648", + "ads_percentage_today": "80.89" +} +``` +The same output can be acheived on the CLI by running `chronometer.sh -j` + +![Web](http://i.imgur.com/m114SCn.png) + +## Real-time Statistics + +You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). +![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) + +## Help +- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details +- There is also an [FAQ section on pi-hole.net](http://pi-hole.net) + ## Other Operating Systems This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. diff --git a/adlists.default b/adlists.default index 2c171e87..d2b5e798 100644 --- a/adlists.default +++ b/adlists.default @@ -22,7 +22,7 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt # hosts-file.net list. Updated frequently, but has been known to block legitimate sites. -https://hosts-file.net/ad_servers.txt +http://hosts-file.net/ad_servers.txt # Mahakala list. Has been known to block legitimage domains including the entire .com range. # Warning: Due to the sheer size of this list, the web admin console will be unresponsive. From 8550b76e23540be096ea67aac22bf233f4c25103 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 24 Jul 2016 22:42:06 -0600 Subject: [PATCH 300/311] add gateway to interface configuration --- automated install/basic-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 29e3237f..55206faf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -359,6 +359,7 @@ setStaticIPv4() { $SUDO echo "ONBOOT=yes" >> $IFCFG_FILE $SUDO echo "IPADDR=$IPADDR" >> $IFCFG_FILE $SUDO echo "PREFIX=$CIDR" >> $IFCFG_FILE + $SUDO echo "GATEWAY=$IPv4gw" >> $IFCFG_FILE $SUDO echo "USERCTL=no" >> $IFCFG_FILE $SUDO ip addr replace dev "$piholeInterface" "$IPv4addr" if [ -x "$(command -v nmcli)" ];then From 02c4669e95e0dc3d2762231ca2b529cf0bbef9e7 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 26 Jul 2016 20:46:43 -0700 Subject: [PATCH 301/311] Typo/Linter fix Fix a few typo's, run through linter for format corrections. --- README.md | 129 +++++++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index deea666e..d8990967 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,64 @@ -# Automated Install -##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!) +# Automated Install -1. Install Raspbian +Designed For Raspberry Pi A+, B, B+, 2, 3B, and Zero (with an Ethernet/Wi-Fi adapter) +Works on most Debian and CentOS/RHEL based distributions! -2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) +1. Install Raspbian +2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) -### ```curl -L https://install.pi-hole.net | bash``` +## `curl -L https://install.pi-hole.net | bash` -#### Alternative Semi-Automated install #### -``` +### Alternative Semi-Automated install + +```bash wget -O basic-install.sh https://install.pi-hole.net chmod +x basic-install.sh ./basic-install.sh ``` + If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer - -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/). +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/). ## How To Install Pi-hole [![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) -## How Does It Work? +## How It Works + **Watch the 60-second video below to get a quick overview** [![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho) ## Pi-hole Is Free, But Powered By Your Donations -Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee. -* ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) -* ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) -* ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL -* ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission) +Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the monthly fee. + +- ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) +- ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) +- ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL +- ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small commission) ## Get Help Or Connect With Us On The Web -- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) -- [/r/pihole](https://www.reddit.com/r/pihole/) -- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) -- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) -- [FAQs](https://pi-hole.net/help/) -- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) +- [/r/pihole](https://www.reddit.com/r/pihole/) +- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) +- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) +- [FAQs](https://pi-hole.net/help/) +- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Technical Details -The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. +The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. ### Gravity -The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). + +The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). ## Web Interface -The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: + +The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at: `http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` @@ -60,55 +66,58 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb ### Whitelist and blacklist -Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details -![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png) +Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details ![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png) ## API A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: -```JSON + +```json { - "domains_being_blocked": "136708", - "dns_queries_today": "18108", - "ads_blocked_today": "14648", - "ads_percentage_today": "80.89" + "domains_being_blocked": "136708", + "dns_queries_today": "18108", + "ads_blocked_today": "14648", + "ads_percentage_today": "80.89" } ``` -The same output can be acheived on the CLI by running `chronometer.sh -j` + +The same output can be achieved on the CLI by running `chronometer.sh -j` ## Real-time Statistics -You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). -![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) +You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). ![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg) ## Pi-hole Projects -- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) -- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/) -- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) -- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) -- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) -- [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) -- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/) -- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0) -- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/) -- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) + +- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) +- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/) +- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) +- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) +- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) +- [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) +- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/) +- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0) +- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/) +- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) ## Coverage -- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI) -- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) -- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) -- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) -- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) -- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d) -- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) -- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)! -- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m) -- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s) -- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s) -- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) -- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) + +- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI) +- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) +- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) +- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) +- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) +- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d) +- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) +- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)! +- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m) +- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s) +- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s) +- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) +- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) ## Other Operating Systems -This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. + +This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi. From 0749e4ed70c6f5c34d1e2df1b0ff67b95f8f9aba Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 27 Jul 2016 18:58:05 -0700 Subject: [PATCH 302/311] Move BountySource to top position --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7feabfaa..aae3693f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Automated Install - [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=3011939)](https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE) +# Automated Install + Designed For Raspberry Pi A+, B, B+, 2, 3B, and Zero (with an Ethernet/Wi-Fi adapter) Works on most Debian and CentOS/RHEL based distributions! From 20d8c9053b126476283632c3a1f951eb308d34c8 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 29 Jul 2016 13:05:15 -0700 Subject: [PATCH 303/311] Remove defunct Optimal link Optimal has discontinued it's app program. Removing dead link --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index aae3693f..acfce86c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Send a one-time donation or sign up for Optimal.com's service using our link bel - ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY) - ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole) - ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL -- ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small commission) ## Get Help Or Connect With Us On The Web From e642b41b5b1870184ebaf951eb9959818475ebe9 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 29 Jul 2016 16:35:26 -0700 Subject: [PATCH 304/311] Add PullApprove configuration --- .pullapprove.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .pullapprove.yml diff --git a/.pullapprove.yml b/.pullapprove.yml new file mode 100644 index 00000000..ae786ecf --- /dev/null +++ b/.pullapprove.yml @@ -0,0 +1,14 @@ +approve_by_comment: true +approve_regex: '^(Approved|:shipit:|:\+1:)' +reject_regex: '^(Rejected|:-1:)' +reset_on_push: true +author_approval: required +reviewers: + members: + - brantje + - dschaper + - jacobsalmela + - Mcat12 + - PromoFaux + name: pullapprove + required: 3 From a3b3a7a34dfbef0eb73c915829bca18aedfca700 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Aug 2016 21:43:13 +0100 Subject: [PATCH 305/311] Add option for uploading debug log to termbin --- advanced/Scripts/piholeDebug.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 36ae15bc..ec08c984 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -337,17 +337,27 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "::: Finshed debugging!" - TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) + echo "::: Finshed debugging!" + echo "::: The degug log can be uploaded to Termbin.com for easier sharing." + read -r -p "::: Would you like to upload the log? [y/N] " response + case $response in + [yY][eE][sS]|[yY]) + TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) + ;; + *) + echo "::: Log will NOT be uploaded to Termbin." + ;; + esac - # Check if termbin.com is reachable. When it's not, point to local log instead - if [ -n "$TERMBIN" ] - then - echo "::: Debug log can be found at : $TERMBIN" - else - echo "::: Debug log can be found at : /var/log/pihole_debug.log" - fi + # Check if termbin.com is reachable. When it's not, point to local log instead + if [ -n "$TERMBIN" ] + then + echo "::: Debug log can be found at : $TERMBIN" + else + echo "::: Debug log can be found at : /var/log/pihole_debug.log" + fi } + trap finalWork EXIT ### Method calls for additional logging ### From 66ff9a24c6a2c37816702adc527aa802f9f90951 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 1 Aug 2016 21:54:42 +0100 Subject: [PATCH 306/311] Add piholeDebug to the chmod 755 command in install script. Not sure how that went missing... --- 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 29e3237f..afd5f351 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -547,7 +547,7 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeDebug,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole From 6a17a3eeec3dfb5de0920e96ca8f419cb844389d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 2 Aug 2016 19:44:11 +0100 Subject: [PATCH 307/311] Add command to pihole script --- pihole | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pihole b/pihole index bbcb82d0..73c7fa64 100755 --- a/pihole +++ b/pihole @@ -74,6 +74,10 @@ function uninstallFunc { exit 1 } +function versionFunc{ + $SUDO /opt/pihole/version.sh + exit 1 +} function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" @@ -90,6 +94,7 @@ function helpFunc { echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -h, help Show this help dialog" + echo "::: -v, version Show current versions" echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } @@ -109,6 +114,7 @@ case "$1" in "-s" | "setupLCD" ) setupLCDFunction;; "-c" | "chronometer" ) chronometerFunc "$@";; "-h" | "help" ) helpFunc;; +"-v" | "version" ) versionFunc;; "uninstall" ) uninstallFunc;; * ) helpFunc;; esac From e11ef5a7f01a50e6e1a7373345b907b9a3e6234f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 2 Aug 2016 20:07:09 +0100 Subject: [PATCH 308/311] Add version display script. Also checks current version on web and reports version. --- advanced/Scripts/version.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 advanced/Scripts/version.sh diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh new file mode 100644 index 00000000..e7e7c782 --- /dev/null +++ b/advanced/Scripts/version.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Pi-hole: A black hole for Internet advertisements +# (c) 2015, 2016 by Jacob Salmela +# Network-wide ad blocking via your Raspberry Pi +# http://pi-hole.net +# Whitelists domains +# +# 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. + +piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) +webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0) + +piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//') +webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//') + +echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)" +echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)" \ No newline at end of file From 57df56dc629e2b71c15fef812c96d52f19eee244 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 2 Aug 2016 20:08:21 +0100 Subject: [PATCH 309/311] Add version.sh to the install script --- 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 29e3237f..d99433c2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -547,7 +547,8 @@ installScripts() { $SUDO cp /etc/.pihole/advanced/Scripts/updateDashboard.sh /opt/pihole/updateDashboard.sh $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh + $SUDO cp /etc/.pihole/advanced/Scripts/version.sh /opt/pihole/version.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD, version}.sh $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole From 2bc364023afec556b9f04d7c7ad6673b0234b705 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Tue, 2 Aug 2016 20:14:36 +0100 Subject: [PATCH 310/311] Remove erroneous space in chmod command Fix spacing in help function --- automated install/basic-install.sh | 2 +- pihole | 89 +++++++++++++++--------------- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d99433c2..254d601f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -548,7 +548,7 @@ installScripts() { $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh $SUDO cp /etc/.pihole/advanced/Scripts/version.sh /opt/pihole/version.sh - $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD, version}.sh + $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD,version}.sh $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole $SUDO chmod 755 /usr/local/bin/pihole $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash_completion.d/pihole diff --git a/pihole b/pihole index 73c7fa64..64a36c59 100755 --- a/pihole +++ b/pihole @@ -12,13 +12,13 @@ # Must be root to use this tool if [[ ! $EUID -eq 0 ]];then - #echo "::: You are root." + #echo "::: You are root." #else - #echo "::: Sudo will be used for this tool." + #echo "::: Sudo will be used for this tool." # Check if it is actually installed # If it isn't, exit because the pihole cannot be invoked without privileges. if [ -x "$(command -v sudo)" ];then - export SUDO="sudo" + export SUDO="sudo" else echo "::: Please install sudo or run this as root." exit 1 @@ -26,81 +26,82 @@ if [[ ! $EUID -eq 0 ]];then fi function whitelistFunc { - shift - $SUDO /opt/pihole/whitelist.sh "$@" - exit 1 + shift + $SUDO /opt/pihole/whitelist.sh "$@" + exit 1 } function blacklistFunc { - shift - $SUDO /opt/pihole/blacklist.sh "$@" - exit 1 + shift + $SUDO /opt/pihole/blacklist.sh "$@" + exit 1 } function debugFunc { - $SUDO /opt/pihole/piholeDebug.sh - exit 1 + $SUDO /opt/pihole/piholeDebug.sh + exit 1 } function flushFunc { - $SUDO /opt/pihole/piholeLogFlush.sh - exit 1 + $SUDO /opt/pihole/piholeLogFlush.sh + exit 1 } function updateDashboardFunc { - $SUDO /opt/pihole/updateDashboard.sh - exit 1 + $SUDO /opt/pihole/updateDashboard.sh + exit 1 } function updateGravityFunc { - $SUDO /opt/pihole/gravity.sh - exit 1 + $SUDO /opt/pihole/gravity.sh + exit 1 } function setupLCDFunction { - $SUDO /opt/pihole/setupLCD.sh - exit 1 + $SUDO /opt/pihole/setupLCD.sh + exit 1 } function chronometerFunc { - shift - $SUDO /opt/pihole/chronometer.sh "$@" - exit 1 + shift + $SUDO /opt/pihole/chronometer.sh "$@" + exit 1 } function uninstallFunc { - $SUDO /opt/pihole/uninstall.sh - exit 1 + $SUDO /opt/pihole/uninstall.sh + exit 1 } -function versionFunc{ +function versionFunc { $SUDO /opt/pihole/version.sh exit 1 } + function helpFunc { - echo "::: Control all PiHole specific functions!" - echo ":::" - echo "::: Usage: pihole [options]" - echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" - echo ":::" - echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" - echo "::: -v, version Show current versions" - echo "::: uninstall Uninstall Pi-Hole from your system!" - exit 1 + echo "::: Control all PiHole specific functions!" + echo ":::" + echo "::: Usage: pihole [options]" + echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" + echo ":::" + echo "::: Options:" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" + echo "::: -v, version Show current versions" + echo "::: uninstall Uninstall Pi-Hole from your system :(!" + exit 1 } if [[ $# = 0 ]]; then - helpFunc + helpFunc fi # Handle redirecting to specific functions based on arguments From 95edb49bb824daa93fc37a57a014256844728d92 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 1 Aug 2016 21:43:13 +0100 Subject: [PATCH 311/311] Add option for uploading debug log to termbin --- advanced/Scripts/piholeDebug.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 36ae15bc..ec08c984 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -337,17 +337,27 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "::: Finshed debugging!" - TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) + echo "::: Finshed debugging!" + echo "::: The degug log can be uploaded to Termbin.com for easier sharing." + read -r -p "::: Would you like to upload the log? [y/N] " response + case $response in + [yY][eE][sS]|[yY]) + TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) + ;; + *) + echo "::: Log will NOT be uploaded to Termbin." + ;; + esac - # Check if termbin.com is reachable. When it's not, point to local log instead - if [ -n "$TERMBIN" ] - then - echo "::: Debug log can be found at : $TERMBIN" - else - echo "::: Debug log can be found at : /var/log/pihole_debug.log" - fi + # Check if termbin.com is reachable. When it's not, point to local log instead + if [ -n "$TERMBIN" ] + then + echo "::: Debug log can be found at : $TERMBIN" + else + echo "::: Debug log can be found at : /var/log/pihole_debug.log" + fi } + trap finalWork EXIT ### Method calls for additional logging ###