From 01d7fc0ac9f68d9c6172d7e860288fcf7e743662 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 10:07:12 +0000 Subject: [PATCH 01/12] Removed apt-get update/upgrade, instead checking for updates availible and advising user to update/upgrade after installation of pi-hole. Addresses issue #218 --- automated install/basic-install.sh | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d9e448a9..09fe2eb3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -293,24 +293,27 @@ stopServices(){ } checkForDependencies(){ - echo ":::" - #Check to see if apt-get update has already been run today - timestamp=$(stat -c %Y /var/cache/apt/) - timestampAsDate=$(date -d @$timestamp "+%b %e") + + #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 + today=$(date "+%b %e") - if [ ! "$today" == "$timestampAsDate" ]; then - #update package lists - echo -n "::: Updating package list before install...." - $SUDO apt-get -qq update > /dev/null & spinner $! - echo " done!" - echo -n "::: Upgrading installed apt-get packages...." - $SUDO apt-get -y -qq upgrade > /dev/null & spinner $! - echo " done!" - else - echo "::: Apt-get update already run today, any more would be overkill..." - fi - + echo -n "::: Checking apt-get for upgraded packages...." + updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $! + echo " done!" + + if [ updatesToInstall > 0 ]; then + echo "::: There are $updatesToInstall updates availible for your pi!" + echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" + echo "::: after pi-hole has finished installing. + echo ":::" + echo "::: Continuing with pi-hole installation..." + else + echo "::: Your pi is up to date! Continuing with pi-hole installation..." + fi echo ":::" echo "::: Checking dependencies:" From 32389e4ab80079e5ee49606503f0d653d82ffefe Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 25 Jan 2016 02:27:44 -0800 Subject: [PATCH 02/12] Terminate string with missing quote --- 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 09fe2eb3..06fffd8e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -308,7 +308,7 @@ checkForDependencies(){ if [ updatesToInstall > 0 ]; then echo "::: There are $updatesToInstall updates availible for your pi!" echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" - echo "::: after pi-hole has finished installing. + echo "::: after pi-hole has finished installing." echo ":::" echo "::: Continuing with pi-hole installation..." else From e99be28a73c1ba49d377ce6cace15fb5a1451b7e Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 25 Jan 2016 02:31:03 -0800 Subject: [PATCH 03/12] Variable 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 06fffd8e..de9cfed3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -305,7 +305,7 @@ checkForDependencies(){ updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $! echo " done!" - if [ updatesToInstall > 0 ]; then + if [ $updatesToInstall > 0 ]; then echo "::: There are $updatesToInstall updates availible for your pi!" echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" echo "::: after pi-hole has finished installing." From 4cedca342748df3dd5363a88cb003e8c08c7a762 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 12:47:03 +0000 Subject: [PATCH 04/12] add in a prompt to give users the option to quit installation or continue --- automated install/basic-install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index de9cfed3..0feb5e8d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -310,7 +310,16 @@ checkForDependencies(){ echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" echo "::: after pi-hole has finished installing." echo ":::" - echo "::: Continuing with pi-hole installation..." + #add in a prompt to give users the option to quit installation or continue + echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):" + read answer + + case "$answer" in + [yY][eE][sS]|[yY] ) echo "::: Continuing!;; + * ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" + exit 0;; + esac + else echo "::: Your pi is up to date! Continuing with pi-hole installation..." fi From 354a42dd00502735238920ddfdae9e8af9b11b41 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 12:49:04 +0000 Subject: [PATCH 05/12] close quotes on line 318!!! --- 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 0feb5e8d..d96a4416 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -315,7 +315,7 @@ checkForDependencies(){ read answer case "$answer" in - [yY][eE][sS]|[yY] ) echo "::: Continuing!;; + [yY][eE][sS]|[yY] ) echo "::: Continuing!";; * ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" exit 0;; esac From 74ea597bd811a6dd01b17af8489012113243222a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 15:52:22 +0000 Subject: [PATCH 06/12] Cosmetic enhancement. Add the domain 'Pi-Hole.IsWorking.OK' to the top of the domain list to return a friendlier looking domain when pinging a blocked host! --- gravity.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gravity.sh b/gravity.sh index 255bb264..c33eb05c 100755 --- a/gravity.sh +++ b/gravity.sh @@ -55,7 +55,8 @@ sources=('https://adaway.org/hosts.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://winhelp2002.mvps.org/hosts.txt' + 'http://mirror1.malwaredomains.com/files/justdomains') # Variables for various stages of downloading and formatting the list basename=pihole @@ -256,10 +257,15 @@ function gravity_hostFormat() { 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 - cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' > $piholeDir/$accretionDisc + #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 - cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' > $piholeDir/$accretionDisc + # 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 # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp $piholeDir/$accretionDisc $adList From e87443b3e4c4ec10de1bed3425e93441d5109c6c Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 15:53:49 +0000 Subject: [PATCH 07/12] add 'http://mirror1.malwaredomains.com/files/justdomains' to list of ad-list sources, can be removed if it causes problems --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c33eb05c..5097e050 100755 --- a/gravity.sh +++ b/gravity.sh @@ -56,7 +56,7 @@ sources=('https://adaway.org/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://mirror1.malwaredomains.com/files/justdomains') # Variables for various stages of downloading and formatting the list basename=pihole From 2b99fa81f337bb166f04f33f75a4e2aa2b7f665e Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 25 Jan 2016 16:08:48 +0000 Subject: [PATCH 08/12] Tidy up output lines around new code --- 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 d96a4416..a8676721 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -300,11 +300,12 @@ checkForDependencies(){ # if so, advise the user to run apt-get update/upgrade at their own discretion today=$(date "+%b %e") - + echo ":::" echo -n "::: Checking apt-get for upgraded packages...." updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) & spinner $! echo " done!" + echo ":::" if [ $updatesToInstall > 0 ]; then echo "::: There are $updatesToInstall updates availible for your pi!" echo "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" From 80bec9c5cfa72ef28c4d7732ad4cb487189045ec Mon Sep 17 00:00:00 2001 From: PromoFaux Date: Mon, 25 Jan 2016 16:28:26 +0000 Subject: [PATCH 09/12] Delete install Not sure how this got in here... :) --- automated install/install | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 automated install/install diff --git a/automated install/install b/automated install/install deleted file mode 100644 index e69de29b..00000000 From 98a0d17431df81e40d505ad19eb29909e9c9618a Mon Sep 17 00:00:00 2001 From: PromoFaux Date: Wed, 27 Jan 2016 15:28:40 +0000 Subject: [PATCH 10/12] Update basic-install.sh Emergency Bug fix. I take the blame for this one, it got lost in a merge! --- 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 a8676721..94fd0b46 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -182,7 +182,7 @@ use4andor6(){ useIPv6dialog(){ 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 mkdir -p /etc/pihole/ + $SUDO touch /etc/pihole/.useIPv6 } @@ -448,7 +448,7 @@ runGravity(){ installPihole(){ checkForDependencies # done stopServices - + $SUDO mkdir -p /etc/pihole/ $SUDO chown www-data:www-data /var/www/html $SUDO chmod 775 /var/www/html $SUDO usermod -a -G www-data pi From 3d78b44a8ee5933a4dfe7f7396e161681a5af0d6 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 27 Jan 2016 22:32:08 +0000 Subject: [PATCH 11/12] Changes as in #253, but with less commits to keep the repo tidy --- automated install/basic-install.sh | 67 ++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a8676721..ed5fd60d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -16,7 +16,9 @@ # # curl -L install.pi-hole.net | bash + ######## VARIABLES ######### + tmpLog=/tmp/pihole-install.log instalLogLoc=/etc/pihole/install.log @@ -34,7 +36,9 @@ 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}') @@ -59,7 +63,7 @@ else fi fi -if [ -f "/etc/dnsmasq.d/01-pihole.conf" ]; then +if [ -d "/etc/pihole" ]; then #Likely an existing install upgrade=true else @@ -182,7 +186,7 @@ use4andor6(){ useIPv6dialog(){ 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 mkdir -p /etc/pihole/ + $SUDO touch /etc/pihole/.useIPv6 } @@ -256,7 +260,9 @@ setStaticIPv4(){ else setDHCPCD $SUDO ip addr replace dev $piholeInterface $IPv4addr - echo "Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" + echo "::: Setting IP to $IPv4addr. You may need to restart after the install is complete." + echo ":::" fi } @@ -269,7 +275,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 chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh + $SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh $SUDO echo " done." } @@ -299,30 +305,47 @@ checkForDependencies(){ #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! + + timestamp=$(stat -c %Y /var/cache/apt/) + timestampAsDate=$(date -d @$timestamp "+%b %e") today=$(date "+%b %e") - echo ":::" + + 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) & spinner $! + updatesToInstall=$(sudo apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst) echo " done!" - + echo ":::" - if [ $updatesToInstall > 0 ]; then + 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 "::: Please consider running 'sudo apt-get update', followed by 'sudo apt-get upgrade'" - echo "::: after pi-hole has finished installing." + echo "::: Please run 'sudo apt-get upgrade' before continuing with installation" echo ":::" + echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" + echo ":::" + + exit 1 #add in a prompt to give users the option to quit installation or continue - echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):" - read answer + #echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):" + #read answer - case "$answer" in - [yY][eE][sS]|[yY] ) echo "::: Continuing!";; - * ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" - exit 0;; - esac - - else - echo "::: Your pi is up to date! Continuing with pi-hole installation..." + #case "$answer" in + # [yY][eE][sS]|[yY] ) echo "::: Continuing!";; + # * ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" + + #esac fi echo ":::" @@ -477,6 +500,7 @@ The install log is in /etc/pihole." $r $c ######## SCRIPT ############ # Start the installer +$SUDO mkdir -p /etc/pihole/ welcomeDialogs # Just back up the original Pi-hole right away since it won't take long and it gets it out of the way @@ -486,8 +510,6 @@ chooseInterface # Let the user decide if they want to block ads over IPv4 and/or IPv6 use4andor6 - - # Install and log everything to a file installPihole | tee $tmpLog @@ -495,6 +517,5 @@ installPihole | tee $tmpLog $SUDO mv $tmpLog $instalLogLoc displayFinalMessage - $SUDO service dnsmasq start $SUDO service lighttpd start From c00fb44cee77ae61e44acc1cb00e55c1ca457f9e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 27 Jan 2016 23:28:36 +0000 Subject: [PATCH 12/12] Do not force apt-get upgrade on the user. Instead, advise them. We only need to make sure apt-get update has been run --- automated install/basic-install.sh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ed5fd60d..745566aa 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -331,21 +331,8 @@ checkForDependencies(){ echo "::: Your pi is up to date! Continuing with pi-hole installation..." else echo "::: There are $updatesToInstall updates availible for your pi!" - echo "::: Please run 'sudo apt-get upgrade' before continuing with installation" + echo "::: We recommend you run 'sudo apt-get upgrade' after installing Pi-Hole! " echo ":::" - echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" - echo ":::" - - exit 1 - #add in a prompt to give users the option to quit installation or continue - #echo -n "::: Would you like to continue with the pi-hole installation? (Y/n):" - #read answer - - #case "$answer" in - # [yY][eE][sS]|[yY] ) echo "::: Continuing!";; - # * ) echo "::: Quitting install, please run 'curl -L install.pi-hole.net | bash' after updating packages!" - - #esac fi echo ":::" @@ -518,4 +505,4 @@ $SUDO mv $tmpLog $instalLogLoc displayFinalMessage $SUDO service dnsmasq start -$SUDO service lighttpd start +$SUDO service lighttpd start \ No newline at end of file