From 1dd9f0747eb15f333765ac74e1309ba6d4d3017f Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 7 Sep 2016 19:41:54 -0600 Subject: [PATCH 01/55] add gateway to interface configuration pi-hole@9cb4e8b broke #593 original commit 8550b76 --- 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 0caa8bf7..3963b6ef 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -358,6 +358,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 05ad4445b54ded54b60f10b543428878a1277bbf Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 7 Sep 2016 19:58:35 -0600 Subject: [PATCH 02/55] add dns to sysconfig interface 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 3963b6ef..1356a002 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -359,6 +359,8 @@ setStaticIPv4() { ${SUDO} echo "IPADDR=$IPADDR" >> ${IFCFG_FILE} ${SUDO} echo "PREFIX=$CIDR" >> ${IFCFG_FILE} ${SUDO} echo "GATEWAY=$IPv4gw" >> ${IFCFG_FILE} + ${SUDO} echo "DNS1=$piholeDNS1" >> ${IFCFG_FILE} + ${SUDO} echo "DNS2=$piholeDNS2" >> ${IFCFG_FILE} ${SUDO} echo "USERCTL=no" >> ${IFCFG_FILE} ${SUDO} ip addr replace dev "$piholeInterface" "$IPv4addr" if [ -x "$(command -v nmcli)" ];then From 6c0c6182e9979e87300ca8e2e25b7a48041db96c Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 7 Sep 2016 20:06:36 -0600 Subject: [PATCH 03/55] fix newline in configureSelinux stdout --- 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 1356a002..9f31100b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -871,9 +871,9 @@ configureSelinux() { printf "::: Enabling httpd server side includes (SSI).. " ${SUDO} setsebool -P httpd_ssi_exec on if [ $? -eq 0 ]; then - echo -n "Success\n" + echo -n "Success" fi - printf ":::\tCompiling Pi-Hole SELinux policy..\n" + printf "\n:::\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 From 640af300cba4c032d55f9af7e5b2ea2fd6f0893c Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 7 Sep 2016 20:38:44 -0600 Subject: [PATCH 04/55] additional hostname checks in gravity.sh - Test if /etc/hostname exists before attempting to cat the file. - Add alternative hostname discovery via hostname command - Add an error message to stdout if unable to determine host fqdn --- gravity.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 0b1622e0..a1485acf 100755 --- a/gravity.sh +++ b/gravity.sh @@ -264,7 +264,13 @@ function gravity_unique() { function gravity_hostFormat() { # Format domain list as "192.168.x.x domain.com" echo "::: Formatting domains into a HOSTS file..." - hostname=$( Date: Mon, 12 Sep 2016 18:12:31 +0100 Subject: [PATCH 05/55] Only pull master branch, the rest aren't needed! --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pihole b/pihole index bd948b55..d6da8366 100755 --- a/pihole +++ b/pihole @@ -55,7 +55,7 @@ function updateDashboardFunc { function updatePiholeFunc { echo "::: Fetching latest changes from Github..." cd /etc/.pihole - ${SUDO} git pull + ${SUDO} git pull origin master ${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole exit 1 } From 0229f7076176e777dbba05681fbcd2200280697c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 18:29:04 +0100 Subject: [PATCH 06/55] Make updatePiholeFunc a bit smarter. Only run update if version is not the latest. --- pihole | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pihole b/pihole index d6da8366..f23db60e 100755 --- a/pihole +++ b/pihole @@ -53,10 +53,26 @@ function updateDashboardFunc { } function updatePiholeFunc { - echo "::: Fetching latest changes from Github..." - cd /etc/.pihole - ${SUDO} git pull origin master - ${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole + echo "::: Checking for updates..." + piholeVersion=$(cd /etc/.pihole/ && 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/",$//') + + if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then + echo "::: Pi-hole is already up to date! Version: ${piholeVersion}" + echo ":::" + echo "::: No need to update!" + else + echo "::: An update is available! Current Version: ${piholeVersion}" + echo "::: Latest Version: ${piholeVersionLatest}" + echo ":::" + echo "::: Fetching latest changes from Github..." + cd /etc/.pihole + ${SUDO} git pull origin master + ${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole + echo ":::" + echo "::: Pi-hole has been updated, see https://changes.pi-hole.net for details" + fi + exit 1 } From d124c2c12e78426a823a430eaff4fdcd641ac8a7 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 18:57:19 +0100 Subject: [PATCH 07/55] Expand to check web admin versions --- pihole | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/pihole b/pihole index f23db60e..e6f6e292 100755 --- a/pihole +++ b/pihole @@ -57,20 +57,51 @@ function updatePiholeFunc { piholeVersion=$(cd /etc/.pihole/ && 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/",$//') + webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0) + 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)" + if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then - echo "::: Pi-hole is already up to date! Version: ${piholeVersion}" - echo ":::" + echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}" echo "::: No need to update!" - else - echo "::: An update is available! Current Version: ${piholeVersion}" - echo "::: Latest Version: ${piholeVersionLatest}" echo ":::" - echo "::: Fetching latest changes from Github..." + + if [[ ${webVersion} == ${webVersionLatest} ]] ; then + echo "::: Web Admin files are already up to date!" + echo "::: No need to update!" + echo ":::" + else + echo "::: An Update is available for the Web Admin!" + echo ":::" + echo "::: Fetching latest changes from GitHub..." + cd /var/www/html/admin + ${SUDO} git pull origin master + echo ":::" + echo "::: Pi-hole Web Admin has been updated to ${webVersion}" + echo "::: See https://changes.pi-hole.net for details" + fi + else + echo -n "::: An update is available for " + if [[ ${webVersion} == ${webVersionLatest} ]] ; then + echo " Pi-Hole!" + else + echo " Pi-Hole base files and the Web Admin. Both will be updated!" + fi + + echo "::: Fetching latest changes from GitHub..." cd /etc/.pihole ${SUDO} git pull origin master ${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole + echo ":::" - echo "::: Pi-hole has been updated, see https://changes.pi-hole.net for details" + echo "::: Pi-hole has been updated to version ${piholeVersionLatest}" + if [[ ${webVersion} != ${webVersionLatest} ]] ; then + echo "::: Web Admin has been updated to version ${webVersionLatest}" + fi + echo ":::" + echo "::: See https://changes.pi-hole.net for details" fi exit 1 From d58f7c6ec92a95903e5464420df30b9100633602 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 19:08:33 +0100 Subject: [PATCH 08/55] Remove references to dashboard update Script --- pihole | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pihole b/pihole index e6f6e292..8fc98f51 100755 --- a/pihole +++ b/pihole @@ -47,10 +47,6 @@ function flushFunc { exit 1 } -function updateDashboardFunc { - ${SUDO} /opt/pihole/updateDashboard.sh - exit 1 -} function updatePiholeFunc { echo "::: Checking for updates..." @@ -159,8 +155,7 @@ 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 "::: -ud, updateDashboard Update the web dashboard manually" - echo "::: -up, updatePihole Update Pi-hole" + echo "::: -up, updatePihole Update Pi-hole" 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" @@ -181,7 +176,6 @@ case "$1" in "-b" | "blacklist" ) blacklistFunc "$@";; "-d" | "debug" ) debugFunc;; "-f" | "flush" ) flushFunc;; -"-ud" | "updateDashboard" ) updateDashboardFunc;; "-up" | "updatePihole" ) updatePiholeFunc;; "-g" | "updateGravity" ) updateGravityFunc "$@";; "-s" | "setupLCD" ) setupLCDFunction;; From a3ef9efd2f6ecc65d41aed11d81b88c86a8d6c52 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 19:09:19 +0100 Subject: [PATCH 09/55] remove updateDashboard script --- advanced/Scripts/updateDashboard.sh | 69 ----------------------------- 1 file changed, 69 deletions(-) delete mode 100755 advanced/Scripts/updateDashboard.sh diff --git a/advanced/Scripts/updateDashboard.sh b/advanced/Scripts/updateDashboard.sh deleted file mode 100755 index 991089c2..00000000 --- a/advanced/Scripts/updateDashboard.sh +++ /dev/null @@ -1,69 +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 -# Updates the Pi-hole web interface -# -# 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. - -WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git" -WEB_INTERFACE_DIR="/var/www/html/admin" - -main() { - prerequisites - if ! is_repo; then - make_repo - fi - update_repo -} - -prerequisites() { - - # must be root to update - if [[ $EUID -ne 0 ]]; then - sudo bash "$0" "$@" - exit $? - fi - - # web interface must already exist. this is a (lazy) - # check to make sure pihole is actually installed. - if [ ! -d "$WEB_INTERFACE_DIR" ]; then - echo "$WEB_INTERFACE_DIR not found. Exiting." - exit 1 - fi - - if ! type "git" > /dev/null; then - apt-get -y install git - fi -} - -is_repo() { - # if the web interface directory does not have a .git folder - # it means its using the master.zip archive from the install - # script. - if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then - return 1 - fi - return 0 -} - -# removes the web interface installed from the master.zip archive and -# replaces it with the current master branch from github -make_repo() { - # remove the non-repod interface and clone the interface - rm -rf ${WEB_INTERFACE_DIR} - git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR" -} - -# pulls the latest master branch from github -update_repo() { - # pull the latest commits - cd "$WEB_INTERFACE_DIR" - git pull -} - -main From a0977af0818d9e27f49a4a38abfcb01de6d4e7a2 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 19:10:12 +0100 Subject: [PATCH 10/55] remove references to UpdateDashboard.sh --- 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 97171c31..0df28498 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -543,11 +543,10 @@ installScripts() { ${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} cp /etc/.pihole/advanced/Scripts/version.sh /opt/pihole/version.sh - ${SUDO} chmod 755 /opt/pihole/gravity.sh /opt/pihole/chronometer.sh /opt/pihole/whitelist.sh /opt/pihole/blacklist.sh /opt/pihole/piholeLogFlush.sh /opt/pihole/updateDashboard.sh /opt/pihole/uninstall.sh /opt/pihole/setupLCD.sh /opt/pihole/version.sh + ${SUDO} chmod 755 /opt/pihole/gravity.sh /opt/pihole/chronometer.sh /opt/pihole/whitelist.sh /opt/pihole/blacklist.sh /opt/pihole/piholeLogFlush.sh /opt/pihole/uninstall.sh /opt/pihole/setupLCD.sh /opt/pihole/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 ec0c68621c1d0f991c9176a967c9bfa8b86d2665 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 12 Sep 2016 19:40:34 +0100 Subject: [PATCH 11/55] add blank line after Current version display --- pihole | 1 + 1 file changed, 1 insertion(+) diff --git a/pihole b/pihole index 8fc98f51..00e4a7bf 100755 --- a/pihole +++ b/pihole @@ -58,6 +58,7 @@ function updatePiholeFunc { echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)" echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)" + echo ":::" if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}" From b1a7b0a1864f8a65fea94b226c80c776ce3dcc4e Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 15 Sep 2016 15:16:06 +0100 Subject: [PATCH 12/55] Update piholeDebug.sh I can spell, honest. --- 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 e2e59244..d003c1a4 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -338,7 +338,7 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { echo "::: Finshed debugging!" - echo "::: The degug log can be uploaded to Termbin.com for easier sharing." + echo "::: The debug 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]) From 3ed62d45f5285d162f39da453ac3e2f318fb82bf Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 16 Sep 2016 23:05:08 +0100 Subject: [PATCH 13/55] Source IP addresses from /etc/pihole/setupVars.conf --- gravity.sh | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/gravity.sh b/gravity.sh index 0b1622e0..acf7c76f 100755 --- a/gravity.sh +++ b/gravity.sh @@ -39,44 +39,26 @@ function helpFunc() exit 1 } -piholeIPfile=/etc/pihole/piholeIP -piholeIPv6file=/etc/pihole/.useIPv6 adListFile=/etc/pihole/adlists.list adListDefault=/etc/pihole/adlists.default 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 - 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 - -if [[ -f ${piholeIPv6file} ]];then - # If the file exists, then the user previously chose to use IPv6 in the automated installer - piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') -fi +#Source the setupVars from install script for the IP +. /etc/pihole/setupVars.conf +#Remove the /* from the end of the IPv4addr. +IPv4addr=${IPv4addr%/*} # 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 justDomainsExtension=domains -matterandlight=${basename}.0.matterandlight.txt +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 # After setting defaults, check if there's local overrides if [[ -r ${piholeDir}/pihole.conf ]];then @@ -213,10 +195,10 @@ 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} + truncate -s 0 ${piholeDir}/${matterAndLight} for i in "${activeDomains[@]}" do - cat "$i" | tr -d '\r' >> ${piholeDir}/${matterandlight} + cat "$i" | tr -d '\r' >> ${piholeDir}/${matterAndLight} done echo " done!" } @@ -268,13 +250,13 @@ function gravity_hostFormat() { # 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 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$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > ${piholeDir}/${accretionDisc} - cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} + echo -e "$IPv4addr $hostname\n$piholeIPv6 $hostname\n$IPv4addr pi.hole\n$piholeIPv6 pi.hole" > ${piholeDir}/${accretionDisc} + cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -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} + echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc} + cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc} fi # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it @@ -301,7 +283,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} + 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}) @@ -349,14 +331,13 @@ do esac done -#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list - if [[ ${forceGrav} == true ]]; then echo -n "::: Deleting exising list cache..." ${SUDO} rm /etc/pihole/list.* echo " done!" fi +#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list ${SUDO} cp /etc/.pihole/adlists.default /etc/pihole/adlists.default gravity_collapse gravity_spinup From f16574085f98b74ac0a1a04e1773a067cfee2010 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 16 Sep 2016 23:09:14 +0100 Subject: [PATCH 14/55] remove code made redundant by the existence of /etc/pihole/setupVars.conf --- automated install/basic-install.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 97171c31..3c86dd5a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -195,7 +195,6 @@ chooseInterface() { do piholeInterface=${desiredInterface} echo "::: Using interface: $piholeInterface" - echo "${piholeInterface}" > /tmp/piholeINT done else echo "::: Cancel selected, exiting...." @@ -204,13 +203,6 @@ 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 cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" ${r} ${c} 2) @@ -249,7 +241,7 @@ use4andor6() { echo "::: Exiting" exit 1 fi - cleanupIPv6 + else echo "::: Cancel selected. Exiting..." exit 1 @@ -260,8 +252,6 @@ 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} - - ${SUDO} touch /etc/pihole/.useIPv6 } getStaticIPv4Settings() { @@ -273,8 +263,6 @@ 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 - ${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. @@ -294,10 +282,6 @@ It is also possible to use a DHCP reservation, but if you are going to do that, 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. piholeIP is saved to a permanent file so gravity.sh can use it when updating - $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 3d5140458bde33fff9d9b89ffd94ccedf2cb51b1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 19 Sep 2016 20:43:04 +0100 Subject: [PATCH 15/55] Change cron job --- advanced/pihole.cron | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index d4ec56a7..2d06fbbc 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -13,9 +13,8 @@ # Download any updates from the adlists 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/pihole updateDashboard +# Pi-hole: Update Pi-hole! Uncomment to enable auto update +#30 2 * * 7 root /usr/local/bin/pihole updatePihole # 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 From a3edd0b976494e03d403f71ee4cbbf1dd3021404 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 19 Sep 2016 21:06:28 +0100 Subject: [PATCH 16/55] Change reset_on_push to false So we don't have to reapprove every time the branch is updated. --- .pullapprove.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pullapprove.yml b/.pullapprove.yml index ae786ecf..f868b48d 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -1,7 +1,7 @@ approve_by_comment: true approve_regex: '^(Approved|:shipit:|:\+1:)' reject_regex: '^(Rejected|:-1:)' -reset_on_push: true +reset_on_push: false author_approval: required reviewers: members: From 655c422c3c4bafe0876b96d05f4b4eeb90ee9d27 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 19 Sep 2016 22:17:58 +0100 Subject: [PATCH 17/55] Add additional instruction. Include "(Press space to select)" on ChooseInterface --- 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 a19b465a..0e1c8046 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -188,7 +188,7 @@ chooseInterface() { # 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}) + chooseInterfaceCmd=(whiptail --separate-output --radiolist "Choose An Interface (press space to select)" ${r} ${c} ${interfaceCount}) chooseInterfaceOptions=$("${chooseInterfaceCmd[@]}" "${interfacesArray[@]}" 2>&1 >/dev/tty) if [[ $? = 0 ]]; then for desiredInterface in ${chooseInterfaceOptions} From d9077310278a31766cdcff744b30a4fd388fc0b4 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 20 Sep 2016 15:10:34 -0500 Subject: [PATCH 18/55] new template based on udemy-dl --- .github/ISSUE_TEMPLATE.md | 41 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 04303614..473d1828 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,42 @@ -##### Expected Behaviour: +_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ +**In raising this issue, I confirm the following (please check boxes, eg [X]):** -##### Actual Behaviour: +- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). +- [ ] I have verified that the issue I am reporting can be replicated, or that the [feature](https://pi-hole.net/feature-requests/) I am suggesting [isn't already acknowledged](https://github.com/pi-hole/pi-hole/wiki). +- [ ] I have checked that the issue I'm reporting isn't already solved and no duplicates exist in [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20) and in [opened issues](https://github.com/pi-hole/pi-hole/issues) +- [ ] I have checked the [pull requests tab](https://github.com/pi-hole/pi-hole/pulls) for existing solutions/implementations to my issue/suggestion. +- [ ] I have prefixed my issue title with one of the following: _[BUG], [ISSUE], [FEATURE REQUEST], [QUESTION], [OTHER]_. +**My familiarity with the project is as follows (check one, eg [X]):** -##### Steps to reproduce this issue: +- [ ] I have never used the project. +- [ ] I have used the project briefly. +- [ ] I have used the project extensively, but have not contributed previously. +- [ ] I am an active contributor to the project. + +--- +**(Optional) Debug Log generated by `pihole -d`:** + +`http://termbin.com/` + +**[BUG | ISSUE] Expected Behaviour:** + +_{replace this section with your content or delete if not a BUG/ISSUE}_ + +**[BUG | ISSUE] Actual Behaviour:** + +_{replace this section with your content or delete if not a BUG/ISSUE}_ + +**[BUG | ISSUE] Steps to reproduce:** + +_{replace this section with your content or delete if not a BUG/ISSUE}_ + +- +- +- +- + +**[FEATURE REQUEST | QUESTION | OTHER]:** + +_{replace this line with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_ From fcb7d9111eeffb7b663a4cbaf100a0eda3fa5af3 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 20 Sep 2016 15:14:15 -0500 Subject: [PATCH 19/55] new template based on udemy-dl --- .github/PULL_REQUEST_TEMPLATE.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b289a1c0..af052392 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,19 @@ -Fixes #[issue number] . +_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ -Changes proposed in this pull request: +**By submitting this pull request, I confirm the following (please check boxes, eg [X]):** -- +- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). +- [ ] I have checked that [another pull request](https://github.com/pi-hole/pi-hole/pulls) for this purpose does not exist. +- [ ] I have considered, and confirmed that this submission will be valuable to others. +- [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. +- [ ] I give this submission freely, and claim no ownership to its content. -- +**My familiarity with the project is as follows (check one, eg [X]):** -- +- [ ] I have never used the project. +- [ ] I have used the project briefly. +- [ ] I have used the project extensively, but have not contributed previously. +- [ ] I am an active contributor to the project. -@pi-hole/gravity +--- +_{replace this line with your pull request content}_ From e6a37588996a0d22f81fc8a87fe726c09a5de082 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 20 Sep 2016 15:29:20 -0500 Subject: [PATCH 20/55] new template based on udemy-dl --- CONTRIBUTING.md | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1313f599..539f55d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,37 @@ -This is a basic checklist for now, We will update it in the future. +_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ -* 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.. +# Contributors Guide + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature. +- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that. +- Please be considerate towards the developers and other users when raising issues or presenting pull requests. +- Respect our decision(s), and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many people, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project. + +## Procedure + +**Before filing an issue:** + +- Attempt to replicate and **document** the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +**Before submitting a pull request:** + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Technical Requirements + +- 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!) +- Commit Unix line endings. +- (Optional fun) keep to the theme of Star Trek/black holes/gravity. From 4a0d5138a11c42d0c4fc21a784b1602994302b3b Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 20 Sep 2016 15:30:27 -0500 Subject: [PATCH 21/55] move CONTRIBUTING.MD to .github --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md From 34806ee2c22947a3f3d75c6e6db59ece9ec28136 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Wed, 21 Sep 2016 08:39:32 -0500 Subject: [PATCH 22/55] 1-10 codebase familiarity Also tried to simplify the language a bit so as not to deter people from submitting issues. We may need to simplify it more --- .github/ISSUE_TEMPLATE.md | 20 +++++++++++++------- .github/PULL_REQUEST_TEMPLATE.md | 16 +++++++++++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 473d1828..2cda41c2 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,17 +3,23 @@ _This template was created based on the work of [`udemy-dl`](https://github.com/ **In raising this issue, I confirm the following (please check boxes, eg [X]):** - [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). -- [ ] I have verified that the issue I am reporting can be replicated, or that the [feature](https://pi-hole.net/feature-requests/) I am suggesting [isn't already acknowledged](https://github.com/pi-hole/pi-hole/wiki). -- [ ] I have checked that the issue I'm reporting isn't already solved and no duplicates exist in [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20) and in [opened issues](https://github.com/pi-hole/pi-hole/issues) +- [ ] I have verified that the issue I am reporting can be replicated +- [ ] I have checked that the issue I'm reporting isn't a duplicate in our [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), or [open issues](https://github.com/pi-hole/pi-hole/issues). - [ ] I have checked the [pull requests tab](https://github.com/pi-hole/pi-hole/pulls) for existing solutions/implementations to my issue/suggestion. - [ ] I have prefixed my issue title with one of the following: _[BUG], [ISSUE], [FEATURE REQUEST], [QUESTION], [OTHER]_. -**My familiarity with the project is as follows (check one, eg [X]):** +**How familiar are you with the codebase?:** -- [ ] I have never used the project. -- [ ] I have used the project briefly. -- [ ] I have used the project extensively, but have not contributed previously. -- [ ] I am an active contributor to the project. +- [ ] 1 (very unfamiliar) +- [ ] 2 +- [ ] 3 +- [ ] 4 +- [ ] 5 +- [ ] 6 +- [ ] 7 +- [ ] 8 +- [ ] 9 +- [ ] 10 (very familiar) --- **(Optional) Debug Log generated by `pihole -d`:** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index af052392..3eb26862 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,12 +8,18 @@ _This template was created based on the work of [`udemy-dl`](https://github.com/ - [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [ ] I give this submission freely, and claim no ownership to its content. -**My familiarity with the project is as follows (check one, eg [X]):** +**How familiar are you with the codebase?:** -- [ ] I have never used the project. -- [ ] I have used the project briefly. -- [ ] I have used the project extensively, but have not contributed previously. -- [ ] I am an active contributor to the project. +- [ ] 1 (very unfamiliar) +- [ ] 2 +- [ ] 3 +- [ ] 4 +- [ ] 5 +- [ ] 6 +- [ ] 7 +- [ ] 8 +- [ ] 9 +- [ ] 10 (very familiar) --- _{replace this line with your pull request content}_ From 521374e2381b23639081ddcfa44c91d6874ff14d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 21 Sep 2016 16:53:50 -0700 Subject: [PATCH 23/55] Update .pullapprove.yml --- .pullapprove.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pullapprove.yml b/.pullapprove.yml index ae786ecf..6730954e 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -1,6 +1,6 @@ approve_by_comment: true -approve_regex: '^(Approved|:shipit:|:\+1:)' -reject_regex: '^(Rejected|:-1:)' +approve_regex: '^(Approved|:shipit:|:\+1:|Engage)' +reject_regex: '^(Rejected|:-1:|Borg)' reset_on_push: true author_approval: required reviewers: From ac49e639bdc1e4e046a06864514200969992fdf0 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 26 Sep 2016 11:58:07 +0100 Subject: [PATCH 24/55] Fix #718 --- gravity.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ca2ef57d..05354c43 100755 --- a/gravity.sh +++ b/gravity.sh @@ -289,7 +289,10 @@ 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} + #awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} + #Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment') + #Add additional awk command to read all lines up to a '#', and then continue as we were + cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova} echo " done!" numberOf=$(wc -l < ${piholeDir}/${supernova}) From 60c0e59a83f7d878535fbdce2a0d9bfac8c2ac9f Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 18:06:31 -0700 Subject: [PATCH 25/55] Add IPv6 intelligence to debug --- advanced/Scripts/piholeDebug.sh | 85 ++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index d003c1a4..b63244c4 100755 --- 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 -# Generates pihole_debug.log in /var/log/ to be used for troubleshooting. +# Generates pihole_debug.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 @@ -25,18 +25,27 @@ ADLISTSFILE="/etc/pihole/adlists.list" PIHOLELOG="/var/log/pihole.log" WHITELISTMATCHES="/tmp/whitelistmatches.list" +# Header info and introduction +echo "::: Beginning Pi-hole debug at $(date)!" +echo "::: This debugging process will collect information from your running configuration," +echo "::: and optionally upload the generated log to a unique and random directory on" +echo "::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only" +echo "::: person who is given the unique URL. Please consider where you post this link." +echo "::: " + ######## FIRST CHECK ######## # Must be root to debug if [[ $EUID -eq 0 ]]; then - echo "::: You are root... Beginning debug!" + echo "::: Script is executing as root user..." else - echo "::: Sudo will be used for debugging." + echo "::: Non-root user detected..." # Check if sudo is actually installed if [ -x "$(command -v sudo)" ]; then export SUDO="sudo" + echo "::: sudo command located, debug will run under sudo." else - echo "::: Please install sudo or run this as root." + echo "::: Unable to locate sudo command. Please install sudo or run this as root." exit 1 fi fi @@ -52,27 +61,57 @@ fi ### Private functions exist here ### function versionCheck { - echo "#######################################" >> ${DEBUG_LOG} - echo "########## Versions Section ###########" >> ${DEBUG_LOG} - echo "#######################################" >> ${DEBUG_LOG} - + echo "############################################################" >> ${DEBUG_LOG} + echo "########## Installed Versions ##########" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + echo "::: Detecting Pi-hole installed versions." TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) echo "Pi-hole Version: $TMP" >> ${DEBUG_LOG} - + + echo "::: Writing Pi-hole installed version to logfile." TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0) echo "WebUI Version: $TMP" >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} } function distroCheck { - echo "#######################################" >> ${DEBUG_LOG} - echo "######## Distribution Section #########" >> ${DEBUG_LOG} - echo "#######################################" >> ${DEBUG_LOG} - + echo "############################################################" >> ${DEBUG_LOG} + echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + echo "::: Checking installed OS Distribution release." TMP=$(cat /etc/*release || echo "Failed to find release") - echo "Distribution Version: $TMP" >> ${DEBUG_LOG} + + echo "::: Writing OS Distribution release to logfile." + echo "$TMP" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} +} + +function ipCheck { + echo "############################################################" >> ${DEBUG_LOG} + echo "######## IP Address Information #########" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + IPADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }') + echo "::: Writing local IPs to debug log" + echo "$IPADDR" >> ${DEBUG_LOG} + IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }') + echo "$IP6ADDR" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} + + echo "::: Locating default gateway and checking connectivity" + GATEWAY=$(ip r | grep default | cut -d ' ' -f 3) + GATEWAY_CHECK=$(ping -q -w 1 -c 1 "${GATEWAY}" > /dev/null && echo ok || echo error) + echo "Gateway check at ${GATEWAY}:" >> ${DEBUG_LOG} + echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} + + GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3) + GATEWAY6_CHECK=$(ping6 -q -w 1 -c 1 "${GATEWAY6}" > /dev/null && echo ok || echo error) + echo "IPv6 Gateway check at ${GATEWAY6}:" >> ${DEBUG_LOG} + echo "$GATEWAY6_CHECK" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} } - function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then ${SUDO} touch ${WHITELISTMATCHES} @@ -186,22 +225,10 @@ function debugLighttpd { ### END FUNCTIONS ### -### Check Pi internet connections ### -# Log the IP addresses of this Pi -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} -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} versionCheck distroCheck +ipCheck compareWhitelist compareBlacklist testNslookup @@ -319,7 +346,7 @@ fi # Continuously append the pihole.log file to the pihole_debug.log file function dumpPiHoleLog { 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 -e "::: Writing current pi-hole 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} From 7729ddab3081a1074109009d2dd32573974699c6 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 18:21:58 -0700 Subject: [PATCH 26/55] Mode code realignment. Handle lack of IPv6 gateway gracefully. --- advanced/Scripts/piholeDebug.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index b63244c4..cccf45d6 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -93,8 +93,8 @@ function ipCheck { echo "######## IP Address Information #########" >> ${DEBUG_LOG} echo "############################################################" >> ${DEBUG_LOG} + echo "::: Writing local IPs to logfile" IPADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }') - echo "::: Writing local IPs to debug log" echo "$IPADDR" >> ${DEBUG_LOG} IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }') echo "$IP6ADDR" >> ${DEBUG_LOG} @@ -107,9 +107,12 @@ function ipCheck { echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3) + if [ -n "$GATEWAY6" ] + then GATEWAY6_CHECK=$(ping6 -q -w 1 -c 1 "${GATEWAY6}" > /dev/null && echo ok || echo error) echo "IPv6 Gateway check at ${GATEWAY6}:" >> ${DEBUG_LOG} echo "$GATEWAY6_CHECK" >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} } function compareWhitelist { From c41d543d811c0a684c45a62b323e6165185cbc4b Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 18:27:02 -0700 Subject: [PATCH 27/55] Handle lack of IPv6 gracefully. --- advanced/Scripts/piholeDebug.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index cccf45d6..f38947b9 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -96,8 +96,12 @@ function ipCheck { echo "::: Writing local IPs to logfile" IPADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }') echo "$IPADDR" >> ${DEBUG_LOG} + IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }') + if [ -n "$IP6ADDR" ] + then echo "$IP6ADDR" >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} echo "::: Locating default gateway and checking connectivity" From 274b71f8bc3ccc1b359a889a3d2526951a0fe6c0 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 18:52:12 -0700 Subject: [PATCH 28/55] Relocate hostname checks --- advanced/Scripts/piholeDebug.sh | 37 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index f38947b9..05f3cff8 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -119,6 +119,26 @@ function ipCheck { fi echo >> ${DEBUG_LOG} } + +function hostnameCheck { + # 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 "#######################################" >> ${DEBUG_LOG} + echo "################ Hosts ################" >> ${DEBUG_LOG} + echo "#######################################" >> ${DEBUG_LOG} + if [ -e "$HOSTSFILE" ] + then + cat "$HOSTSFILE" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} + else + echo "No hosts file found!" >> ${DEBUG_LOG} + printf ":::\tNo hosts file found!\n" + fi +} + function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then ${SUDO} touch ${WHITELISTMATCHES} @@ -236,6 +256,7 @@ function debugLighttpd { versionCheck distroCheck ipCheck +hostnameCheck compareWhitelist compareBlacklist testNslookup @@ -292,22 +313,6 @@ else 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 "#######################################" >> ${DEBUG_LOG} -echo "################ Hosts ################" >> ${DEBUG_LOG} -echo "#######################################" >> ${DEBUG_LOG} -if [ -e "$HOSTSFILE" ] -then - cat "$HOSTSFILE" >> ${DEBUG_LOG} - echo >> ${DEBUG_LOG} -else - echo "No hosts file found!" >> ${DEBUG_LOG} - printf ":::\tNo hosts file found!\n" -fi ### PiHole application specific logging ### echo "::: Writing whitelist to debug log..." From 874853fe1846e429c6caf5da44cb4d1fc1fddc89 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 19:23:30 -0700 Subject: [PATCH 29/55] Add lighttpd to version check --- advanced/Scripts/piholeDebug.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 05f3cff8..acdb699a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -72,6 +72,15 @@ function versionCheck { echo "::: Writing Pi-hole installed version to logfile." TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0) echo "WebUI Version: $TMP" >> ${DEBUG_LOG} + + echo "::: Writing lighttpd version to logfile." + light_ver=$(lighttpd -v | head -n1) + if [ -n light_ver ] + then + echo "${light_ver}" >> ${DEBUG_LOG} + else + echo "lighttpd not installed." >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} } @@ -121,14 +130,17 @@ function ipCheck { } function hostnameCheck { + echo "############################################################" >> ${DEBUG_LOG} + echo "######## Hostname Information #########" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + echo "::: Writing locally configured hostnames to logfile" # 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 "This Pi-hole is: $(hostname)" >> ${DEBUG_LOG} echo "::: Writing hosts file to debug log..." - echo "#######################################" >> ${DEBUG_LOG} - echo "################ Hosts ################" >> ${DEBUG_LOG} - echo "#######################################" >> ${DEBUG_LOG} + echo "### Hosts ###" >> ${DEBUG_LOG} + if [ -e "$HOSTSFILE" ] then cat "$HOSTSFILE" >> ${DEBUG_LOG} From 014bdf911a11b0e40c79808cc694fa2d88ec4eb5 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 20:39:39 -0700 Subject: [PATCH 30/55] Add open port detection --- advanced/Scripts/piholeDebug.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index acdb699a..7e08b24e 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -81,6 +81,15 @@ function versionCheck { else echo "lighttpd not installed." >> ${DEBUG_LOG} fi + + echo "::: Writing PHP version to logfile." + php_ver=$(php -v | head -n1) + if [ -n php_ver ] + then + echo "${php_ver}" >> ${DEBUG_LOG} + else + echo "PHP not installed." >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} } @@ -151,6 +160,17 @@ function hostnameCheck { fi } +function portCheck { + echo "############################################################" >> ${DEBUG_LOG} + echo "######## Open Port Information #########" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + echo "::: Writing local server ports to logfile" + + ${SUDO} netstat -tulpn >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} +} + function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then ${SUDO} touch ${WHITELISTMATCHES} @@ -269,6 +289,7 @@ versionCheck distroCheck ipCheck hostnameCheck +portCheck compareWhitelist compareBlacklist testNslookup From 5bbb3ac49acd97bf50943638a03c70a98d2e2ff7 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 20:50:03 -0700 Subject: [PATCH 31/55] Standardize Pi-hole naming. --- advanced/Scripts/piholeDebug.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 7e08b24e..6ea16fdd 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -226,7 +226,7 @@ function testNslookup { done < "$GRAVITYFILE" fi - echo "NSLOOKUP of $TESTURL from PiHole:" >> ${DEBUG_LOG} + echo "NSLOOKUP of $TESTURL from Pi-hole:" >> ${DEBUG_LOG} nslookup "$TESTURL" >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG} @@ -347,7 +347,7 @@ else fi -### PiHole application specific logging ### +### Pi-hole application specific logging ### echo "::: Writing whitelist to debug log..." echo "#######################################" >> ${DEBUG_LOG} echo "############## Whitelist ##############" >> ${DEBUG_LOG} @@ -391,7 +391,7 @@ fi # Continuously append the pihole.log file to the pihole_debug.log file function dumpPiHoleLog { trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT - echo -e "::: Writing current pi-hole 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 -e "::: Writing current Pi-hole 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} @@ -402,8 +402,8 @@ function dumpPiHoleLog { echo >> ${DEBUG_LOG} done else - echo "No pihole.log file found!" >> ${DEBUG_LOG} - printf ":::\tNo pihole.log file found!\n" + echo "No Pi-hole.log file found!" >> ${DEBUG_LOG} + printf ":::\tNo Pi-hole.log file found!\n" fi } From ac1c299369c0d299423ad91df0d25f3fd1c93c99 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 26 Sep 2016 20:54:05 -0700 Subject: [PATCH 32/55] Revert overzealous renaming of Pi-hole in pihole.log detection. --- 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 6ea16fdd..9a060572 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -402,8 +402,8 @@ function dumpPiHoleLog { echo >> ${DEBUG_LOG} done else - echo "No Pi-hole.log file found!" >> ${DEBUG_LOG} - printf ":::\tNo Pi-hole.log file found!\n" + echo "No pihole.log file found!" >> ${DEBUG_LOG} + printf ":::\tNo pihole.log file found!\n" fi } From daa5366b5757367086640a4c7afe36ae42831115 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 27 Sep 2016 11:11:47 +0100 Subject: [PATCH 33/55] Check if php5 is available in apt-cache, if so install it, else just install php --- automated install/basic-install.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 100522cc..1fdbe096 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -59,7 +59,14 @@ fi # Compatibility if [ -x "$(command -v apt-get)" ];then - # Debian Family + #Debian Family + #Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS) + phpVer="php" + apt-cache show php5 &> /dev/null + if [ $? == 0 ]; then + phpVer="php5" + fi + ############################################# PKG_MANAGER="apt-get" PKG_CACHE="/var/cache/apt" UPDATE_PKG_CACHE="$PKG_MANAGER -qq update" @@ -67,7 +74,7 @@ if [ -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 netcat cron ) + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer} git curl unzip wget sudo netcat cron ) LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" From 3fc3c5cae4a8e364fb09a7d8e97582518469dbfa Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 27 Sep 2016 11:15:46 +0100 Subject: [PATCH 34/55] Add iproute2 to fix #653 --- 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 1fdbe096..dc07ac47 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -74,7 +74,7 @@ if [ -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 ${phpVer}-common ${phpVer}-cgi ${phpVer} git curl unzip wget sudo netcat cron ) + PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer} git curl unzip wget sudo netcat cron iproute2 ) LIGHTTPD_USER="www-data" LIGHTTPD_GROUP="www-data" LIGHTTPD_CFG="lighttpd.conf.debian" From 6f6450bcff058231d61e962a6b89bb37b7760e18 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Tue, 27 Sep 2016 08:23:52 -0500 Subject: [PATCH 35/55] simplify a bit more Removed a few checkboxes. I really don't want to deter people from submitting issue because of a wall of text, but some of this information we really can use to be more helpful. --- .github/ISSUE_TEMPLATE.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 2cda41c2..fc2d528e 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -3,10 +3,8 @@ _This template was created based on the work of [`udemy-dl`](https://github.com/ **In raising this issue, I confirm the following (please check boxes, eg [X]):** - [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). -- [ ] I have verified that the issue I am reporting can be replicated -- [ ] I have checked that the issue I'm reporting isn't a duplicate in our [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), or [open issues](https://github.com/pi-hole/pi-hole/issues). -- [ ] I have checked the [pull requests tab](https://github.com/pi-hole/pi-hole/pulls) for existing solutions/implementations to my issue/suggestion. -- [ ] I have prefixed my issue title with one of the following: _[BUG], [ISSUE], [FEATURE REQUEST], [QUESTION], [OTHER]_. +- [ ] The issue I am reporting can be *replicated* +- [ ] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)). **How familiar are you with the codebase?:** @@ -22,27 +20,23 @@ _This template was created based on the work of [`udemy-dl`](https://github.com/ - [ ] 10 (very familiar) --- -**(Optional) Debug Log generated by `pihole -d`:** +**[FEATURE REQUEST | QUESTION | OTHER]:** -`http://termbin.com/` +_{replace this section with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_ **[BUG | ISSUE] Expected Behaviour:** -_{replace this section with your content or delete if not a BUG/ISSUE}_ **[BUG | ISSUE] Actual Behaviour:** -_{replace this section with your content or delete if not a BUG/ISSUE}_ **[BUG | ISSUE] Steps to reproduce:** -_{replace this section with your content or delete if not a BUG/ISSUE}_ - - - - - -**[FEATURE REQUEST | QUESTION | OTHER]:** +**(Optional) Debug Log generated by `pihole -d`:** -_{replace this line with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_ +`http://termbin.com/` From 3df9c48012b570b186b66a91885adf45a956309c Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 27 Sep 2016 19:30:37 -0700 Subject: [PATCH 36/55] Include ping statistics in default gateway checks. --- advanced/Scripts/piholeDebug.sh | 35 ++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 9a060572..ebeee470 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -10,6 +10,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +set -o pipefail ######## GLOBAL VARS ######## DEBUG_LOG="/var/log/pihole_debug.log" @@ -116,25 +117,45 @@ function ipCheck { echo "$IPADDR" >> ${DEBUG_LOG} IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }') - if [ -n "$IP6ADDR" ] + if [[ $? = 0 ]] then echo "$IP6ADDR" >> ${DEBUG_LOG} + else + echo "No IPv6 addresses found." >> ${DEBUG_LOG} fi echo >> ${DEBUG_LOG} echo "::: Locating default gateway and checking connectivity" GATEWAY=$(ip r | grep default | cut -d ' ' -f 3) - GATEWAY_CHECK=$(ping -q -w 1 -c 1 "${GATEWAY}" > /dev/null && echo ok || echo error) - echo "Gateway check at ${GATEWAY}:" >> ${DEBUG_LOG} + if [[ $? = 0 ]] + then + echo "::: Pinging default IPv4 gateway..." + GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3) + if [[ $? = 0 ]] + then + echo "IPv4 Gateway check:" >> ${DEBUG_LOG} + else + echo "IPv4 Gateway check failed:" >> ${DEBUG_LOG} + fi echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} + fi GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3) - if [ -n "$GATEWAY6" ] + if [[ $? = 0 ]] then - GATEWAY6_CHECK=$(ping6 -q -w 1 -c 1 "${GATEWAY6}" > /dev/null && echo ok || echo error) - echo "IPv6 Gateway check at ${GATEWAY6}:" >> ${DEBUG_LOG} - echo "$GATEWAY6_CHECK" >> ${DEBUG_LOG} + echo "::: Pinging default IPv4 gateway..." + GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}" | tail -n3) + if [[ $? = 0 ]] + then + echo "IPv6 Gateway check:" >> ${DEBUG_LOG} + else + echo "IPv6 Gateway check failed:" >> ${DEBUG_LOG} + fi + else + GATEWAY_CHECK="No IPv6 Gateway Detected" fi + echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} } From dba1ab3fc0cf0d36003ba60dc9102b325555c89e Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 27 Sep 2016 19:31:21 -0700 Subject: [PATCH 37/55] Remove compareWhitelist --- advanced/Scripts/piholeDebug.sh | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index ebeee470..322de330 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -192,28 +192,6 @@ function portCheck { echo >> ${DEBUG_LOG} } -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 - TMP=$(grep -w ".* $line$" "$GRAVITYFILE") - if [ ! -z "$TMP" ]; then - echo "$TMP" >> ${DEBUG_LOG} - echo "$TMP" >> ${WHITELISTMATCHES} - fi - done < "$WHITELISTFILE" - echo >> ${DEBUG_LOG} -} - function compareBlacklist { echo "#######################################" >> ${DEBUG_LOG} echo "######## Blacklist Comparison #########" >> ${DEBUG_LOG} @@ -311,7 +289,6 @@ distroCheck ipCheck hostnameCheck portCheck -compareWhitelist compareBlacklist testNslookup checkProcesses From edd7f28104ab572d955e55b27518da865089939b Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 27 Sep 2016 19:39:28 -0700 Subject: [PATCH 38/55] Add internet checks to IP section --- advanced/Scripts/piholeDebug.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 322de330..5b704f21 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -138,12 +138,24 @@ function ipCheck { echo "IPv4 Gateway check failed:" >> ${DEBUG_LOG} fi echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} + + echo "::: Pinging Internet via IPv4..." + INET_CHECK=$(ping -q -w 5 -c 3 -n 8.8.8.8 | tail -n3) + if [[ $? = 0 ]] + then + echo "IPv4 Internet check:" >> ${DEBUG_LOG} + else + echo "IPv4 Internet check failed:" >> ${DEBUG_LOG} + fi + echo "$INET_CHECK" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} fi GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3) if [[ $? = 0 ]] then - echo "::: Pinging default IPv4 gateway..." + echo "::: Pinging default IPv6 gateway..." GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}" | tail -n3) if [[ $? = 0 ]] then @@ -151,11 +163,22 @@ function ipCheck { else echo "IPv6 Gateway check failed:" >> ${DEBUG_LOG} fi + + echo "::: Pinging Internet via IPv6..." + GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n 2001:4860:4860::8888 | tail -n3) + if [[ $? = 0 ]] + then + echo "IPv6 Internet check:" >> ${DEBUG_LOG} + else + echo "IPv6 Internet check failed:" >> ${DEBUG_LOG} + fi + else GATEWAY_CHECK="No IPv6 Gateway Detected" fi echo "$GATEWAY_CHECK" >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} } From 36e10595cc9d94799dbbf0ded660c7fec9547691 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 09:51:14 -0700 Subject: [PATCH 39/55] Change netstat to lsof. --- advanced/Scripts/piholeDebug.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 5b704f21..67d2815e 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -209,9 +209,10 @@ function portCheck { echo "######## Open Port Information #########" >> ${DEBUG_LOG} echo "############################################################" >> ${DEBUG_LOG} - echo "::: Writing local server ports to logfile" + echo "::: Detecting local server port 80 and 53 processes." - ${SUDO} netstat -tulpn >> ${DEBUG_LOG} + ${SUDO} lsof -i :80 >> ${DEBUG_LOG} + ${SUDO} lsof -i :53 >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} } From 5de179f1eb2fa84d994d1fb990467ce28cc11ef7 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 09:52:11 -0700 Subject: [PATCH 40/55] Remove blacklist comparison. --- advanced/Scripts/piholeDebug.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 67d2815e..488ed4a1 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -216,18 +216,6 @@ function portCheck { echo >> ${DEBUG_LOG} } -function compareBlacklist { - echo "#######################################" >> ${DEBUG_LOG} - echo "######## Blacklist Comparison #########" >> ${DEBUG_LOG} - echo "#######################################" >> ${DEBUG_LOG} - while read -r line; do - if [ ! -z "$line" ]; then - grep -w ".* $line$" "$GRAVITYFILE" >> ${DEBUG_LOG} - fi - done < "$BLACKLISTFILE" - echo >> ${DEBUG_LOG} -} - function testNslookup { TESTURL="doubleclick.com" echo "#######################################" >> ${DEBUG_LOG} @@ -313,7 +301,6 @@ distroCheck ipCheck hostnameCheck portCheck -compareBlacklist testNslookup checkProcesses debugLighttpd From 8466d0b6818927d394f4edef9174178ff1e25b09 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 10:14:47 -0700 Subject: [PATCH 41/55] Change NSLOOKUP to dig for resolver tests, add dnsmasq specific records check --- advanced/Scripts/piholeDebug.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 488ed4a1..a4eec46d 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -216,12 +216,14 @@ function portCheck { echo >> ${DEBUG_LOG} } -function testNslookup { - TESTURL="doubleclick.com" - echo "#######################################" >> ${DEBUG_LOG} - echo "############ NSLookup Test ############" >> ${DEBUG_LOG} - echo "#######################################" >> ${DEBUG_LOG} +function testResolver { + echo "############################################################" >> ${DEBUG_LOG} + echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} + + # Find a blocked url that has not been whitelisted. + TESTURL="doubleclick.com" if [ -s "$WHITELISTMATCHES" ]; then while read -r line; do CUTURL=${line#*" "} @@ -237,12 +239,19 @@ function testNslookup { done < "$GRAVITYFILE" fi - echo "NSLOOKUP of $TESTURL from Pi-hole:" >> ${DEBUG_LOG} - nslookup "$TESTURL" >> ${DEBUG_LOG} + echo "Resolution of $TESTURL from Pi-hole:" >> ${DEBUG_LOG} + dig "$TESTURL" @127.0.0.1>> ${DEBUG_LOG} echo >> ${DEBUG_LOG} - echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG} - nslookup "$TESTURL" 8.8.8.8 >> ${DEBUG_LOG} + echo "Resolution of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG} + dig "$TESTURL" @8.8.8.8 >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} + + echo "Pi-hole dnsmasq specific records lookups" >> ${DEBUG_LOG} + echo "Cache Size:" >> ${DEBUG_LOG} + dig +short chaos txt cachesize.bind >> ${DEBUG_LOG} + echo "Upstream Servers:" >> ${DEBUG_LOG} + dig +short chaos txt servers.bind >> ${DEBUG_LOG} + echo >> ${DEBUG_LOG} } function checkProcesses { @@ -259,6 +268,7 @@ function checkProcesses { echo " processes status:" >> ${DEBUG_LOG} ${SUDO} systemctl -l status "$i" >> "$DEBUG_LOG" done + echo >> ${DEBUG_LOG} } function debugLighttpd { @@ -301,8 +311,8 @@ distroCheck ipCheck hostnameCheck portCheck -testNslookup checkProcesses +testResolver debugLighttpd echo "::: Writing dnsmasq.conf to debug log..." From 5a3d319677422593aaf77282b32042d176e49573 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 10:24:44 -0700 Subject: [PATCH 42/55] Add fail check to dig local and remote. --- advanced/Scripts/piholeDebug.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index a4eec46d..faf1a295 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -240,15 +240,38 @@ function testResolver { fi echo "Resolution of $TESTURL from Pi-hole:" >> ${DEBUG_LOG} - dig "$TESTURL" @127.0.0.1>> ${DEBUG_LOG} + LOCALDIG=$(dig "$TESTURL" @127.0.0.1) + if [[ $? = 0 ]] + then + echo "$LOCALDIG" >> ${DEBUG_LOG} + else + echo "Failed to resolve $TESTURL on Pi-hole" >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} + + echo "Resolution of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG} - dig "$TESTURL" @8.8.8.8 >> ${DEBUG_LOG} + REMOTEDIG=$(dig "$TESTURL" @8.8.8.8) + if [[ $? = 0 ]] + then + echo "$REMOTEDIG" >> ${DEBUG_LOG} + else + echo "Failed to resolve $TESTURL on 8.8.8.8" >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} echo "Pi-hole dnsmasq specific records lookups" >> ${DEBUG_LOG} echo "Cache Size:" >> ${DEBUG_LOG} dig +short chaos txt cachesize.bind >> ${DEBUG_LOG} + echo "Insertions count:" >> ${DEBUG_LOG} + dig +short chaos txt insertions.bind >> ${DEBUG_LOG} + echo "Evictions count:" >> ${DEBUG_LOG} + dig +short chaos txt evictions.bind >> ${DEBUG_LOG} + echo "Misses count:" >> ${DEBUG_LOG} + dig +short chaos txt misses.bind >> ${DEBUG_LOG} + echo "Hits count:" >> ${DEBUG_LOG} + dig +short chaos txt hits.bind >> ${DEBUG_LOG} + echo "Auth count:" >> ${DEBUG_LOG} + dig +short chaos txt auth.bind >> ${DEBUG_LOG} echo "Upstream Servers:" >> ${DEBUG_LOG} dig +short chaos txt servers.bind >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} From 7fcb40739d0fea406d96107fcca084f6ed197350 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 10:25:37 -0700 Subject: [PATCH 43/55] Close IF statement --- advanced/Scripts/piholeDebug.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index faf1a295..0a02a1f7 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -257,6 +257,7 @@ function testResolver { echo "$REMOTEDIG" >> ${DEBUG_LOG} else echo "Failed to resolve $TESTURL on 8.8.8.8" >> ${DEBUG_LOG} + fi echo >> ${DEBUG_LOG} echo "Pi-hole dnsmasq specific records lookups" >> ${DEBUG_LOG} From a9c3e2c7ba4f5c3aedc611ea887273fa43b7ef08 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 28 Sep 2016 13:09:38 -0700 Subject: [PATCH 44/55] Add log_write function. Update version_check to use logical conditionals. --- advanced/Scripts/piholeDebug.sh | 76 +++++++++++++-------------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 0a02a1f7..718b6c74 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -37,7 +37,7 @@ echo "::: " ######## FIRST CHECK ######## # Must be root to debug -if [[ $EUID -eq 0 ]]; then +if [[ "$EUID" -eq 0 ]]; then echo "::: Script is executing as root user..." else echo "::: Non-root user detected..." @@ -61,40 +61,30 @@ else fi ### Private functions exist here ### -function versionCheck { - echo "############################################################" >> ${DEBUG_LOG} - echo "########## Installed Versions ##########" >> ${DEBUG_LOG} - echo "############################################################" >> ${DEBUG_LOG} - - echo "::: Detecting Pi-hole installed versions." - TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) - echo "Pi-hole Version: $TMP" >> ${DEBUG_LOG} - - echo "::: Writing Pi-hole installed version to logfile." - TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0) - echo "WebUI Version: $TMP" >> ${DEBUG_LOG} - - echo "::: Writing lighttpd version to logfile." - light_ver=$(lighttpd -v | head -n1) - if [ -n light_ver ] - then - echo "${light_ver}" >> ${DEBUG_LOG} - else - echo "lighttpd not installed." >> ${DEBUG_LOG} - fi - - echo "::: Writing PHP version to logfile." - php_ver=$(php -v | head -n1) - if [ -n php_ver ] - then - echo "${php_ver}" >> ${DEBUG_LOG} - else - echo "PHP not installed." >> ${DEBUG_LOG} - fi - echo >> ${DEBUG_LOG} +function log_write { + echo "$1" >> "${DEBUG_LOG}" } -function distroCheck { +function version_check { + log_write "############################################################" + log_write "########## Installed Versions ##########" + log_write "############################################################" + + echo "::: Detecting Pi-hole installed versions." + pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \ + && log_write "Pi-hole Version: $pi_hole_ver" || log_write "Pi-hole git repository not detected." + admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \ + && log_write "WebUI Version: $admin_ver" || log_write "Pi-hole Admin Pages git repository not detected." + + echo "::: Writing lighttpd version to logfile." + light_ver="$(lighttpd -v |& head -n1)" && log_write "${light_ver}" || log_write "lighttpd not installed." + + echo "::: Writing PHP version to logfile." + php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed." + +} + +function distro_check { echo "############################################################" >> ${DEBUG_LOG} echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG} echo "############################################################" >> ${DEBUG_LOG} @@ -107,22 +97,17 @@ function distroCheck { echo >> ${DEBUG_LOG} } -function ipCheck { +function ip_check { echo "############################################################" >> ${DEBUG_LOG} echo "######## IP Address Information #########" >> ${DEBUG_LOG} echo "############################################################" >> ${DEBUG_LOG} echo "::: Writing local IPs to logfile" - IPADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }') + IPADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')" echo "$IPADDR" >> ${DEBUG_LOG} - IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }') - if [[ $? = 0 ]] - then - echo "$IP6ADDR" >> ${DEBUG_LOG} - else - echo "No IPv6 addresses found." >> ${DEBUG_LOG} - fi + IP6ADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')" \ + && echo "$IP6ADDR" >> ${DEBUG_LOG} || echo "No IPv6 addresses found." >> ${DEBUG_LOG} echo >> ${DEBUG_LOG} echo "::: Locating default gateway and checking connectivity" @@ -329,10 +314,9 @@ function debugLighttpd { ### END FUNCTIONS ### - -versionCheck -distroCheck -ipCheck +version_check +distro_check +ip_check hostnameCheck portCheck checkProcesses From 6a8bef83b31e07ed04f4ef12fae435ddd2abf9fa Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 30 Sep 2016 22:40:43 +0100 Subject: [PATCH 45/55] Fix the php version check command (Thanks @diginc!) --- 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 dc07ac47..46abeb62 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -62,7 +62,7 @@ if [ -x "$(command -v apt-get)" ];then #Debian Family #Decide if php should be `php5` or just `php` (Fixes issues with Ubuntu 16.04 LTS) phpVer="php" - apt-cache show php5 &> /dev/null + ${SUDO} apt-get install --dry-run php5 > /dev/null 2>&1 if [ $? == 0 ]; then phpVer="php5" fi From 0d4402ee0cdc88b6d301220f235d62e62af1ae7e Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Fri, 30 Sep 2016 17:01:44 -0500 Subject: [PATCH 46/55] Update README.md Updating the old x86 only reference on the link to my docker project. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09de0d03..4c242d56 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - [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/) +- [Docker Pi-hole container (x86 and ARM)](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) From 1a83988e26dc5e931fb3059fc99216fc428409ec Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 1 Oct 2016 16:56:03 +0100 Subject: [PATCH 47/55] Add check at the beginning of update script to check for existence of local repos. If not, redirect user to run install command again. --- pihole | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pihole b/pihole index 00e4a7bf..e0d1715a 100755 --- a/pihole +++ b/pihole @@ -49,6 +49,18 @@ function flushFunc { function updatePiholeFunc { + + if [ ! -d "/etc/.pihole" ]; then #This is unlikely + echo "::: Critical Error: Pi-Hole repo missing from system!" + echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" + exit 1; + fi + if [ ! -d "/var/www/html/admin" ]; then #This is unlikely + echo "::: Critical Error: Pi-Hole repo missing from system!" + echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole" + exit 1; + fi + echo "::: Checking for updates..." piholeVersion=$(cd /etc/.pihole/ && 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/",$//') From 9a421d510a1cce8aef3a6b98991f467cc188e86a Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 1 Oct 2016 13:16:58 -0700 Subject: [PATCH 48/55] Ignore comments in adlists.list section. --- advanced/Scripts/piholeDebug.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 718b6c74..aadb083b 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -81,7 +81,6 @@ function version_check { echo "::: Writing PHP version to logfile." php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed." - } function distro_check { @@ -190,7 +189,7 @@ function hostnameCheck { } function portCheck { - echo "############################################################" >> ${DEBUG_LOG} + echo "############################################################" >> ${DEBUG_LOG} echo "######## Open Port Information #########" >> ${DEBUG_LOG} echo "############################################################" >> ${DEBUG_LOG} @@ -407,7 +406,12 @@ echo "############ adlists.list #############" >> ${DEBUG_LOG} echo "#######################################" >> ${DEBUG_LOG} if [ -e "$ADLISTSFILE" ] then - cat "$ADLISTSFILE" >> ${DEBUG_LOG} + while read -r line; do + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> ${DEBUG_LOG} + fi + done < "$ADLISTSFILE" echo >> ${DEBUG_LOG} else echo "No adlists.list file found... using adlists.default!" >> ${DEBUG_LOG} From 73c85ae68a931f777173b9d394f803c9a62104d2 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:30:55 +0100 Subject: [PATCH 49/55] remove duplicate calls to installConfigs --- automated install/basic-install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 46abeb62..c9c16e8a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -820,7 +820,6 @@ installPihole() { getGitFiles installScripts installConfigs - installConfigs CreateLogFile configureSelinux installPiholeWeb @@ -837,7 +836,6 @@ updatePihole() { getGitFiles installScripts installConfigs - installConfigs CreateLogFile configureSelinux installPiholeWeb From 7684069d0b7012190f6efea8af7d6552830682de Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:33:04 +0100 Subject: [PATCH 50/55] verifyFreeDiskSpace BEFORE installing any 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 c9c16e8a..7388dcd7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -926,13 +926,13 @@ if [[ -f ${setupVars} ]];then fi # Start the installer +# Verify there is enough disk space for the install +verifyFreeDiskSpace # Install packages used by this installation script installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - # Verify there is enough disk space for the install - verifyFreeDiskSpace ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world From 6c2ff950ee5ab0a353515b2ba363eabafbd7605b Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:33:59 +0100 Subject: [PATCH 51/55] remote duplicate ${SUDO} mkdir /etc/pihole --- 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 7388dcd7..5455de53 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -933,7 +933,6 @@ installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world findIPRoute From 4e262d81f04374c7cba1d017757b02a157ac46de Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 10:39:09 +0100 Subject: [PATCH 52/55] wrap these vars in {} to matcht he rest of the script --- 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 5455de53..c372c410 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -166,9 +166,9 @@ verifyFreeDiskSpace() { fi # - Insufficient free disk space - elif [[ $existing_free_kilobytes -lt $required_free_kilobytes ]]; then + elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; 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 $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes 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 + 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 $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes 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 "$existing_free_kilobytes is less than $required_free_kilobytes" echo "Insufficient free space, exiting..." exit 1 From 6f780316c4a6c5904b7751b5bcd56a291d986334 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 11:09:14 +0100 Subject: [PATCH 53/55] remove whiptail dependency from verifyFreeDiskSpace. Add argument detection to skip disk space. This is because curling to bash does not support waiting for user input. --- automated install/basic-install.sh | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c372c410..f70aeed0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -149,27 +149,27 @@ verifyFreeDiskSpace() { # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) # - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables. + echo "::: Verifying free disk space..." local required_free_kilobytes=51200 local existing_free_kilobytes=$(df -Pk | grep -m1 '\/$' | awk '{print $4}') # - Unknown free disk space , not a integer if ! [[ "$existing_free_kilobytes" =~ ^([0-9])+$ ]]; then - - whiptail --title "Unknown free disk space" --yesno "We were unable to determine available free disk space on this system.\n\nYou may override this check and force the installation, however, it is not recommended.\n\nWould you like to continue with the installation?" --defaultno --backtitle "Pi-hole" ${r} ${c} - local choice=$? - if (( $choice != 0 )); then - - echo "non-integer value from existing_free_kilobytes ($existing_free_kilobytes)" - echo "Unknown free space, user aborted, exiting..." - exit 1 - - fi - + echo "::: Unknown free disk space!" + echo "::: We were unable to determine available free disk space on this system." + echo "::: You may override this check and force the installation, however, it is not recommended" + echo "::: To do so, pass the argument '--force' to the install script" + echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --force" + exit 1 # - Insufficient free disk space elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; then + echo "::: Insufficient Disk Space!" + echo "::: Your system appears to be low on disk space. pi-hole recommends a minimum of $required_free_kilobytes KiloBytes." + echo "::: You only have $existing_free_kilobytes KiloBytes free." + echo "::: If this is a new install you may need to expand your disk." + echo "::: Try running 'sudo raspi-config', and choose the 'expand file system option'" + echo "::: After rebooting, run this installation again. (curl -L https://install.pi-hole.net | bash)" - 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 $required_free_kilobytes KiloBytes.\nYou only have $existing_free_kilobytes KiloBytes 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 "$existing_free_kilobytes is less than $required_free_kilobytes" echo "Insufficient free space, exiting..." exit 1 @@ -927,7 +927,12 @@ fi # Start the installer # Verify there is enough disk space for the install -verifyFreeDiskSpace +if [ $1 = "--force" ]; then + echo "::: --force passed to script, skipping free disk space verification!" +else + verifyFreeDiskSpace +fi + # Install packages used by this installation script installerDependencies From aca5064743ed9639ca69eb03c031de51147fc22d Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 11:16:48 +0100 Subject: [PATCH 54/55] --force seems to light. lets try --i_do_not_follow_recommendations --- automated install/basic-install.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f70aeed0..08c2bd6a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -158,8 +158,8 @@ verifyFreeDiskSpace() { echo "::: Unknown free disk space!" echo "::: We were unable to determine available free disk space on this system." echo "::: You may override this check and force the installation, however, it is not recommended" - echo "::: To do so, pass the argument '--force' to the install script" - echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --force" + echo "::: To do so, pass the argument '--i_do_not_follow_recommendations' to the install script" + echo "::: eg. curl -L https://install.pi-hole.net | bash /dev/stdin --i_do_not_follow_recommendations" exit 1 # - Insufficient free disk space elif [[ ${existing_free_kilobytes} -lt ${required_free_kilobytes} ]]; then @@ -927,8 +927,9 @@ fi # Start the installer # Verify there is enough disk space for the install -if [ $1 = "--force" ]; then - echo "::: --force passed to script, skipping free disk space verification!" +if [ $1 = "--i_do_not_follow_recommendations" ]; then + echo "::: ----i_do_not_follow_recommendations passed to script" + echo "::: skipping free disk space verification!" else verifyFreeDiskSpace fi From c281b4790583527d22ee8841833fcec3990e3327 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 2 Oct 2016 12:44:33 +0100 Subject: [PATCH 55/55] Mover {SUDO} mkdir -p /etc/pihole/ back to the beginning. --- 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 08c2bd6a..4d8c602a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -804,7 +804,6 @@ installPihole() { checkForDependencies # done stopServices setUser - ${SUDO} mkdir -p /etc/pihole/ if [ ! -d "/var/www/html" ]; then ${SUDO} mkdir -p /var/www/html fi @@ -939,7 +938,7 @@ installerDependencies if [[ ${useUpdateVars} == false ]]; then welcomeDialogs - + ${SUDO} mkdir -p /etc/pihole/ # Find IP used to route to outside world findIPRoute # Find interfaces and let the user choose one