From c7141966475985a5675597428b8d136b6dd8268d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 17 Apr 2016 22:46:06 -0400 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 3fda2d9ac3017b5adb2b011ef06c43d3e73801bb Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 25 May 2016 17:07:12 -0400 Subject: [PATCH 05/12] 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 06/12] 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 07/12] 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 08/12] 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 09/12] 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 10/12] 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 11/12] 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 12/12] 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