From 2c8dcd86e570df2c1b1372b330b095d749f804d9 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 9 Nov 2017 20:47:15 +0000 Subject: [PATCH 01/87] remove package_check to avoid situations like #1760 Signed-off-by: Adam Warner --- automated install/uninstall.sh | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 2f4f4f9f..5628702f 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -62,19 +62,12 @@ if [ -x "$(command -v rpm)" ]; then package_check() { rpm -qa | grep ^$1- > /dev/null } - package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - } elif [ -x "$(command -v apt-get)" ]; then # Debian Family PKG_REMOVE="${PKG_MANAGER} -y remove --purge" package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } - package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - ${SUDO} ${PKG_MANAGER} -y autoclean - } else echo -e " ${CROSS} OS distribution not supported" exit 1 @@ -103,14 +96,9 @@ removeAndPurge() { done # Remove dnsmasq config files - ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/*-pihole*.conf &> /dev/null echo -e " ${TICK} Removing dnsmasq config files" - # Take care of any additional package cleaning - echo -ne " ${INFO} Removing & cleaning remaining dependencies..." - package_cleanup &> /dev/null - echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" - # Call removeNoPurge to remove Pi-hole specific files removeNoPurge } From 36945a67d03d7ea28b706ed4b5b0b57b2ed0c93a Mon Sep 17 00:00:00 2001 From: Ryan Knapper Date: Wed, 7 Feb 2018 17:04:10 -0500 Subject: [PATCH 02/87] Prevent redundant entries in to adlists.list Grep ${args[3]} and only add if grep -c -eq 0 Signed-off-by: Ryan Knapper --- advanced/Scripts/webpage.sh | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index d47eaff6..bd69d8ad 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -182,10 +182,6 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423 add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}" fi - if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then - add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}" - add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}" - fi } @@ -215,17 +211,6 @@ SetDNSServers() { else change_setting "DNSSEC" "false" fi - if [[ "${args[6]}" == "conditional_forwarding" ]]; then - change_setting "CONDITIONAL_FORWARDING" "true" - change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}" - change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}" - change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}" - else - change_setting "CONDITIONAL_FORWARDING" "false" - delete_setting "CONDITIONAL_FORWARDING_IP" - delete_setting "CONDITIONAL_FORWARDING_DOMAIN" - delete_setting "CONDITIONAL_FORWARDING_REVERSE" - fi ProcessDNSSettings @@ -269,7 +254,7 @@ ProcessDHCPSettings() { fi if [[ "${PIHOLE_DOMAIN}" == "" ]]; then - PIHOLE_DOMAIN="local" + PIHOLE_DOMAIN="lan" change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}" fi @@ -361,7 +346,9 @@ CustomizeAdLists() { elif [[ "${args[2]}" == "disable" ]]; then sed -i "\\@${args[3]}@s/^http/#http/g" "${list}" elif [[ "${args[2]}" == "add" ]]; then - echo "${args[3]}" >> ${list} + if [[ $(grep -c "${args[3]}" "${list}") -eq 0 ]] ; then + echo "${args[3]}" >> ${list} + fi elif [[ "${args[2]}" == "del" ]]; then var=$(echo "${args[3]}" | sed 's/\//\\\//g') sed -i "/${var}/Id" "${list}" From f2b3752f3dea7bd7e7e9ab6e06fba372bebeb454 Mon Sep 17 00:00:00 2001 From: Ryan Knapper Date: Wed, 7 Feb 2018 17:08:55 -0500 Subject: [PATCH 03/87] lan to local Reduced differences. Signed-off-by: Ryan Knapper --- advanced/Scripts/webpage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index bd69d8ad..6e13d24e 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -254,7 +254,7 @@ ProcessDHCPSettings() { fi if [[ "${PIHOLE_DOMAIN}" == "" ]]; then - PIHOLE_DOMAIN="lan" + PIHOLE_DOMAIN="local" change_setting "PIHOLE_DOMAIN" "${PIHOLE_DOMAIN}" fi From 0541d8f1c550e9c55acfdcbbbd6b225885644ac1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 24 Feb 2018 11:13:33 +0100 Subject: [PATCH 04/87] Try to determine if the user is running a 32bit OS on a 64bit system. If so, download the 32bit binary as we cannot expect the 64bit libraries to be present. Signed-off-by: DL6ER --- advanced/Scripts/piholeCheckout.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/advanced/Scripts/piholeCheckout.sh b/advanced/Scripts/piholeCheckout.sh index 9e97c69c..63198b5a 100644 --- a/advanced/Scripts/piholeCheckout.sh +++ b/advanced/Scripts/piholeCheckout.sh @@ -68,9 +68,20 @@ FTLinstall() { } get_binary_name() { + # This gives the machine architecture which may be different from the OS architecture... local machine machine=$(uname -m) + # This gives the architecture of packages dpkg installs (for example, "i386") + local dpkgarch + dpkgarch=$(dpkg --print-architecture 2> /dev/null) + + # Special case: This is a 32 bit OS, installed on a 64 bit machine + # -> change machine architecture to download the 32 bit executable + if [[ "${machine}" == "x86_64" && "${dpkgarch}" == "i386" ]]; then + machine="i686" + fi + local str str="Detecting architecture" echo -ne " ${INFO} ${str}..." From 5ecfc58e5fb016d1f8fd031325d8f7c98aa8cb4a Mon Sep 17 00:00:00 2001 From: Ryan Knapper Date: Wed, 28 Feb 2018 13:06:07 -0500 Subject: [PATCH 05/87] Require exact match Updated to require an exact match to reduce false-positives, as suggested by DL6ER. Signed-off-by: Ryan Knapper --- advanced/Scripts/webpage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 6e13d24e..3c76e173 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -346,7 +346,7 @@ CustomizeAdLists() { elif [[ "${args[2]}" == "disable" ]]; then sed -i "\\@${args[3]}@s/^http/#http/g" "${list}" elif [[ "${args[2]}" == "add" ]]; then - if [[ $(grep -c "${args[3]}" "${list}") -eq 0 ]] ; then + if [[ $(grep -c "^${args[3]}$" "${list}") -eq 0 ]] ; then echo "${args[3]}" >> ${list} fi elif [[ "${args[2]}" == "del" ]]; then From 143e75d213a0cbcf9b2f179fe4e4a095c248c8e1 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 25 Mar 2018 09:39:29 -0500 Subject: [PATCH 06/87] fix empty ports on some systems Signed-off-by: Jacob Salmela --- 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 b668af94..633fb7a9 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -652,7 +652,7 @@ check_required_ports() { # Sort the addresses and remove duplicates while IFS= read -r line; do ports_in_use+=( "$line" ) - done < <( lsof -i -P -n | awk -F' ' '/LISTEN/ {print $9, $1}' | sort -n | uniq | cut -d':' -f2 ) + done < <( lsof -i -P -n | awk -F' ' '/LISTEN/ {print $1, $9}' | sort -n | tr -d '[*]\r' | uniq | awk '{print $2, $1}' ) # Now that we have the values stored, for i in "${!ports_in_use[@]}"; do From c3f391dc5ac45209f8e963f681bea8787657fbf9 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 31 Mar 2018 14:08:48 -0500 Subject: [PATCH 07/87] maybe fixes #2028 by deleting null bytes Signed-off-by: Jacob Salmela --- gravity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 395ea548..b040b69b 100755 --- a/gravity.sh +++ b/gravity.sh @@ -384,7 +384,7 @@ gravity_ConsolidateDownloadedBlocklists() { tr -d '\r' < "${i}" | tr '[:upper:]' '[:lower:]' >> "${piholeDir}/${matterAndLight}" # Ensure that the first line of a new list is on a new line - lastLine=$(tail -1 "${piholeDir}/${matterAndLight}") + lastLine=$(tail -1 "${piholeDir}/${matterAndLight}" | tr -d '\0') if [[ "${#lastLine}" -gt 0 ]]; then echo "" >> "${piholeDir}/${matterAndLight}" fi @@ -505,7 +505,7 @@ gravity_ParseBlacklistDomains() { # Empty $accretionDisc if it already exists, otherwise, create it : > "${piholeDir}/${accretionDisc}" - + if [[ -f "${piholeDir}/${whitelistMatter}" ]]; then gravity_ParseDomainsIntoHosts "${piholeDir}/${whitelistMatter}" "${piholeDir}/${accretionDisc}" else From 187848660c15243802942b05c78dd572b3054d28 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sat, 31 Mar 2018 16:12:29 -0500 Subject: [PATCH 08/87] try another fix for #2028 Signed-off-by: Jacob Salmela --- gravity.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index b040b69b..677f1956 100755 --- a/gravity.sh +++ b/gravity.sh @@ -382,9 +382,8 @@ gravity_ConsolidateDownloadedBlocklists() { if [[ -r "${i}" ]]; then # Remove windows CRs from file, convert list to lower case, and append into $matterAndLight tr -d '\r' < "${i}" | tr '[:upper:]' '[:lower:]' >> "${piholeDir}/${matterAndLight}" - # Ensure that the first line of a new list is on a new line - lastLine=$(tail -1 "${piholeDir}/${matterAndLight}" | tr -d '\0') + IFS= read -r -d '' lastLine <"${piholeDir}/${matterAndLight}" || [[ $lastLine ]] if [[ "${#lastLine}" -gt 0 ]]; then echo "" >> "${piholeDir}/${matterAndLight}" fi From 5ffc3561eda57963e5b88b74816184869574f66e Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Wed, 11 Apr 2018 20:35:51 -0500 Subject: [PATCH 09/87] implement dschapers suggestions--better command, less subshells, and finer formatting Signed-off-by: Jacob Salmela --- advanced/Scripts/piholeDebug.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 633fb7a9..44e71a25 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -652,15 +652,22 @@ check_required_ports() { # Sort the addresses and remove duplicates while IFS= read -r line; do ports_in_use+=( "$line" ) - done < <( lsof -i -P -n | awk -F' ' '/LISTEN/ {print $1, $9}' | sort -n | tr -d '[*]\r' | uniq | awk '{print $2, $1}' ) + done < <( lsof -iTCP -sTCP:LISTEN -P -n +c 10 ) # Now that we have the values stored, for i in "${!ports_in_use[@]}"; do # loop through them and assign some local variables - local port_number - port_number="$(echo "${ports_in_use[$i]}" | awk '{print $1}')" local service_name - service_name=$(echo "${ports_in_use[$i]}" | awk '{print $2}') + service_name=$(echo "${ports_in_use[$i]}" | awk '{print $1}') + local protocol_type + protocol_type=$(echo "${ports_in_use[$i]}" | awk '{print $5}') + local port_number + port_number="$(echo "${ports_in_use[$i]}" | awk '{print $9}')" + + # Skip the line if it's the titles of the columns the lsof command produces + if [[ "${service_name}" == COMMAND ]]; then + continue + fi # Use a case statement to determine if the right services are using the right ports case "${port_number}" in 53) compare_port_to_service_assigned "${resolver}" @@ -670,7 +677,7 @@ check_required_ports() { 4711) compare_port_to_service_assigned "${ftl}" ;; # If it's not a default port that Pi-hole needs, just print it out for the user to see - *) log_write "[${port_number}] is in use by ${service_name}"; + *) log_write "${port_number} ${service_name} (${protocol_type})"; esac done } From 8ad37af70ee884c3d863755b32f87dea35681ae5 Mon Sep 17 00:00:00 2001 From: bcambl Date: Tue, 1 May 2018 00:28:55 -0600 Subject: [PATCH 10/87] CentOS install re-worked to include PHP7 via Remi repository Signed-off-by: bcambl --- automated install/basic-install.sh | 71 +++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index e7c5cd55..753f1211 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -217,14 +217,71 @@ elif command -v rpm &> /dev/null; then PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l" INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng) PIHOLE_DEPS=(bc bind-utils cronie curl findutils nmap-ncat sudo unzip wget libidn2 psmisc) - PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli php-pdo) - # EPEL (https://fedoraproject.org/wiki/EPEL) is required for lighttpd on CentOS - if grep -qi 'centos' /etc/redhat-release; then - INSTALLER_DEPS=("${INSTALLER_DEPS[@]}" "epel-release"); + PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo) + LIGHTTPD_USER="lighttpd" + LIGHTTPD_GROUP="lighttpd" + LIGHTTPD_CFG="lighttpd.conf.fedora" + # If the host OS is Fedora, + if grep -qi 'fedora' /etc/redhat-release; then + # all required packages should be available by default with the latest fedora release + : # continue + # or if host OS is CentOS, + elif grep -qi 'centos' /etc/redhat-release; then + # Pi-Hole currently supports CentOS 7+ with PHP7+ + SUPPORTED_CENTOS_VERSION=7 + SUPPORTED_CENTOS_PHP_VERSION=7 + # Check current CentOS major release version + CURRENT_CENTOS_VERSION=$(rpm -q --queryformat '%{VERSION}' centos-release) + # Check if CentOS version is supported + if [[ $CURRENT_CENTOS_VERSION -lt $SUPPORTED_CENTOS_VERSION ]]; then + echo -e " ${CROSS} CentOS $CURRENT_CENTOS_VERSION is not suported." + echo -e " Please update to CentOS release $SUPPORTED_CENTOS_VERSION or later" + # exit the installer + exit + fi + # on CentOS we need to add the EPEL repository to gain access to Fedora packages + EPEL_PKG="epel-release" + rpm -q ${EPEL_PKG} &> /dev/null || rc=$? + if [[ $rc -ne 0 ]]; then + echo -e " ${INFO} Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)" + "${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null + echo -e " ${TICK} Installed ${EPEL_PKG}" + fi + + # The default php on CentOS 7.x is 5.4 which is EOL + # Check if the version of PHP available via installed repositories is >= to PHP 7 + AVAILABLE_PHP_VERSION=$(${PKG_MANAGER} info php | grep -i version | grep -o '[0-9]\+' | head -1) + if [[ $AVAILABLE_PHP_VERSION -ge $SUPPORTED_CENTOS_PHP_VERSION ]]; then + # Since PHP 7 is available by default, install via default PHP package names + : # do nothing as PHP is current + else + REMI_PKG="remi-release" + REMI_REPO="remi-php72" + rpm -q ${REMI_PKG} &> /dev/null || rc=$? + if [[ $rc -ne 0 ]]; then + # The PHP version available via default repositories is older than version 7 + if ! whiptail --defaultno --title "PHP 7 Update (recommended)" --yesno "PHP 7.x is recommended for both security and language features.\\nWould you like to install PHP7 via Remi's RPM repository?\\n\\nSee: https://rpms.remirepo.net for more information" ${r} ${c}; then + # User decided to NOT update PHP from REMI, attempt to install the default available PHP version + echo -e " ${INFO} User opt-out of PHP 7 upgrade on CentOS. Deprecated PHP may be in use." + : # continue with unsupported php version + else + echo -e " ${INFO} Enabling Remi's RPM repository (https://rpms.remirepo.net)" + "${PKG_INSTALL[@]}" "https://rpms.remirepo.net/enterprise/${REMI_PKG}-$(rpm -E '%{rhel}').rpm" &> /dev/null + # enable the PHP 7 repository via yum-config-manager (provided by yum-utils) + "${PKG_INSTALL[@]}" "yum-utils" &> /dev/null + yum-config-manager --enable ${REMI_REPO} &> /dev/null + echo -e " ${TICK} Remi's RPM repository has been enabled for PHP7" + + fi + fi + fi + else + # If not a supported version of Fedora or CentOS, + echo -e " ${CROSS} Unsupported RPM based distribution" + # exit the installer + exit fi - LIGHTTPD_USER="lighttpd" - LIGHTTPD_GROUP="lighttpd" - LIGHTTPD_CFG="lighttpd.conf.fedora" + # If neither apt-get or rmp/dnf are found else From ec3802c180385edf2d092a87619c76062440a314 Mon Sep 17 00:00:00 2001 From: bcambl Date: Thu, 3 May 2018 23:41:42 -0600 Subject: [PATCH 11/87] add 'which' dependency (missing on Fedora minimal) Signed-off-by: bcambl --- 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 753f1211..878f2785 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -215,7 +215,7 @@ elif command -v rpm &> /dev/null; then UPDATE_PKG_CACHE=":" PKG_INSTALL=(${PKG_MANAGER} install -y) PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l" - INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng) + INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng which) PIHOLE_DEPS=(bc bind-utils cronie curl findutils nmap-ncat sudo unzip wget libidn2 psmisc) PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo) LIGHTTPD_USER="lighttpd" From d3dda443cd03aa6a9ad3b1c87d3d12a68c9bb60d Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 4 May 2018 00:02:47 -0600 Subject: [PATCH 12/87] flip uninstall compatability check Signed-off-by: bcambl --- automated install/uninstall.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 2f4c58a1..b58c3ecb 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -53,16 +53,7 @@ if [[ "${INSTALL_WEB_SERVER}" == true ]]; then fi # Compatability -if [ -x "$(command -v rpm)" ]; then - # Fedora Family - PKG_REMOVE="${PKG_MANAGER} remove -y" - package_check() { - rpm -qa | grep ^$1- > /dev/null - } - package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - } -elif [ -x "$(command -v apt-get)" ]; then +if [ -x "$(command -v apt-get)" ]; then # Debian Family PKG_REMOVE="${PKG_MANAGER} -y remove --purge" package_check() { @@ -72,6 +63,15 @@ elif [ -x "$(command -v apt-get)" ]; then ${SUDO} ${PKG_MANAGER} -y autoremove ${SUDO} ${PKG_MANAGER} -y autoclean } +elif [ -x "$(command -v rpm)" ]; then + # Fedora Family + PKG_REMOVE="${PKG_MANAGER} remove -y" + package_check() { + rpm -qa | grep ^$1- > /dev/null + } + package_cleanup() { + ${SUDO} ${PKG_MANAGER} -y autoremove + } else echo -e " ${CROSS} OS distribution not supported" exit 1 From 31951dae4c8dbefb7606251dfa800fcefe6614df Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 11 May 2018 14:31:42 +1000 Subject: [PATCH 13/87] Update index.php Avoiding calling empty() on a function allows this to work under PHP5. Making the check for blocklist generation in this way instead is compatible with both PHP5 and PHP7. Signed-off-by: Rob Gill --- advanced/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index d097fe0f..041939a7 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -102,7 +102,8 @@ if ($serverName === "pi.hole") { $bpAskAdmin = !empty($svEmail) ? '' : ""; // Determine if at least one block list has been generated -if (empty(glob("/etc/pihole/list.0.*.domains"))) +$blocklistglob = glob("/etc/pihole/list.0.*.domains"); +if ($blocklistglob = "") die("[ERROR] There are no domain lists generated lists within /etc/pihole/! Please update gravity by running pihole -g, or repair Pi-hole using pihole -r."); // Set location of adlists file From 5e99baf7b9b9ae81ec3d07dd44919732d8dc31fc Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 11 May 2018 14:52:30 +1000 Subject: [PATCH 14/87] Update index.php thanks stickler-ci ....... Signed-off-by: Rob Gill --- advanced/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 041939a7..0f22908f 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -103,8 +103,9 @@ $bpAskAdmin = !empty($svEmail) ? '/etc/pihole/! Please update gravity by running pihole -g, or repair Pi-hole using pihole -r."); +} // Set location of adlists file if (is_file("/etc/pihole/adlists.list")) { From 9379487942ec0f9f733ac18de7b9a215503190ca Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 12 May 2018 10:49:01 +1000 Subject: [PATCH 15/87] changes as requested changes as requested Signed-off-by: Rob Gill --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 0f22908f..5503d604 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -103,7 +103,7 @@ $bpAskAdmin = !empty($svEmail) ? '/etc/pihole/! Please update gravity by running pihole -g, or repair Pi-hole using pihole -r."); } From 382c19024f6d7927a3684e9a77f7ae3e4252fdf6 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 12 May 2018 10:53:44 +1000 Subject: [PATCH 16/87] oh stickler bot... accidentally a space Signed-off-by: Rob Gill --- advanced/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/index.php b/advanced/index.php index 5503d604..1575bafc 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -103,7 +103,7 @@ $bpAskAdmin = !empty($svEmail) ? '/etc/pihole/! Please update gravity by running pihole -g, or repair Pi-hole using pihole -r."); } From c1ecfbfe63961850f5d8f311fe9be2db08321de4 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sat, 12 May 2018 19:39:17 -0600 Subject: [PATCH 17/87] linting: Double quote to prevent globbing and word splitting Signed-off-by: bcambl --- automated install/uninstall.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b58c3ecb..2bcf66bb 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -60,17 +60,17 @@ if [ -x "$(command -v apt-get)" ]; then dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - ${SUDO} ${PKG_MANAGER} -y autoclean + "${SUDO} ${PKG_MANAGER}" -y autoremove + "${SUDO} ${PKG_MANAGER}" -y autoclean } elif [ -x "$(command -v rpm)" ]; then # Fedora Family PKG_REMOVE="${PKG_MANAGER} remove -y" package_check() { - rpm -qa | grep ^$1- > /dev/null + rpm -qa | grep "^$1-" > /dev/null } package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove + "${SUDO} ${PKG_MANAGER}" -y autoremove } else echo -e " ${CROSS} OS distribution not supported" From adf2275018ea9e20b11c87d175d32530c35e30ba Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 14 May 2018 19:38:12 +1000 Subject: [PATCH 18/87] unbind resolved on ubuntu 18.04 Stop systemd-resolved from interfering with dnsmasq/ftl Signed-off-by: Rob Gill --- automated install/basic-install.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3100ce58..d4984061 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2304,6 +2304,25 @@ main() { fi fi + # resolved and dnsmasq can't share port 53. + # resolved needs to remain in place for installer to download needed files + # so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl + + # Check if running ubuntu 18.04 bionic beaver, which ships with resolved active on port 53 + # (This check may need to be broadened for other systems running resolved?) + if ( lsb_release -a | grep 'Ubuntu 18.04' &> /dev/null ); then + # Running ubuntu 18.04, so check if resolved is running, + if (systemctl is-enabled systemd-resolved | grep -c 'enabled' || true); then + # if resolveconf is running unbind it from port 53 + # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running + echo -e "Unbinding resolved from port 53" + # Make a backup of the original /etc/systemd/resolveconf.d + # (This will need to be restored on uninstallation) + sed -i.orig 's/#DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf + systemctl restart systemd-resolved + fi + fi + # Enable FTL start_service pihole-FTL enable_service pihole-FTL From 3d3e7a330cf8809bd53254eb5a5a660fdb3f8053 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 14 May 2018 19:44:23 +1000 Subject: [PATCH 19/87] restore resolvd.conf If dnsmasq is removed, resolved will need to be restored. Signed-off-by: Rob Gill --- automated install/uninstall.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 2f4c58a1..68eeec45 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -165,6 +165,13 @@ removeNoPurge() { ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null echo -e " ${TICK} Removed config files" + # Restore resolved + if [[ -e /etc/systemd/resolved.conf.orig ]]; then + systemctl disable systemd-resolved + cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf + systemctl enable systemd-resolved + fi + # Remove FTL if command -v pihole-FTL &> /dev/null; then echo -ne " ${INFO} Removing pihole-FTL..." From 97809277df1ebe3f8a6546c9c4f0de5e75508c33 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 14 May 2018 19:50:58 +1000 Subject: [PATCH 20/87] Update uninstall.sh Signed-off-by: Rob Gill > --- automated install/uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 68eeec45..b339ed2c 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -168,7 +168,7 @@ removeNoPurge() { # Restore resolved if [[ -e /etc/systemd/resolved.conf.orig ]]; then systemctl disable systemd-resolved - cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf + ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf systemctl enable systemd-resolved fi From b89a78ce1787dd917e604cbc6372473aacd36d4c Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 15 May 2018 19:42:18 +1000 Subject: [PATCH 21/87] message text Signed-off-by: Rob Gill > --- 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 d4984061..f5d17b04 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2315,7 +2315,7 @@ main() { if (systemctl is-enabled systemd-resolved | grep -c 'enabled' || true); then # if resolveconf is running unbind it from port 53 # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running - echo -e "Unbinding resolved from port 53" + echo -e "Disabling systemd-resolved DNSStubListener" # Make a backup of the original /etc/systemd/resolveconf.d # (This will need to be restored on uninstallation) sed -i.orig 's/#DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf From 25d0e125e58a3a921911be0257a9651a9606e459 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 15 May 2018 20:23:36 +1000 Subject: [PATCH 22/87] relocate as function The check for systemd-resolved DNSStubListener, and disabling as necessary is a new function, called just prior to start_service pihole-FTL. The check for ubuntu bionic 18.04 specifically is removed. The check if resolved is enabled is made with check_service_active() An additional check that the dnsstublistener is enabled is made. Signed-off-by: Rob Gill --- automated install/basic-install.sh | 39 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f5d17b04..155e9f90 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1265,6 +1265,25 @@ check_service_active() { fi } +# Systemd-resolved's DNSStubListener and dnsmasq can't share port 53. +# Resolved needs to remain in place for installer to download needed files +# so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl +disable_resolved_stublistener() { + # Check if Systemd-resolved's DNSSTub listener is enabled and active on port 53 + if check_service_active "systemd-resolved"; then + # Check if DNSStubListener is enabled + if ( grep '#DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then + # Disable the DNSStubListener to unbind it from port 53 + # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running + echo -e "Disabling systemd-resolved DNSStubListener" + # Make a backup of the original /etc/systemd/resolved.conf + # (This will need to be restored on uninstallation) + sed -i.orig 's/#DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf + systemctl restart systemd-resolved + fi + fi +} + update_package_cache() { # Running apt-get update/upgrade with minimal output can cause some issues with # requiring user input (e.g password for phpmyadmin see #218) @@ -2304,24 +2323,8 @@ main() { fi fi - # resolved and dnsmasq can't share port 53. - # resolved needs to remain in place for installer to download needed files - # so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl - - # Check if running ubuntu 18.04 bionic beaver, which ships with resolved active on port 53 - # (This check may need to be broadened for other systems running resolved?) - if ( lsb_release -a | grep 'Ubuntu 18.04' &> /dev/null ); then - # Running ubuntu 18.04, so check if resolved is running, - if (systemctl is-enabled systemd-resolved | grep -c 'enabled' || true); then - # if resolveconf is running unbind it from port 53 - # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running - echo -e "Disabling systemd-resolved DNSStubListener" - # Make a backup of the original /etc/systemd/resolveconf.d - # (This will need to be restored on uninstallation) - sed -i.orig 's/#DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf - systemctl restart systemd-resolved - fi - fi + # Check for and if necessary disable systemd-resolved-DNSStubListener + disable_resolved_stublistener # Enable FTL start_service pihole-FTL From a431c829cbbecfbcfb6036047776fc6f4df73cd9 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 16 May 2018 07:11:23 +1000 Subject: [PATCH 23/87] Regex & case fix grep & sed regexes match commented or uncommented Signed-off-by: Rob Gill --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 155e9f90..d9efa280 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1269,16 +1269,16 @@ check_service_active() { # Resolved needs to remain in place for installer to download needed files # so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl disable_resolved_stublistener() { - # Check if Systemd-resolved's DNSSTub listener is enabled and active on port 53 + # Check if Systemd-resolved's DNSStubListener is enabled and active on port 53 if check_service_active "systemd-resolved"; then # Check if DNSStubListener is enabled - if ( grep '#DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then + if ( grep -E '#?DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then # Disable the DNSStubListener to unbind it from port 53 # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running echo -e "Disabling systemd-resolved DNSStubListener" # Make a backup of the original /etc/systemd/resolved.conf # (This will need to be restored on uninstallation) - sed -i.orig 's/#DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf + sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf systemctl restart systemd-resolved fi fi From c400b914e5d46765a8613c1745ad67778b753a77 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 16 May 2018 07:28:32 +1000 Subject: [PATCH 24/87] Update basic-install.sh Force reloading of relsolved config where available Signed-off-by: Rob Gill --- 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 d9efa280..47462723 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1279,7 +1279,7 @@ disable_resolved_stublistener() { # Make a backup of the original /etc/systemd/resolved.conf # (This will need to be restored on uninstallation) sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf - systemctl restart systemd-resolved + systemctl reload-or-restart systemd-resolved fi fi } From 15f0ba839f5f4979d3cc43397dfc4090910cc198 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 16 May 2018 07:35:22 +1000 Subject: [PATCH 25/87] reload resloved reload resolved config if possible, restart otherwise Signed-off-by: Rob Gill --- automated install/uninstall.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b339ed2c..70f8eeb3 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -167,9 +167,8 @@ removeNoPurge() { # Restore resolved if [[ -e /etc/systemd/resolved.conf.orig ]]; then - systemctl disable systemd-resolved ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf - systemctl enable systemd-resolved + systemctl reload-or-restart systemd-resolved fi # Remove FTL From 8cfe89604af7d699b75b29fbede39f789636ffb8 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 17 May 2018 07:44:07 +1000 Subject: [PATCH 26/87] user-facing messages Signed-off-by: Rob Gill --- 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 47462723..07a4adc1 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1266,21 +1266,28 @@ check_service_active() { } # Systemd-resolved's DNSStubListener and dnsmasq can't share port 53. -# Resolved needs to remain in place for installer to download needed files +# Resolved needs to remain in place for installer to download needed files, # so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl disable_resolved_stublistener() { + echo -en " ${INFO} Testing if systemd-resolved is enabled" # Check if Systemd-resolved's DNSStubListener is enabled and active on port 53 if check_service_active "systemd-resolved"; then # Check if DNSStubListener is enabled + echo -en " ${OVER} ${INFO} Testing if systemd-resolved DNSStub-Listener is active" if ( grep -E '#?DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then # Disable the DNSStubListener to unbind it from port 53 # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running - echo -e "Disabling systemd-resolved DNSStubListener" + echo -en "${OVER} ${TICK} Disabling systemd-resolved DNSStubListener" # Make a backup of the original /etc/systemd/resolved.conf # (This will need to be restored on uninstallation) sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf + echo -e " and restarting systemd-resolved" systemctl reload-or-restart systemd-resolved + else + echo -e "${OVER} ${INFO} Systemd-resolved does not need to be restarted" fi + else + echo -e "${OVER} ${INFO} Systemd-resolved is not enabled" fi } From 20ccb7b5589bc7f1b2f225995f4c9f0c3bf385aa Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 21 May 2018 08:16:53 +1000 Subject: [PATCH 27/87] move & clarify comments --- automated install/basic-install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 07a4adc1..3a8fe928 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1266,8 +1266,6 @@ check_service_active() { } # Systemd-resolved's DNSStubListener and dnsmasq can't share port 53. -# Resolved needs to remain in place for installer to download needed files, -# so this change needs to be made after installation is complete, but before resarting dnsmasq/ftl disable_resolved_stublistener() { echo -en " ${INFO} Testing if systemd-resolved is enabled" # Check if Systemd-resolved's DNSStubListener is enabled and active on port 53 @@ -2316,8 +2314,11 @@ main() { fi fi - echo -e " ${INFO} Restarting services..." - # Start services + # Check for and disable systemd-resolved-DNSStubListener before reloading resolved + # DNSStubListener needs to remain in place for installer to download needed files, + # so this change needs to be made after installation is complete, + # but before starting or resarting the dnsmasq or ftl services + disable_resolved_stublistener # If the Web server was installed, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then @@ -2330,8 +2331,8 @@ main() { fi fi - # Check for and if necessary disable systemd-resolved-DNSStubListener - disable_resolved_stublistener + echo -e " ${INFO} Restarting services..." + # Start services # Enable FTL start_service pihole-FTL From 1911c3690d2970cb03741266dd44adf12be0e61c Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 29 May 2018 17:59:39 +1000 Subject: [PATCH 28/87] Style/Tabs to spaces uninstall.sh contains a mix of tabs and spaces for indentation in different parts of the file. Everywhere that used tabs has been converted to spaces, compatible with the indentation style used in basic_install.sh No code has been altered, only the use of tabs and spaces in indention. Signed-off-by: Rob Gill --- automated install/uninstall.sh | 208 ++++++++++++++++----------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 2f4c58a1..a077ff44 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -11,29 +11,29 @@ source "/opt/pihole/COL_TABLE" while true; do - read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn - case ${yn} in - [Yy]* ) break;; - [Nn]* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; + read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn + case ${yn} in + [Yy]* ) break;; + [Nn]* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; * ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; - esac + esac done # Must be root to uninstall str="Root user check" if [[ ${EUID} -eq 0 ]]; then - echo -e " ${TICK} ${str}" + echo -e " ${TICK} ${str}" else - # Check if sudo is actually installed - # If it isn't, exit because the uninstall can not complete - if [ -x "$(command -v sudo)" ]; then - export SUDO="sudo" - else + # Check if sudo is actually installed + # If it isn't, exit because the uninstall can not complete + if [ -x "$(command -v sudo)" ]; then + export SUDO="sudo" + else echo -e " ${CROSS} ${str} Script called with non-root privileges The Pi-hole requires elevated privleges to uninstall" - exit 1 - fi + exit 1 + fi fi readonly PI_HOLE_FILES_DIR="/etc/.pihole" @@ -54,115 +54,115 @@ fi # Compatability if [ -x "$(command -v rpm)" ]; then - # Fedora Family - PKG_REMOVE="${PKG_MANAGER} remove -y" - package_check() { - rpm -qa | grep ^$1- > /dev/null - } - package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - } + # Fedora Family + PKG_REMOVE="${PKG_MANAGER} remove -y" + package_check() { + rpm -qa | grep ^$1- > /dev/null + } + package_cleanup() { + ${SUDO} ${PKG_MANAGER} -y autoremove + } elif [ -x "$(command -v apt-get)" ]; then - # Debian Family - PKG_REMOVE="${PKG_MANAGER} -y remove --purge" - package_check() { - dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" - } - package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - ${SUDO} ${PKG_MANAGER} -y autoclean - } + # Debian Family + PKG_REMOVE="${PKG_MANAGER} -y remove --purge" + package_check() { + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" + } + package_cleanup() { + ${SUDO} ${PKG_MANAGER} -y autoremove + ${SUDO} ${PKG_MANAGER} -y autoclean + } else echo -e " ${CROSS} OS distribution not supported" - exit 1 + exit 1 fi removeAndPurge() { - # Purge dependencies + # Purge dependencies echo "" - for i in "${DEPS[@]}"; do - package_check ${i} > /dev/null - if [[ "$?" -eq 0 ]]; then - while true; do - read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn - case ${yn} in - [Yy]* ) + for i in "${DEPS[@]}"; do + package_check ${i} > /dev/null + if [[ "$?" -eq 0 ]]; then + while true; do + read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn + case ${yn} in + [Yy]* ) echo -ne " ${INFO} Removing ${i}..."; ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; echo -e "${OVER} ${INFO} Removed ${i}"; break;; - [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; - esac - done - else - echo -e " ${INFO} Package ${i} not installed" - fi - done + [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; + esac + done + else + echo -e " ${INFO} Package ${i} not installed" + fi + done - # Remove dnsmasq config files - ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + # Remove dnsmasq config files + ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null echo -e " ${TICK} Removing dnsmasq config files" - # Take care of any additional package cleaning - echo -ne " ${INFO} Removing & cleaning remaining dependencies..." - package_cleanup &> /dev/null + # Take care of any additional package cleaning + echo -ne " ${INFO} Removing & cleaning remaining dependencies..." + package_cleanup &> /dev/null echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" - # Call removeNoPurge to remove Pi-hole specific files - removeNoPurge + # Call removeNoPurge to remove Pi-hole specific files + removeNoPurge } removeNoPurge() { - # Only web directories/files that are created by Pi-hole should be removed - echo -ne " ${INFO} Removing Web Interface..." - ${SUDO} rm -rf /var/www/html/admin &> /dev/null - ${SUDO} rm -rf /var/www/html/pihole &> /dev/null - ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null + # Only web directories/files that are created by Pi-hole should be removed + echo -ne " ${INFO} Removing Web Interface..." + ${SUDO} rm -rf /var/www/html/admin &> /dev/null + ${SUDO} rm -rf /var/www/html/pihole &> /dev/null + ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null - # If the web directory is empty after removing these files, then the parent html folder can be removed. - if [ -d "/var/www/html" ]; then - if [[ ! "$(ls -A /var/www/html)" ]]; then - ${SUDO} rm -rf /var/www/html &> /dev/null - fi - fi + # If the web directory is empty after removing these files, then the parent html folder can be removed. + if [ -d "/var/www/html" ]; then + if [[ ! "$(ls -A /var/www/html)" ]]; then + ${SUDO} rm -rf /var/www/html &> /dev/null + fi + fi echo -e "${OVER} ${TICK} Removed Web Interface" - # Attempt to preserve backwards compatibility with older versions - # to guarantee no additional changes were made to /etc/crontab after - # the installation of pihole, /etc/crontab.pihole should be permanently - # preserved. - if [[ -f /etc/crontab.orig ]]; then - ${SUDO} mv /etc/crontab /etc/crontab.pihole - ${SUDO} mv /etc/crontab.orig /etc/crontab - ${SUDO} service cron restart + # Attempt to preserve backwards compatibility with older versions + # to guarantee no additional changes were made to /etc/crontab after + # the installation of pihole, /etc/crontab.pihole should be permanently + # preserved. + if [[ -f /etc/crontab.orig ]]; then + ${SUDO} mv /etc/crontab /etc/crontab.pihole + ${SUDO} mv /etc/crontab.orig /etc/crontab + ${SUDO} service cron restart echo -e " ${TICK} Restored the default system cron" - fi + fi - # Attempt to preserve backwards compatibility with older versions - if [[ -f /etc/cron.d/pihole ]];then - ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null + # Attempt to preserve backwards compatibility with older versions + if [[ -f /etc/cron.d/pihole ]];then + ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null echo -e " ${TICK} Removed /etc/cron.d/pihole" - fi + fi - package_check lighttpd > /dev/null - if [[ $? -eq 1 ]]; then - ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null - echo -e " ${TICK} Removed lighttpd" - else - if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then - ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf - fi - fi + package_check lighttpd > /dev/null + if [[ $? -eq 1 ]]; then + ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null + echo -e " ${TICK} Removed lighttpd" + else + if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then + ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf + fi + fi - ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null - ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null - ${SUDO} rm -rf /var/log/*pihole* &> /dev/null - ${SUDO} rm -rf /etc/pihole/ &> /dev/null - ${SUDO} rm -rf /etc/.pihole/ &> /dev/null - ${SUDO} rm -rf /opt/pihole/ &> /dev/null - ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null - ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null - ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null + ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null + ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null + ${SUDO} rm -rf /var/log/*pihole* &> /dev/null + ${SUDO} rm -rf /etc/pihole/ &> /dev/null + ${SUDO} rm -rf /etc/.pihole/ &> /dev/null + ${SUDO} rm -rf /opt/pihole/ &> /dev/null + ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null + ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null + ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null echo -e " ${TICK} Removed config files" # Remove FTL @@ -180,15 +180,15 @@ removeNoPurge() { echo -e "${OVER} ${TICK} Removed pihole-FTL" fi - # If the pihole user exists, then remove - if id "pihole" &> /dev/null; then - ${SUDO} userdel -r pihole 2> /dev/null + # If the pihole user exists, then remove + if id "pihole" &> /dev/null; then + ${SUDO} userdel -r pihole 2> /dev/null if [[ "$?" -eq 0 ]]; then echo -e " ${TICK} Removed 'pihole' user" else echo -e " ${CROSS} Unable to remove 'pihole' user" fi - fi + fi echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole! If you need help, reach out to us on Github, Discourse, Reddit or Twitter @@ -211,10 +211,10 @@ while true; do echo -n "${i} " done echo "${COL_NC}" - read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn - case ${yn} in - [Yy]* ) removeAndPurge; break;; - [Nn]* ) removeNoPurge; break;; + read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn + case ${yn} in + [Yy]* ) removeAndPurge; break;; + [Nn]* ) removeNoPurge; break;; * ) removeAndPurge; break;; - esac + esac done From ebeab06710cb8953bd14ed80d026e1c2b78f167b Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 29 May 2018 18:59:55 +1000 Subject: [PATCH 29/87] Appease Stickler-bot So... originally no changes were made to the code, but Stickler-bot was unimpressed, so I've followed its suggestions. Signed-off-by: Rob Gill --- automated install/uninstall.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index a077ff44..7d4782ba 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -57,10 +57,10 @@ if [ -x "$(command -v rpm)" ]; then # Fedora Family PKG_REMOVE="${PKG_MANAGER} remove -y" package_check() { - rpm -qa | grep ^$1- > /dev/null + rpm -qa | grep "^$1-" > /dev/null } package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove + "${SUDO}" "${PKG_MANAGER}" -y autoremove } elif [ -x "$(command -v apt-get)" ]; then # Debian Family @@ -69,8 +69,8 @@ elif [ -x "$(command -v apt-get)" ]; then dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } package_cleanup() { - ${SUDO} ${PKG_MANAGER} -y autoremove - ${SUDO} ${PKG_MANAGER} -y autoclean + "${SUDO}" "${PKG_MANAGER}" -y autoremove + "${SUDO}" "${PKG_MANAGER}" -y autoclean } else echo -e " ${CROSS} OS distribution not supported" @@ -81,8 +81,7 @@ removeAndPurge() { # Purge dependencies echo "" for i in "${DEPS[@]}"; do - package_check ${i} > /dev/null - if [[ "$?" -eq 0 ]]; then + if package_check "${i}" > /dev/null; then while true; do read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn case ${yn} in From e6893bc419165e5a9d091b72dbe118e761eb84fd Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 29 May 2018 19:03:00 +1000 Subject: [PATCH 30/87] Update uninstall.sh Signed-off-by: Rob Gill --- automated install/uninstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 7d4782ba..d6bde208 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -14,8 +14,8 @@ while true; do read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn case ${yn} in [Yy]* ) break;; - [Nn]* ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; - * ) echo -e "\n ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; + [Nn]* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; + * ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; esac done From ff71379a8e5e88f35eda0c24b5d4c2c67bb3c778 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 31 May 2018 13:14:18 +1000 Subject: [PATCH 31/87] Convert from two to four space indetation Signed-Off-By: Rob Gill --- automated install/uninstall.sh | 300 ++++++++++++++++----------------- 1 file changed, 149 insertions(+), 151 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index d6bde208..00c28a3a 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -11,29 +11,29 @@ source "/opt/pihole/COL_TABLE" while true; do - read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn - case ${yn} in - [Yy]* ) break;; - [Nn]* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; - * ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; - esac + read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " yn + case ${yn} in + [Yy]* ) break;; + [Nn]* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; + * ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been cancelled${COL_NC}"; exit 0;; + esac done # Must be root to uninstall str="Root user check" if [[ ${EUID} -eq 0 ]]; then - echo -e " ${TICK} ${str}" + echo -e " ${TICK} ${str}" else - # Check if sudo is actually installed - # If it isn't, exit because the uninstall can not complete - if [ -x "$(command -v sudo)" ]; then - export SUDO="sudo" - else - echo -e " ${CROSS} ${str} - Script called with non-root privileges - The Pi-hole requires elevated privleges to uninstall" - exit 1 - fi + # Check if sudo is actually installed + # If it isn't, exit because the uninstall can not complete + if [ -x "$(command -v sudo)" ]; then + export SUDO="sudo" + else + echo -e " ${CROSS} ${str} + Script called with non-root privileges + The Pi-hole requires elevated privleges to uninstall" + exit 1 + fi fi readonly PI_HOLE_FILES_DIR="/etc/.pihole" @@ -48,172 +48,170 @@ distro_check # Install packages used by the Pi-hole DEPS=("${INSTALLER_DEPS[@]}" "${PIHOLE_DEPS[@]}") if [[ "${INSTALL_WEB_SERVER}" == true ]]; then - # Install the Web dependencies - DEPS+=("${PIHOLE_WEB_DEPS[@]}") + # Install the Web dependencies + DEPS+=("${PIHOLE_WEB_DEPS[@]}") fi # Compatability if [ -x "$(command -v rpm)" ]; then - # Fedora Family - PKG_REMOVE="${PKG_MANAGER} remove -y" - package_check() { - rpm -qa | grep "^$1-" > /dev/null - } - package_cleanup() { - "${SUDO}" "${PKG_MANAGER}" -y autoremove - } + # Fedora Family + PKG_REMOVE="${PKG_MANAGER} remove -y" + package_check() { + rpm -qa | grep "^$1-" > /dev/null + } + package_cleanup() { + "${SUDO}" "${PKG_MANAGER}" -y autoremove + } elif [ -x "$(command -v apt-get)" ]; then - # Debian Family - PKG_REMOVE="${PKG_MANAGER} -y remove --purge" - package_check() { - dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" - } - package_cleanup() { - "${SUDO}" "${PKG_MANAGER}" -y autoremove - "${SUDO}" "${PKG_MANAGER}" -y autoclean - } + # Debian Family + PKG_REMOVE="${PKG_MANAGER} -y remove --purge" + package_check() { + dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" + } + package_cleanup() { + "${SUDO}" "${PKG_MANAGER}" -y autoremove + "${SUDO}" "${PKG_MANAGER}" -y autoclean + } else - echo -e " ${CROSS} OS distribution not supported" - exit 1 + echo -e " ${CROSS} OS distribution not supported" + exit 1 fi removeAndPurge() { - # Purge dependencies - echo "" - for i in "${DEPS[@]}"; do - if package_check "${i}" > /dev/null; then - while true; do - read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn - case ${yn} in - [Yy]* ) - echo -ne " ${INFO} Removing ${i}..."; - ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; - echo -e "${OVER} ${INFO} Removed ${i}"; - break;; - [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; - esac - done - else - echo -e " ${INFO} Package ${i} not installed" - fi - done + # Purge dependencies + echo "" + for i in "${DEPS[@]}"; do + if package_check "${i}" > /dev/null; then + while true; do + read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn + case ${yn} in + [Yy]* ) + echo -ne " ${INFO} Removing ${i}..."; + ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; + echo -e "${OVER} ${INFO} Removed ${i}"; + break;; + [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; + esac + done + else + echo -e " ${INFO} Package ${i} not installed" + fi + done - # Remove dnsmasq config files - ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null - echo -e " ${TICK} Removing dnsmasq config files" + # Remove dnsmasq config files + ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + echo -e " ${TICK} Removing dnsmasq config files" - # Take care of any additional package cleaning - echo -ne " ${INFO} Removing & cleaning remaining dependencies..." - package_cleanup &> /dev/null - echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" + # Take care of any additional package cleaning + echo -ne " ${INFO} Removing & cleaning remaining dependencies..." + package_cleanup &> /dev/null + echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" - # Call removeNoPurge to remove Pi-hole specific files - removeNoPurge + # Call removeNoPurge to remove Pi-hole specific files + removeNoPurge } removeNoPurge() { - # Only web directories/files that are created by Pi-hole should be removed - echo -ne " ${INFO} Removing Web Interface..." - ${SUDO} rm -rf /var/www/html/admin &> /dev/null - ${SUDO} rm -rf /var/www/html/pihole &> /dev/null - ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null + # Only web directories/files that are created by Pi-hole should be removed + echo -ne " ${INFO} Removing Web Interface..." + ${SUDO} rm -rf /var/www/html/admin &> /dev/null + ${SUDO} rm -rf /var/www/html/pihole &> /dev/null + ${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null - # If the web directory is empty after removing these files, then the parent html folder can be removed. - if [ -d "/var/www/html" ]; then - if [[ ! "$(ls -A /var/www/html)" ]]; then - ${SUDO} rm -rf /var/www/html &> /dev/null + # If the web directory is empty after removing these files, then the parent html folder can be removed. + if [ -d "/var/www/html" ]; then + if [[ ! "$(ls -A /var/www/html)" ]]; then + ${SUDO} rm -rf /var/www/html &> /dev/null + fi fi - fi - echo -e "${OVER} ${TICK} Removed Web Interface" - - # Attempt to preserve backwards compatibility with older versions - # to guarantee no additional changes were made to /etc/crontab after - # the installation of pihole, /etc/crontab.pihole should be permanently - # preserved. - if [[ -f /etc/crontab.orig ]]; then - ${SUDO} mv /etc/crontab /etc/crontab.pihole - ${SUDO} mv /etc/crontab.orig /etc/crontab - ${SUDO} service cron restart - echo -e " ${TICK} Restored the default system cron" - fi - - # Attempt to preserve backwards compatibility with older versions - if [[ -f /etc/cron.d/pihole ]];then - ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null - echo -e " ${TICK} Removed /etc/cron.d/pihole" - fi - - package_check lighttpd > /dev/null - if [[ $? -eq 1 ]]; then - ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null - echo -e " ${TICK} Removed lighttpd" - else - if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then - ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf + echo -e "${OVER} ${TICK} Removed Web Interface" + + # Attempt to preserve backwards compatibility with older versions + # to guarantee no additional changes were made to /etc/crontab after + # the installation of pihole, /etc/crontab.pihole should be permanently + # preserved. + if [[ -f /etc/crontab.orig ]]; then + ${SUDO} mv /etc/crontab /etc/crontab.pihole + ${SUDO} mv /etc/crontab.orig /etc/crontab + ${SUDO} service cron restart + echo -e " ${TICK} Restored the default system cron" fi - fi - ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null - ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null - ${SUDO} rm -rf /var/log/*pihole* &> /dev/null - ${SUDO} rm -rf /etc/pihole/ &> /dev/null - ${SUDO} rm -rf /etc/.pihole/ &> /dev/null - ${SUDO} rm -rf /opt/pihole/ &> /dev/null - ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null - ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null - ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null - echo -e " ${TICK} Removed config files" + # Attempt to preserve backwards compatibility with older versions + if [[ -f /etc/cron.d/pihole ]];then + ${SUDO} rm -f /etc/cron.d/pihole &> /dev/null + echo -e " ${TICK} Removed /etc/cron.d/pihole" + fi - # Remove FTL - if command -v pihole-FTL &> /dev/null; then - echo -ne " ${INFO} Removing pihole-FTL..." - - if [[ -x "$(command -v systemctl)" ]]; then - systemctl stop pihole-FTL + package_check lighttpd > /dev/null + if [[ $? -eq 1 ]]; then + ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null + echo -e " ${TICK} Removed lighttpd" else - service pihole-FTL stop + if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then + ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf + fi fi - ${SUDO} rm -f /etc/init.d/pihole-FTL - ${SUDO} rm -f /usr/bin/pihole-FTL - echo -e "${OVER} ${TICK} Removed pihole-FTL" - fi + ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null + ${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null + ${SUDO} rm -rf /var/log/*pihole* &> /dev/null + ${SUDO} rm -rf /etc/pihole/ &> /dev/null + ${SUDO} rm -rf /etc/.pihole/ &> /dev/null + ${SUDO} rm -rf /opt/pihole/ &> /dev/null + ${SUDO} rm -f /usr/local/bin/pihole &> /dev/null + ${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null + ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null + echo -e " ${TICK} Removed config files" - # If the pihole user exists, then remove - if id "pihole" &> /dev/null; then - ${SUDO} userdel -r pihole 2> /dev/null - if [[ "$?" -eq 0 ]]; then - echo -e " ${TICK} Removed 'pihole' user" - else - echo -e " ${CROSS} Unable to remove 'pihole' user" + # Remove FTL + if command -v pihole-FTL &> /dev/null; then + echo -ne " ${INFO} Removing pihole-FTL..." + if [[ -x "$(command -v systemctl)" ]]; then + systemctl stop pihole-FTL + else + service pihole-FTL stop + fi + ${SUDO} rm -f /etc/init.d/pihole-FTL + ${SUDO} rm -f /usr/bin/pihole-FTL + echo -e "${OVER} ${TICK} Removed pihole-FTL" fi - fi - echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole! - If you need help, reach out to us on Github, Discourse, Reddit or Twitter - Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC} + # If the pihole user exists, then remove + if id "pihole" &> /dev/null; then + ${SUDO} userdel -r pihole 2> /dev/null + if [[ "$?" -eq 0 ]]; then + echo -e " ${TICK} Removed 'pihole' user" + else + echo -e " ${CROSS} Unable to remove 'pihole' user" + fi + fi - ${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity - ${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}" + echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole! + If you need help, reach out to us on Github, Discourse, Reddit or Twitter + Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC} + + ${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity + ${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}" } ######### SCRIPT ########### if command -v vcgencmd &> /dev/null; then - echo -e " ${INFO} All dependencies are safe to remove on Raspbian" + echo -e " ${INFO} All dependencies are safe to remove on Raspbian" else - echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed" + echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed" fi while true; do - echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:" - echo -n " " - for i in "${DEPS[@]}"; do - echo -n "${i} " - done - echo "${COL_NC}" - read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn - case ${yn} in - [Yy]* ) removeAndPurge; break;; - [Nn]* ) removeNoPurge; break;; - * ) removeAndPurge; break;; - esac + echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:" + echo -n " " + for i in "${DEPS[@]}"; do + echo -n "${i} " + done + echo "${COL_NC}" + read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " yn + case ${yn} in + [Yy]* ) removeAndPurge; break;; + [Nn]* ) removeNoPurge; break;; + * ) removeAndPurge; break;; + esac done From 552138e85188f5f3f013f322040db3be634d3420 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 31 May 2018 13:24:09 +1000 Subject: [PATCH 32/87] Appease stickler-bot. Signed-off-by: Rob Gill --- automated install/uninstall.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 00c28a3a..b5a7964b 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -87,7 +87,7 @@ removeAndPurge() { case ${yn} in [Yy]* ) echo -ne " ${INFO} Removing ${i}..."; - ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; + ${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null; echo -e "${OVER} ${INFO} Removed ${i}"; break;; [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; @@ -179,15 +179,14 @@ removeNoPurge() { # If the pihole user exists, then remove if id "pihole" &> /dev/null; then - ${SUDO} userdel -r pihole 2> /dev/null - if [[ "$?" -eq 0 ]]; then + if ${SUDO} userdel -r pihole 2> /dev/null; then echo -e " ${TICK} Removed 'pihole' user" else echo -e " ${CROSS} Unable to remove 'pihole' user" fi fi - echo -e "\n We're sorry to see you go, but thanks for checking out Pi-hole! + echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole! If you need help, reach out to us on Github, Discourse, Reddit or Twitter Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC} From f2bedddce46d87ab2202926cf45d5cd3aaed93f6 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 31 May 2018 13:37:52 +1000 Subject: [PATCH 33/87] Changes from #2167 converted to spaces Signed-Off-By: Rob Gill --- automated install/uninstall.sh | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b5a7964b..51e85946 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -53,24 +53,17 @@ if [[ "${INSTALL_WEB_SERVER}" == true ]]; then fi # Compatability -if [ -x "$(command -v rpm)" ]; then - # Fedora Family - PKG_REMOVE="${PKG_MANAGER} remove -y" - package_check() { - rpm -qa | grep "^$1-" > /dev/null - } - package_cleanup() { - "${SUDO}" "${PKG_MANAGER}" -y autoremove - } -elif [ -x "$(command -v apt-get)" ]; then +if [ -x "$(command -v apt-get)" ]; then # Debian Family PKG_REMOVE="${PKG_MANAGER} -y remove --purge" package_check() { dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" } - package_cleanup() { - "${SUDO}" "${PKG_MANAGER}" -y autoremove - "${SUDO}" "${PKG_MANAGER}" -y autoclean +elif [ -x "$(command -v rpm)" ]; then + # Fedora Family + PKG_REMOVE="${PKG_MANAGER} remove -y" + package_check() { + rpm -qa | grep "^$1-" > /dev/null } else echo -e " ${CROSS} OS distribution not supported" @@ -81,13 +74,14 @@ removeAndPurge() { # Purge dependencies echo "" for i in "${DEPS[@]}"; do - if package_check "${i}" > /dev/null; then + package_check ${i} > /dev/null + if [[ "$?" -eq 0 ]]; then while true; do read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn case ${yn} in [Yy]* ) echo -ne " ${INFO} Removing ${i}..."; - ${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null; + ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; echo -e "${OVER} ${INFO} Removed ${i}"; break;; [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; @@ -95,18 +89,13 @@ removeAndPurge() { done else echo -e " ${INFO} Package ${i} not installed" - fi + fi done # Remove dnsmasq config files - ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null + ${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/*-pihole*.conf &> /dev/null echo -e " ${TICK} Removing dnsmasq config files" - # Take care of any additional package cleaning - echo -ne " ${INFO} Removing & cleaning remaining dependencies..." - package_cleanup &> /dev/null - echo -e "${OVER} ${TICK} Removed & cleaned up remaining dependencies" - # Call removeNoPurge to remove Pi-hole specific files removeNoPurge } From f0dfa4d53d375f4e4741f2cbb28730e3609a89fa Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 31 May 2018 13:43:49 +1000 Subject: [PATCH 34/87] Stickler-bot... Signed-Off-By: Rob Gill --- automated install/uninstall.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 51e85946..b8797dbb 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -74,14 +74,13 @@ removeAndPurge() { # Purge dependencies echo "" for i in "${DEPS[@]}"; do - package_check ${i} > /dev/null - if [[ "$?" -eq 0 ]]; then + if package_check "${i}" > /dev/null; then while true; do read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " yn case ${yn} in [Yy]* ) echo -ne " ${INFO} Removing ${i}..."; - ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null; + ${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null; echo -e "${OVER} ${INFO} Removed ${i}"; break;; [Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;; From b60a9fa371147d96bb10382aa58c4e47207017fa Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 1 Jun 2018 07:14:54 +1000 Subject: [PATCH 35/87] merge (#2) * remove package_check to avoid situations like #1760 Signed-off-by: Adam Warner * Prevent redundant entries in to adlists.list Grep ${args[3]} and only add if grep -c -eq 0 Signed-off-by: Ryan Knapper * lan to local Reduced differences. Signed-off-by: Ryan Knapper * Require exact match Updated to require an exact match to reduce false-positives, as suggested by DL6ER. Signed-off-by: Ryan Knapper * fix empty ports on some systems Signed-off-by: Jacob Salmela * debug user locale; improve function to parse variables and files Signed-off-by: Jacob Salmela * Split declaration and population for stickler. Signed-off-by: Dan Schaper * implement dschapers suggestions--better command, less subshells, and finer formatting Signed-off-by: Jacob Salmela * flip uninstall compatability check Signed-off-by: bcambl * Update index.php Avoiding calling empty() on a function allows this to work under PHP5. Making the check for blocklist generation in this way instead is compatible with both PHP5 and PHP7. Signed-off-by: Rob Gill * Update index.php thanks stickler-ci ....... Signed-off-by: Rob Gill * changes as requested changes as requested Signed-off-by: Rob Gill * oh stickler bot... accidentally a space Signed-off-by: Rob Gill * linting: Double quote to prevent globbing and word splitting Signed-off-by: bcambl * unbind resolved on ubuntu 18.04 Stop systemd-resolved from interfering with dnsmasq/ftl Signed-off-by: Rob Gill * restore resolvd.conf If dnsmasq is removed, resolved will need to be restored. Signed-off-by: Rob Gill * Update uninstall.sh Signed-off-by: Rob Gill > * Minor correction for double instance of the word "found". Signed-off-by: RamSet * message text Signed-off-by: Rob Gill > * relocate as function The check for systemd-resolved DNSStubListener, and disabling as necessary is a new function, called just prior to start_service pihole-FTL. The check for ubuntu bionic 18.04 specifically is removed. The check if resolved is enabled is made with check_service_active() An additional check that the dnsstublistener is enabled is made. Signed-off-by: Rob Gill * Regex & case fix grep & sed regexes match commented or uncommented Signed-off-by: Rob Gill * Update basic-install.sh Force reloading of relsolved config where available Signed-off-by: Rob Gill * reload resloved reload resolved config if possible, restart otherwise Signed-off-by: Rob Gill * user-facing messages Signed-off-by: Rob Gill * move & clarify comments --- advanced/Scripts/piholeDebug.sh | 32 ++++++++++++++++++++++------ advanced/Scripts/webpage.sh | 19 +++-------------- advanced/index.php | 4 +++- automated install/basic-install.sh | 34 ++++++++++++++++++++++++++++-- automated install/uninstall.sh | 1 + pihole | 2 +- 6 files changed, 65 insertions(+), 27 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 94ff3fb3..a7fa4c2a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -493,6 +493,13 @@ parse_setup_vars() { fi } +parse_locale() { + local pihole_locale + echo_current_diagnostic "Locale" + pihole_locale="$(locale)" + parse_file "${pihole_locale}" +} + does_ip_match_setup_vars() { # Check for IPv4 or 6 local protocol="${1}" @@ -652,15 +659,22 @@ check_required_ports() { # Sort the addresses and remove duplicates while IFS= read -r line; do ports_in_use+=( "$line" ) - done < <( lsof -i -P -n | awk -F' ' '/LISTEN/ {print $9, $1}' | sort -n | uniq | cut -d':' -f2 ) + done < <( lsof -iTCP -sTCP:LISTEN -P -n +c 10 ) # Now that we have the values stored, for i in "${!ports_in_use[@]}"; do # loop through them and assign some local variables - local port_number - port_number="$(echo "${ports_in_use[$i]}" | awk '{print $1}')" local service_name - service_name=$(echo "${ports_in_use[$i]}" | awk '{print $2}') + service_name=$(echo "${ports_in_use[$i]}" | awk '{print $1}') + local protocol_type + protocol_type=$(echo "${ports_in_use[$i]}" | awk '{print $5}') + local port_number + port_number="$(echo "${ports_in_use[$i]}" | awk '{print $9}')" + + # Skip the line if it's the titles of the columns the lsof command produces + if [[ "${service_name}" == COMMAND ]]; then + continue + fi # Use a case statement to determine if the right services are using the right ports case "${port_number}" in 53) compare_port_to_service_assigned "${resolver}" @@ -670,7 +684,7 @@ check_required_ports() { 4711) compare_port_to_service_assigned "${ftl}" ;; # If it's not a default port that Pi-hole needs, just print it out for the user to see - *) log_write "[${port_number}] is in use by ${service_name}"; + *) log_write "${port_number} ${service_name} (${protocol_type})"; esac done } @@ -879,8 +893,11 @@ parse_file() { # Put the current Internal Field Separator into another variable so it can be restored later OLD_IFS="$IFS" # Get the lines that are in the file(s) and store them in an array for parsing later - IFS=$'\r\n' command eval 'file_info=( $(cat "${filename}") )' - + if [[ -f "$filename" ]]; then + IFS=$'\r\n' command eval 'file_info=( $(cat "${filename}") )' + else + read -a file_info <<< $filename + fi # Set a named variable for better readability local file_lines # For each line in the file, @@ -1193,6 +1210,7 @@ parse_setup_vars check_x_headers analyze_gravity_list show_content_of_pihole_files +parse_locale analyze_pihole_log copy_to_debug_log upload_to_tricorder diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 8a85839f..48161604 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -204,10 +204,6 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423 add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}" fi - if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then - add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_DOMAIN}/${CONDITIONAL_FORWARDING_IP}" - add_dnsmasq_setting "server=/${CONDITIONAL_FORWARDING_REVERSE}/${CONDITIONAL_FORWARDING_IP}" - fi } @@ -237,17 +233,6 @@ SetDNSServers() { else change_setting "DNSSEC" "false" fi - if [[ "${args[6]}" == "conditional_forwarding" ]]; then - change_setting "CONDITIONAL_FORWARDING" "true" - change_setting "CONDITIONAL_FORWARDING_IP" "${args[7]}" - change_setting "CONDITIONAL_FORWARDING_DOMAIN" "${args[8]}" - change_setting "CONDITIONAL_FORWARDING_REVERSE" "${args[9]}" - else - change_setting "CONDITIONAL_FORWARDING" "false" - delete_setting "CONDITIONAL_FORWARDING_IP" - delete_setting "CONDITIONAL_FORWARDING_DOMAIN" - delete_setting "CONDITIONAL_FORWARDING_REVERSE" - fi ProcessDNSSettings @@ -383,7 +368,9 @@ CustomizeAdLists() { elif [[ "${args[2]}" == "disable" ]]; then sed -i "\\@${args[3]}@s/^http/#http/g" "${list}" elif [[ "${args[2]}" == "add" ]]; then - echo "${args[3]}" >> ${list} + if [[ $(grep -c "^${args[3]}$" "${list}") -eq 0 ]] ; then + echo "${args[3]}" >> ${list} + fi elif [[ "${args[2]}" == "del" ]]; then var=$(echo "${args[3]}" | sed 's/\//\\\//g') sed -i "/${var}/Id" "${list}" diff --git a/advanced/index.php b/advanced/index.php index d097fe0f..1575bafc 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -102,8 +102,10 @@ if ($serverName === "pi.hole") { $bpAskAdmin = !empty($svEmail) ? '' : ""; // Determine if at least one block list has been generated -if (empty(glob("/etc/pihole/list.0.*.domains"))) +$blocklistglob = glob("/etc/pihole/list.0.*.domains"); +if ($blocklistglob === array()) { die("[ERROR] There are no domain lists generated lists within /etc/pihole/! Please update gravity by running pihole -g, or repair Pi-hole using pihole -r."); +} // Set location of adlists file if (is_file("/etc/pihole/adlists.list")) { diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3100ce58..3a8fe928 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1265,6 +1265,30 @@ check_service_active() { fi } +# Systemd-resolved's DNSStubListener and dnsmasq can't share port 53. +disable_resolved_stublistener() { + echo -en " ${INFO} Testing if systemd-resolved is enabled" + # Check if Systemd-resolved's DNSStubListener is enabled and active on port 53 + if check_service_active "systemd-resolved"; then + # Check if DNSStubListener is enabled + echo -en " ${OVER} ${INFO} Testing if systemd-resolved DNSStub-Listener is active" + if ( grep -E '#?DNSStubListener=yes' /etc/systemd/resolved.conf &> /dev/null ); then + # Disable the DNSStubListener to unbind it from port 53 + # Note that this breaks dns functionality on host until dnsmasq/ftl are up and running + echo -en "${OVER} ${TICK} Disabling systemd-resolved DNSStubListener" + # Make a backup of the original /etc/systemd/resolved.conf + # (This will need to be restored on uninstallation) + sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf + echo -e " and restarting systemd-resolved" + systemctl reload-or-restart systemd-resolved + else + echo -e "${OVER} ${INFO} Systemd-resolved does not need to be restarted" + fi + else + echo -e "${OVER} ${INFO} Systemd-resolved is not enabled" + fi +} + update_package_cache() { # Running apt-get update/upgrade with minimal output can cause some issues with # requiring user input (e.g password for phpmyadmin see #218) @@ -2290,8 +2314,11 @@ main() { fi fi - echo -e " ${INFO} Restarting services..." - # Start services + # Check for and disable systemd-resolved-DNSStubListener before reloading resolved + # DNSStubListener needs to remain in place for installer to download needed files, + # so this change needs to be made after installation is complete, + # but before starting or resarting the dnsmasq or ftl services + disable_resolved_stublistener # If the Web server was installed, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then @@ -2304,6 +2331,9 @@ main() { fi fi + echo -e " ${INFO} Restarting services..." + # Start services + # Enable FTL start_service pihole-FTL enable_service pihole-FTL diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b8797dbb..44753a59 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -65,6 +65,7 @@ elif [ -x "$(command -v rpm)" ]; then package_check() { rpm -qa | grep "^$1-" > /dev/null } + else echo -e " ${CROSS} OS distribution not supported" exit 1 diff --git a/pihole b/pihole index cb75861b..b3f532af 100755 --- a/pihole +++ b/pihole @@ -232,7 +232,7 @@ Options: # Handle notices if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then - echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} found within block lists" + echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists" exit 0 elif [[ -z "${results[*]}" ]]; then # Result found in WL/BL/Wildcards From f35ea9a3ca65c5cea9c0d9e64a629fc644d23cbe Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 1 Jun 2018 11:57:59 +1000 Subject: [PATCH 36/87] replace code i missed during merge Signed-off-by: Rob Gill --- automated install/uninstall.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b8797dbb..301be4e3 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -88,7 +88,7 @@ removeAndPurge() { done else echo -e " ${INFO} Package ${i} not installed" - fi + fi done # Remove dnsmasq config files @@ -154,6 +154,10 @@ removeNoPurge() { # Remove FTL if command -v pihole-FTL &> /dev/null; then + if [[ -e /etc/systemd/resolved.conf.orig ]]; then + ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf + systemctl reload-or-restart systemd-resolved + fi echo -ne " ${INFO} Removing pihole-FTL..." if [[ -x "$(command -v systemctl)" ]]; then systemctl stop pihole-FTL From cadd0e42447869c73aae3efad0358f510d60046d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 1 Jun 2018 14:03:13 +1000 Subject: [PATCH 37/87] move code back to correct location Signed-off-by: Rob Gill --- automated install/uninstall.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 301be4e3..0a51fd4a 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -152,12 +152,14 @@ removeNoPurge() { ${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null echo -e " ${TICK} Removed config files" + # Restore Resolved + if [[ -e /etc/systemd/resolved.conf.orig ]]; then + ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf + systemctl reload-or-restart systemd-resolved + fi + # Remove FTL if command -v pihole-FTL &> /dev/null; then - if [[ -e /etc/systemd/resolved.conf.orig ]]; then - ${SUDO} cp /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf - systemctl reload-or-restart systemd-resolved - fi echo -ne " ${INFO} Removing pihole-FTL..." if [[ -x "$(command -v systemctl)" ]]; then systemctl stop pihole-FTL From 3be19046538442f977b77f5519b4988d6cf1d422 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 1 Jun 2018 10:20:40 +0200 Subject: [PATCH 38/87] basic-install.sh: fix "install: invalid user ''" refs #1767 --- automated install/basic-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3152d9c1..97e8194b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -57,6 +57,10 @@ IPV6_ADDRESS="" QUERY_LOGGING=true INSTALL_WEB=true +if [ -z "${USER}" ]; then + USER="$(id -un)" +fi + # Find the rows and columns will default to 80x24 if it can not be detected screen_size=$(stty size 2>/dev/null || echo 24 80) From ef17f4913b5444965138179443bbfab2bac30fa2 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 09:39:51 +1000 Subject: [PATCH 39/87] Create pihole.8 Linux man page for pihole Signed-off-by: Rob Gill --- pihole.8 | 326 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) create mode 100644 pihole.8 diff --git a/pihole.8 b/pihole.8 new file mode 100644 index 00000000..d62dbf8a --- /dev/null +++ b/pihole.8 @@ -0,0 +1,326 @@ +.TH "Pi-hole" "8" "Pi-hole" "Pi-hole" "May 2018" +.SH "NAME" + +Pi-hole : A black-hole for internet advertisements +.br +.SH "SYNOPSIS" + +\fBpihole\fR (\fB-w\fR|\fB-b\fR|\fB-wild\fR) [options] domain(s) +.br +\fBpihole -a\fR \fB-p\fR password +.br +\fBpihole -a\fR (-c|-f|-k) +.br +\fBpihole -a\fR [\fB-r\fR hostrecord] +.br +\fBpihole -a -e\fR email +.br +\fBpihole -a -i\fR interface +.br +\fBpihole -a -l\fR privacylevel +.br +\fBpihole -c\fR [-j|-r|-e] +.br +\fBpihole\fR \fB-d\fR [-a] +.br +\fBpihole -f +.br +pihole -r +.br +pihole -t +.br +pihole -g\fR +.br +\fBpihole\fR -\fBq\fR [options] +.br +\fBpihole\fR \fB-l\fR (on|off|off noflush) +.br +\fBpihole -up \fR[--checkonly] +.br +\fBpihole uninstall +.br +pihole status +.br +pihole restartdns\fR +.br +\fBpihole\fR (\fBenable\fR|\fBdisable\fR [time]) +.br +\fBpihole\fR \fBcheckout\fR repo [branch] +.br +\fBpihole\fR \fBhelp\fR +.br +.SH "DESCRIPTION" + +Available commands and options: +.br + +\fB-w, whitelist\fR [options] [ ] +.br + Adds or removes specified domain or domains tho the Whitelist +.br + +\fB-b, blacklist\fR [options] [ ] +.br + Adds or removes specified domain or domains to the blacklist +.br + +\fB-wild, wildcard\fR [options] [ ] +.br + Add or removes specified domain, and all subdomains to the blacklist +.br + +.br + (Whitelist/Blacklist manipulation options): +.br + -d, --delmode Remove domain(s) from the list +.br + -nr, --noreload Update list without refreshing dnsmasq +.br + -q, --quiet Make output less verbose +.br + -l, --list Display all your listed domains +.br + --nuke Removes all entries in a list +.br + +\fB-d, debug\fR [\fB-a\fR] +.br + Start a debugging session Add '-a' to enable automated debugging +.br + +\fB-f, flush\fR +.br + Flush the Pi-hole log +.br + +.br +\fB-r, reconfigure\fR +.br + Reconfigure or Repair Pi-hole subsystems +.br + +\fB-t, tail\fR +.br + View the live output of the Pi-hole log +.br + +\fB-a, admin\fR [options] Console +.br + +.br + (Admin console options): +.br + -p, password Set Admin Console password +.br + -c, celsius Set Celsius as preferred temperature unit +.br + -f, fahrenheit Set Fahrenheit as preferred temperature unit +.br + -k, kelvin Set Kelvin as preferred temperature unit +.br + -r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address +.br + -e, email Set an administrative contact address for the Block Page +.br + -i, interface Specify dnsmasq's interface listening behavior +.br + -l, privacylevel Set privacy level (0 = lowest, 3 = highest) +.br + +.br +\fB-c, chronometer\fR [options] +.br + Calculates stats and displays to an LCD +.br + + (Chronometer Options): +.br + -j, --json Output stats as JSON formatted string +.br + -r, --refresh Set update frequency (in seconds) +.br + -e, --exit Output stats and exit witout refreshing +.br + +\fB-g, updateGravity\fR +.br + Update the list of ad-serving domains +.br + +\fB-q, query\fR [option] +.br + Query the adlists for a specified domain +.br + + (Query options): +.br + -adlist Print the name of the block list URL +.br + -exact Search the block lists for exact domain matches +.br + -all Return all query matches within a block list +.br + +\fB-h, --help, help\fR +.br + Show a help dialog +.br + +\fB-l, logging\fR [on|off|off noflush] +.br + Specify whether the Pi-hole log should be used +.br + + (Logging options): +.br + on Enable the Pi-hole log at /var/log/pihole.log +.br + off Disable and flush the Pi-hole log at /var/log/pihole.log +.br + off noflush Disable the Pi-hole log at /var/log/pihole.log +.br + +.br +\fB-up, updat\fBe\fR\fR\fBPihole\fR [--check-only] +.br + Update Pi-hole subsystems +.br + Add '--check-only' to exit script before update is performed. +.br + +\fB-v, version\fR [repo] [options] +.br + Show installed versions of Pi-hole, Admin Console & FTL +.br + +.br + (repo options): +.br + -p, --pihole Only retrieve info regarding Pi-hole repository +.br + -a, --admin Only retrieve info regarding AdminLTE repository +.br + -f, --ftl Only retrieve info regarding FTL repository +.br + (version options): +.br + -c, --current Return the current version +.br + -l, --latest Return the latest version +.br + --hash Return the Github hash from your local repositories +.br + +\fBuninstall\fR +.br + Uninstall Pi-hole from your system +.br + +\fBstatus\fR +.br + Display the running status of Pi-hole subsystems +.br + +\fBenable\fR +.br + Enable Pi-hole subsystems +.br + +\fBdisable\fR [time] +.br + Disable Pi-hole subsystems, optionally for a set duration +.br + +.br + (time options): +.br + #s Disable Pi-hole functionality for # second(s) +.br + #m Disable Pi-hole functionality for # minute(s) +.br + +\fBrestartdns\fR +.br + Restart Pi-hole subsystems +.br + +\fBcheckout\fR [repo][branch] +.br + Switch Pi-hole subsystems to a different Github branch +.br + + (repo options): +.br + core Change the branch of Pi-hole's core subsystem +.br + web Change the branch of Admin Console subsystem +.br + ftl Change the branch of Pi-hole's FTL subsystem +.br + (branch options): +.br + master Update subsystems to the latest stable release +.br + dev Update subsystems to the latest development release +.br + +.SH "EXAMPLE" +Some usage examples +.br + + Whitelist/blacklist manipulation +.br + + \fBpihole -w iloveads.example.com\fR Add "iloveads.example.com" to whitelist +.br + \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist +.br + \fBpihole -wild ads.example\fR Add "ads.example" as wildcard - would block ads.example.net +.br + + Changing the web ui password +.br + +.br + \fBpihole -a -p ExamplePassword\fR Change the password to "ExamplePassword" +.br + + Updating lists from internet sources +.br + +.br + \fBpihole -g\fR Update the list of ad-serving domains +.br + + Displaying version information +.br + +.br + \fBpihole -v -c\fR Display the current version of AdminLTE +.br + +.br + Temporarily disabling Pi-hole +.br + +.br + \fBpihole disable 5m\fR Disable Pi-hole functionality for five minutes +.br + +.br + Switching Pi-hole subsystem branches +.br + +.br + \fBpihole checkout master\fR Switch to master branch +.br + \fBpihole checkout core dev\fR Switch to core development branch +.br +.SH "SEE ALSO" + +dmasq(8), lighttpd(8) +.br +.SH "COLOPHON" + +Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net. +.br From a8103ca22d1c3de39376809e97f07bff6ba23584 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 09:45:04 +1000 Subject: [PATCH 40/87] Manual page install function Function to install man page. Verifies that man pages are installed, and correct directory for the pihole manpage is present. Copies file, and runs man-db to update man page database. Signed-off-by: Rob Gill --- automated install/basic-install.sh | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43d4b7c2..9b5fde8e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1193,6 +1193,37 @@ installConfigs() { fi } +install_manpage() { + # Copy Pi-hole man page and call mandb to update man page database + # Default location for man files for /usr/local/bin is /usr/local/share/man + # on lightweight systems may not be present, so check before copying. + echo -en " ${INFO} Testing man page installation" + if ! command -v mandb; then + # if mandb is not present, no manpage support + echo -e "${OVER} ${INFO} man not installed" + return + elif [[ ! -d "/usr/local/share/man" ]]; then + # appropriate directory for Pi-hole's man page is not present + echo -e "${OVER} ${INFO} man page not installed" + return + elif [[ ! -d "/usr/local/share/man/man8"]]; then + # if not present, create man8 directory + mkdir /usr/local/share/man/man8 + fi + # Testing complete, copy the file & update the man db + cp ${PI_HOLE_LOCAL_REPO}/pihole.8 /usr/local/share/man/man8/pihole.8 + if mandb -q &>/dev/null; then + # Updated successfully + echo -e "${OVER} ${TICK} man page installed and database updated" + return + else + # Something is wrong with the system's man installation, clean up + # our file, (leave everything how we found it). + rm /usr/local/share/man/man8/pihole.8 + echo -e "${OVER} ${INFO} man page db not updated, man page not installed" + fi +} + stop_service() { # Stop service passed in as argument. # Can softfail, as process may not be installed when this is called @@ -1695,6 +1726,9 @@ installPihole() { configureFirewall fi + # install a man page entry for pihole + install_manpage + # Update setupvars.conf with any variables that may or may not have been changed during the install finalExports } From 999e47a26c28c627836c4b8dd4ea56f8f29f8f80 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 09:50:52 +1000 Subject: [PATCH 41/87] Remove manual page Tests for presence of pihole man page. If it is present, deletes it and runs man-db to rebuild manual database. Signed-off-by: Rob Gill --- automated install/uninstall.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 0a51fd4a..4525f42f 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -171,6 +171,13 @@ removeNoPurge() { echo -e "${OVER} ${TICK} Removed pihole-FTL" fi + # If the pihole manpage exists, then delete and rebuild man-db + if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then + ${SUDO} rm -f /usr/local/share/man/man8/pihole.8 + ${SUDO} mandb -q &>/dev/null + echo -e " ${TICK} Removed pihole man page" + fi + # If the pihole user exists, then remove if id "pihole" &> /dev/null; then if ${SUDO} userdel -r pihole 2> /dev/null; then From a8f0283e93ba8d7dd3ea4cfb6d4361c9523d0d4d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 10:11:11 +1000 Subject: [PATCH 42/87] Update basic-install.sh This hands checking of lighttpd's status over to the existing check_service_active() function. All other checks of service status within the install script are handled by this function. Use of existing function: Avoids duplication of service detection logic. Uses return code to determine status, thereby avoids parsing text to determine status, and reliance on English language locale to determine activity, (which may also be broken on some systems (# 2204) Signed-off-by: Rob Gill --- automated install/basic-install.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 43d4b7c2..fcc66fe1 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2290,15 +2290,13 @@ main() { if [[ "${INSTALL_WEB_SERVER}" == true ]]; then enable_service lighttpd fi - - if [[ -x "$(command -v systemctl)" ]]; then - # Value will either be 1, if true, or 0 - LIGHTTPD_ENABLED=$(systemctl is-enabled lighttpd | grep -c 'enabled' || true) - else - # Value will either be 1, if true, or 0 - LIGHTTPD_ENABLED=$(service lighttpd status | awk '/Loaded:/ {print $0}' | grep -c 'enabled' || true) + # Determin if lighttpd is correctly enabled + if check_service_active "lighttpd"; then + LIGHTTPD_ENABLED=true; + else + LIGHTTPD_ENABLED=false; fi - + # Install and log everything to a file installPihole | tee -a /proc/$$/fd/3 @@ -2327,7 +2325,7 @@ main() { # If the Web server was installed, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then - if [[ "${LIGHTTPD_ENABLED}" == "1" ]]; then + if [[ "${LIGHTTPD_ENABLED}" == true ]]; then start_service lighttpd enable_service lighttpd else From aa191e92021302dca9bc3e0bcba6612f2880c6ec Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 10:46:07 +1000 Subject: [PATCH 43/87] Update basic-install.sh Signed-off-by: Rob Gill --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index fcc66fe1..5e10c9e9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2290,11 +2290,11 @@ main() { if [[ "${INSTALL_WEB_SERVER}" == true ]]; then enable_service lighttpd fi - # Determin if lighttpd is correctly enabled + # Determine if lighttpd is correctly enabled if check_service_active "lighttpd"; then - LIGHTTPD_ENABLED=true; + LIGHTTPD_ENABLED=true else - LIGHTTPD_ENABLED=false; + LIGHTTPD_ENABLED=false fi # Install and log everything to a file From ce5429aba7e7dcfd3260684bbce85f0fe2dc92f2 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 11:02:06 +1000 Subject: [PATCH 44/87] stickler Signed-off-by: Rob Gill --- 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 9b5fde8e..83764a0f 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1206,7 +1206,7 @@ install_manpage() { # appropriate directory for Pi-hole's man page is not present echo -e "${OVER} ${INFO} man page not installed" return - elif [[ ! -d "/usr/local/share/man/man8"]]; then + elif [[ ! -d "/usr/local/share/man/man8" ]]; then # if not present, create man8 directory mkdir /usr/local/share/man/man8 fi From c0837c726fb5ee32354d3ec2d9ac5b9b776f57f4 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 11:18:13 +1000 Subject: [PATCH 45/87] blank space Signed-off-by: Rob Gill --- 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 5e10c9e9..91589914 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2296,7 +2296,7 @@ main() { else LIGHTTPD_ENABLED=false fi - + # Install and log everything to a file installPihole | tee -a /proc/$$/fd/3 From ef65bac79b5b6627b51892d2634149d42ce9a97c Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 11:27:35 +1000 Subject: [PATCH 46/87] change status from INFO to CROSS Signed-Off-By: Rob Gill --- 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 83764a0f..4064ec04 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1220,7 +1220,7 @@ install_manpage() { # Something is wrong with the system's man installation, clean up # our file, (leave everything how we found it). rm /usr/local/share/man/man8/pihole.8 - echo -e "${OVER} ${INFO} man page db not updated, man page not installed" + echo -e "${OVER} ${CROSS} man page db not updated, man page not installed" fi } From d01a568b8bb867beb3304d1af644deaa15e1f269 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 14:13:30 +1000 Subject: [PATCH 47/87] Requested changes (also tabs -> spaces) Signed-off-by: Rob Gill --- pihole.8 | 198 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 102 insertions(+), 96 deletions(-) diff --git a/pihole.8 b/pihole.8 index d62dbf8a..75e3e565 100644 --- a/pihole.8 +++ b/pihole.8 @@ -9,7 +9,7 @@ Pi-hole : A black-hole for internet advertisements .br \fBpihole -a\fR \fB-p\fR password .br -\fBpihole -a\fR (-c|-f|-k) +\fBpihole -a\fR (\fB-c|-f|-k\fR) .br \fBpihole -a\fR [\fB-r\fR hostrecord] .br @@ -33,10 +33,12 @@ pihole -g\fR .br \fBpihole\fR -\fBq\fR [options] .br -\fBpihole\fR \fB-l\fR (on|off|off noflush) +\fBpihole\fR \fB-l\fR (\fBon|off|off noflush\fR) .br \fBpihole -up \fR[--checkonly] .br +\fBpihole -v\fR [-p|-a|-f] [-c|-l|-hash] +.br \fBpihole uninstall .br pihole status @@ -56,269 +58,273 @@ Available commands and options: \fB-w, whitelist\fR [options] [ ] .br - Adds or removes specified domain or domains tho the Whitelist + Adds or removes specified domain or domains tho the Whitelist .br \fB-b, blacklist\fR [options] [ ] .br - Adds or removes specified domain or domains to the blacklist + Adds or removes specified domain or domains to the blacklist .br \fB-wild, wildcard\fR [options] [ ] .br - Add or removes specified domain, and all subdomains to the blacklist -.br - -.br - (Whitelist/Blacklist manipulation options): -.br - -d, --delmode Remove domain(s) from the list -.br - -nr, --noreload Update list without refreshing dnsmasq -.br - -q, --quiet Make output less verbose -.br - -l, --list Display all your listed domains -.br - --nuke Removes all entries in a list + Add or removes specified domain, and all subdomains to the blacklist .br -\fB-d, debug\fR [\fB-a\fR] + (Whitelist/Blacklist manipulation options): .br - Start a debugging session Add '-a' to enable automated debugging + -d, --delmode Remove domain(s) from the list +.br + -nr, --noreload Update list without refreshing dnsmasq +.br + -q, --quiet Make output less verbose +.br + -l, --list Display all your listed domains +.br + --nuke Removes all entries in a list +.br + +\fB-d, debug\fR [-a] +.br + Start a debugging session +.br + + -a Enable automated debugging .br \fB-f, flush\fR .br - Flush the Pi-hole log + Flush the Pi-hole log .br .br \fB-r, reconfigure\fR .br - Reconfigure or Repair Pi-hole subsystems + Reconfigure or Repair Pi-hole subsystems .br \fB-t, tail\fR .br - View the live output of the Pi-hole log + View the live output of the Pi-hole log .br -\fB-a, admin\fR [options] Console +\fB-a, admin\fR [options] .br - + + (Admin options): .br - (Admin console options): + -p, password Set Web Interface password .br - -p, password Set Admin Console password + -c, celsius Set Celsius as preferred temperature unit .br - -c, celsius Set Celsius as preferred temperature unit + -f, fahrenheit Set Fahrenheit as preferred temperature unit .br - -f, fahrenheit Set Fahrenheit as preferred temperature unit + -k, kelvin Set Kelvin as preferred temperature unit .br - -k, kelvin Set Kelvin as preferred temperature unit + -r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address .br - -r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address + -e, email Set an administrative contact address for the Block Page .br - -e, email Set an administrative contact address for the Block Page + -i, interface Specify dnsmasq's interface listening behavior .br - -i, interface Specify dnsmasq's interface listening behavior -.br - -l, privacylevel Set privacy level (0 = lowest, 3 = highest) + -l, privacylevel Set privacy level (0 = lowest, 3 = highest) .br .br \fB-c, chronometer\fR [options] .br - Calculates stats and displays to an LCD + Calculates stats and displays to an LCD .br - (Chronometer Options): + (Chronometer Options): .br - -j, --json Output stats as JSON formatted string + -j, --json Output stats as JSON formatted string .br - -r, --refresh Set update frequency (in seconds) + -r, --refresh Set update frequency (in seconds) .br - -e, --exit Output stats and exit witout refreshing + -e, --exit Output stats and exit witout refreshing .br \fB-g, updateGravity\fR .br - Update the list of ad-serving domains + Update the list of ad-serving domains .br \fB-q, query\fR [option] .br - Query the adlists for a specified domain + Query the adlists for a specified domain .br - (Query options): + (Query options): .br - -adlist Print the name of the block list URL + -adlist Print the name of the block list URL .br - -exact Search the block lists for exact domain matches + -exact Search the block lists for exact domain matches .br - -all Return all query matches within a block list + -all Return all query matches within a block list .br \fB-h, --help, help\fR .br - Show a help dialog + Show a help dialog .br \fB-l, logging\fR [on|off|off noflush] .br - Specify whether the Pi-hole log should be used + Specify whether the Pi-hole log should be used .br (Logging options): .br - on Enable the Pi-hole log at /var/log/pihole.log + on Enable the Pi-hole log at /var/log/pihole.log .br - off Disable and flush the Pi-hole log at /var/log/pihole.log + off Disable and flush the Pi-hole log at /var/log/pihole.log .br - off noflush Disable the Pi-hole log at /var/log/pihole.log + off noflush Disable the Pi-hole log at /var/log/pihole.log .br .br \fB-up, updat\fBe\fR\fR\fBPihole\fR [--check-only] .br - Update Pi-hole subsystems + Update Pi-hole subsystems .br - Add '--check-only' to exit script before update is performed. + + --check-only Exit script before update is performed. .br \fB-v, version\fR [repo] [options] .br - Show installed versions of Pi-hole, Admin Console & FTL + Show installed versions of Pi-hole, Web Interface & FTL .br .br - (repo options): + (repo options): .br - -p, --pihole Only retrieve info regarding Pi-hole repository + -p, --pihole Only retrieve info regarding Pi-hole repository .br - -a, --admin Only retrieve info regarding AdminLTE repository + -a, --admin Only retrieve info regarding AdminLTE repository .br - -f, --ftl Only retrieve info regarding FTL repository + -f, --ftl Only retrieve info regarding FTL repository .br - (version options): + (version options): .br - -c, --current Return the current version + -c, --current Return the current version .br - -l, --latest Return the latest version + -l, --latest Return the latest version .br - --hash Return the Github hash from your local repositories + --hash Return the Github hash from your local repositories .br \fBuninstall\fR .br - Uninstall Pi-hole from your system + Uninstall Pi-hole from your system .br \fBstatus\fR .br - Display the running status of Pi-hole subsystems + Display the running status of Pi-hole subsystems .br \fBenable\fR .br - Enable Pi-hole subsystems + Enable Pi-hole subsystems .br \fBdisable\fR [time] .br - Disable Pi-hole subsystems, optionally for a set duration + Disable Pi-hole subsystems, optionally for a set duration .br .br - (time options): + (time options): .br - #s Disable Pi-hole functionality for # second(s) + #s Disable Pi-hole functionality for # second(s) .br - #m Disable Pi-hole functionality for # minute(s) + #m Disable Pi-hole functionality for # minute(s) .br \fBrestartdns\fR .br - Restart Pi-hole subsystems + Restart Pi-hole subsystems .br \fBcheckout\fR [repo][branch] .br - Switch Pi-hole subsystems to a different Github branch + Switch Pi-hole subsystems to a different Github branch .br - (repo options): + (repo options): .br - core Change the branch of Pi-hole's core subsystem + core Change the branch of Pi-hole's core subsystem .br - web Change the branch of Admin Console subsystem + web Change the branch of Admin Console subsystem .br - ftl Change the branch of Pi-hole's FTL subsystem + ftl Change the branch of Pi-hole's FTL subsystem .br - (branch options): + (branch options): .br - master Update subsystems to the latest stable release + master Update subsystems to the latest stable release .br - dev Update subsystems to the latest development release + dev Update subsystems to the latest development release +.br + branchname Update subsystems to the specified branchname .br - .SH "EXAMPLE" + Some usage examples .br - Whitelist/blacklist manipulation + Whitelist/blacklist manipulation .br - \fBpihole -w iloveads.example.com\fR Add "iloveads.example.com" to whitelist + \fBpihole -w iloveads.example.com\fR Add "iloveads.example.com" to whitelist .br - \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist + \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist .br - \fBpihole -wild ads.example\fR Add "ads.example" as wildcard - would block ads.example.net + \fBpihole -wild example\fR Add "example" as wildcard - would block ads.example.net, example.com etc. .br - Changing the web ui password + Changing the web ui password .br .br - \fBpihole -a -p ExamplePassword\fR Change the password to "ExamplePassword" + \fBpihole -a -p ExamplePassword\fR Change the password to "ExamplePassword" .br - Updating lists from internet sources + Updating lists from internet sources .br .br - \fBpihole -g\fR Update the list of ad-serving domains + \fBpihole -g\fR Update the list of ad-serving domains .br - Displaying version information + Displaying version information .br .br - \fBpihole -v -c\fR Display the current version of AdminLTE + \fBpihole -v -a -c\fR Display the current version of AdminLTE .br .br - Temporarily disabling Pi-hole + Temporarily disabling Pi-hole .br .br - \fBpihole disable 5m\fR Disable Pi-hole functionality for five minutes + \fBpihole disable 5m\fR Disable Pi-hole functionality for five minutes .br .br - Switching Pi-hole subsystem branches + Switching Pi-hole subsystem branches .br .br - \fBpihole checkout master\fR Switch to master branch + \fBpihole checkout master\fR Switch to master branch .br - \fBpihole checkout core dev\fR Switch to core development branch + \fBpihole checkout core dev\fR Switch to core development branch .br .SH "SEE ALSO" -dmasq(8), lighttpd(8) +dnsmasq(8), lighttpd(8) .br .SH "COLOPHON" From 9970f3786fba774db6ebfb087a4c97d28ea91267 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 14:14:55 +1000 Subject: [PATCH 48/87] Requested change Signed-off-by: Rob Gill --- 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 4064ec04..e8b1b9bc 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1198,7 +1198,7 @@ install_manpage() { # Default location for man files for /usr/local/bin is /usr/local/share/man # on lightweight systems may not be present, so check before copying. echo -en " ${INFO} Testing man page installation" - if ! command -v mandb; then + if ! command -v mandb &>/dev/null; then # if mandb is not present, no manpage support echo -e "${OVER} ${INFO} man not installed" return From 213f23aaf6c347e7331b03eb0db16a410efbfac1 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 14:46:45 +1000 Subject: [PATCH 49/87] wildcard & space Signed-off-by: Rob Gill --- pihole.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pihole.8 b/pihole.8 index 75e3e565..76d6b72b 100644 --- a/pihole.8 +++ b/pihole.8 @@ -230,7 +230,7 @@ Available commands and options: Enable Pi-hole subsystems .br -\fBdisable\fR [time] +\fBdisable\fR [time] .br Disable Pi-hole subsystems, optionally for a set duration .br @@ -248,7 +248,7 @@ Available commands and options: Restart Pi-hole subsystems .br -\fBcheckout\fR [repo][branch] +\fBcheckout\fR [repo] [branch] .br Switch Pi-hole subsystems to a different Github branch .br @@ -281,7 +281,7 @@ Some usage examples .br \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist .br - \fBpihole -wild example\fR Add "example" as wildcard - would block ads.example.net, example.com etc. + \fBpihole -wild example.com\fR Add "example.com" as wildcard - would block ads.example.com, www.example.com etc. .br Changing the web ui password From 83ff0055b672eab6d237b65ea88fe60acc96dbf6 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 2 Jun 2018 15:30:51 +1000 Subject: [PATCH 50/87] Test and indicate status This added function tests if pihole-FTL is running when the sysV. Signed-off-by: Rob Gill --- advanced/pihole-FTL.service | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/advanced/pihole-FTL.service b/advanced/pihole-FTL.service index ef8ee9c2..ecc7a52a 100644 --- a/advanced/pihole-FTL.service +++ b/advanced/pihole-FTL.service @@ -69,13 +69,25 @@ stop() { echo } +# Indicate the service status +status() { + if is_running; then + echo "[ ok ] pihole-FTL is running" + exit 0 + else + echo "[ ] pihole-FTL is not running" + exit 1 + fi +} + + ### main logic ### case "$1" in stop) stop ;; status) - status pihole-FTL + status ;; start|restart|reload|condrestart) stop From f5541860bc16b96bf9f8121657d4c054d43c42d5 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 2 Jun 2018 09:56:08 +0100 Subject: [PATCH 51/87] Don't run the installer when doing ftl checkout, instead just run the ftl install functions Signed-off-by: Adam Warner --- advanced/Scripts/piholeCheckout.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeCheckout.sh b/advanced/Scripts/piholeCheckout.sh index 65bb5b7a..5125a2b4 100644 --- a/advanced/Scripts/piholeCheckout.sh +++ b/advanced/Scripts/piholeCheckout.sh @@ -166,6 +166,9 @@ checkout() { if check_download_exists "$path"; then echo " ${TICK} Branch ${2} exists" echo "${2}" > /etc/pihole/ftlbranch + FTLinstall "${binary}" + start_service pihole-FTL + enable_service pihole-FTL else echo " ${CROSS} Requested branch \"${2}\" is not available" ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep 'heads' | sed 's/refs\/heads\///;s/ //g' | awk '{print $2}') ) @@ -180,7 +183,7 @@ checkout() { fi # Force updating everything - if [[ ! "${1}" == "web" ]]; then + if [[ ! "${1}" == "web" && ! "${1}" == "ftl" ]]; then echo -e " ${INFO} Running installer to upgrade your installation" if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then exit 0 From ed7ebfd58df4192876e7d6fc4ecc96d2897c9470 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sun, 3 Jun 2018 22:15:26 +1000 Subject: [PATCH 52/87] man page for pihole-FTL Signed-off-by: Rob Gill --- automated install/basic-install.sh | 25 +++++--- automated install/uninstall.sh | 2 +- manpages/pihole-FTL.8 | 94 ++++++++++++++++++++++++++++++ manpages/pihole-FTL.conf.5 | 74 +++++++++++++++++++++++ pihole.8 => manpages/pihole.8 | 65 +++++++++------------ 5 files changed, 212 insertions(+), 48 deletions(-) create mode 100644 manpages/pihole-FTL.8 create mode 100644 manpages/pihole-FTL.conf.5 rename pihole.8 => manpages/pihole.8 (90%) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 325688cd..8181bcb7 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1194,7 +1194,7 @@ installConfigs() { } install_manpage() { - # Copy Pi-hole man page and call mandb to update man page database + # Copy Pi-hole man pages and call mandb to update man page database # Default location for man files for /usr/local/bin is /usr/local/share/man # on lightweight systems may not be present, so check before copying. echo -en " ${INFO} Testing man page installation" @@ -1204,23 +1204,30 @@ install_manpage() { return elif [[ ! -d "/usr/local/share/man" ]]; then # appropriate directory for Pi-hole's man page is not present - echo -e "${OVER} ${INFO} man page not installed" + echo -e "${OVER} ${INFO} man pages not installed" return - elif [[ ! -d "/usr/local/share/man/man8" ]]; then + fi + if [[ ! -d "/usr/local/share/man/man8" ]]; then # if not present, create man8 directory mkdir /usr/local/share/man/man8 fi - # Testing complete, copy the file & update the man db - cp ${PI_HOLE_LOCAL_REPO}/pihole.8 /usr/local/share/man/man8/pihole.8 + if [[ ! -d "/usr/local/share/man/man5" ]]; then + # if not present, create man8 directory + mkdir /usr/local/share/man/man5 + fi + # Testing complete, copy the files & update the man db + cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole.8 /usr/local/share/man/man8/pihole.8 + cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole-FTL.8 /usr/local/share/man/man8/pihole-FTL.8 + cp ${PI_HOLE_LOCAL_REPO}/manpages/pihole-FTL.conf.5 /usr/local/share/man/man5/pihole-FTL.conf.5 if mandb -q &>/dev/null; then # Updated successfully - echo -e "${OVER} ${TICK} man page installed and database updated" + echo -e "${OVER} ${TICK} man pages installed and database updated" return else # Something is wrong with the system's man installation, clean up - # our file, (leave everything how we found it). - rm /usr/local/share/man/man8/pihole.8 - echo -e "${OVER} ${CROSS} man page db not updated, man page not installed" + # our files, (leave everything how we found it). + rm /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5 + echo -e "${OVER} ${CROSS} man page db not updated, man pages not installed" fi } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 4525f42f..9322de92 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -173,7 +173,7 @@ removeNoPurge() { # If the pihole manpage exists, then delete and rebuild man-db if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then - ${SUDO} rm -f /usr/local/share/man/man8/pihole.8 + ${SUDO} rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5 ${SUDO} mandb -q &>/dev/null echo -e " ${TICK} Removed pihole man page" fi diff --git a/manpages/pihole-FTL.8 b/manpages/pihole-FTL.8 new file mode 100644 index 00000000..b11f00de --- /dev/null +++ b/manpages/pihole-FTL.8 @@ -0,0 +1,94 @@ +.TH "Pihole-FTL" "8" "pihole-FTL" "Pi-hole" "June 2018" +.SH "NAME" +pihole-FTL - Pi-hole : The Faster-Than-Light (FTL) Engine +.br +.SH "SYNOPSIS" +\fBservice pihole-FTL \fR(\fBstart\fR|\fBstop\fR|\fBrestart\fR) +.br + +\fBpihole-FTL debug\fR +.br +\fBpihole-FTL test\fR +.br +\fBpihole-FTL -v\fR +.br +\fBpihole-FTL -t\fR +.br +\fBpihole-FTL -b\fR +.br +\fBpihole-FTL -f\fR +.br +\fBpihole-FTL dnsmasq-test\fR +.br + +.SH "DESCRIPTION" +Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery\fR \fIquickly\fR! +.br + +Usage +.br + +\fB\fBservi\fRce pihole-FTL start\fR +.br + Start the pihole-FTL daemon +.br + +\fBservice pihole-FTL stop\fR +.br + Stop the pihole-FTL daemon +.br + +\fBservice pihole-FTL restart\fR +.br + If the pihole-FTP daemon is running, stop and then start, otherwise start. +.br + +Command line arguments +.br + +\fBdebug\fR +.br + Don't go into daemon mode (stay in foreground) + more verbose logging +.br + +\fBtest\fR +.br + Start FTL and process everything, but shut down immediately afterwards +.br + +\fB-v, version\fR +.br + Don't start FTL, show only version +.br + +\fB-t, tag\fR +.br + Don't start FTL, show only git tag +.br + +\fB-b, branch\fR +.br + Don't start FTL, show only git branch FTL was compiled from +.br + +\fB-f, no-daemon\fR +.br + Don't go into background (daemon mode) +.br + +\fB-h, help\fR +.br + Don't start FTL, show help +.br +.SH "EXAMPLE" +Command line arguments can be arbitrarily combined, e.g: +.br + +\fBpihole-FTL debug test\fR +.br + +Start ftl in foreground with more verbose logging, process everything and shutdown immediately +.br +.SH "SEE ALSO" +\fBpihole\fR(8), \fBpihole-FTL.conf\fR(5) +.br diff --git a/manpages/pihole-FTL.conf.5 b/manpages/pihole-FTL.conf.5 new file mode 100644 index 00000000..1db71ace --- /dev/null +++ b/manpages/pihole-FTL.conf.5 @@ -0,0 +1,74 @@ +.TH "pihole-FTL.conf" "5" "pihole-FTL.conf" "pihole-FTL.conf" "June 2018" +.SH "NAME" + +pihole-FTL.conf - FTL's config file +.br +.SH "DESCRIPTION" + +/etc/pihole/pihole-FTL.conf will be read by \fBpihole-FTL(8)\fR on startup. +.br + +SOCKET_LISTENING=localonly|all +.br + Listen only for local socket connections or permit all connections +.br + +QUERY_DISPLAY=yes|no +.br + Display all queries? Set to no to hide query display +.br + +AAAA_QUERY_ANALYSIS=yes|no +.br + Allow FTL to analyze AAAA queries from pihole.log? +.br + +MAXDBDAYS=365 +.br + How long should queries be stored in the database? +.br + Setting this to 0 disables the database altogether +.br + +RESOLVE_IPV6=yes|no +.br + Should FTL try to resolve IPv6 addresses to host names? +.br + +RESOLVE_IPV4=yes|no +.br + Should FTL try to resolve IPv4 addresses to host names? +.br + +DBINTERVAL=1.0 +.br + How often do we store queries in FTL's database [minutes]? +.br + +DBFILE=/etc/pihole/pihole-FTL.db +.br + Specify path and filename of FTL's SQLite long-term database. +.br + Setting this to DBFILE= disables the database altogether +.br + +MAXLOGAGE=24.0 +.br + Up to how many hours of queries should be imported from the database and logs? +.br + Maximum is 744 (31 days) +.br + +For each setting, the option shown first is the default. +.br +.SH "SEE ALSO" + +\fBpihole\fR(8), \fBpihole-FTL\fR(8) +.br +.SH "COLOPHON" + +Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery quickly\fR! +.br + +Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net +.br diff --git a/pihole.8 b/manpages/pihole.8 similarity index 90% rename from pihole.8 rename to manpages/pihole.8 index 76d6b72b..fc719ffb 100644 --- a/pihole.8 +++ b/manpages/pihole.8 @@ -21,13 +21,13 @@ Pi-hole : A black-hole for internet advertisements .br \fBpihole -c\fR [-j|-r|-e] .br -\fBpihole\fR \fB-d\fR [-a] +\fBpihole\fR \fB-d\fR [-a] .br \fBpihole -f .br pihole -r .br -pihole -t +pihole -t .br pihole -g\fR .br @@ -84,9 +84,9 @@ Available commands and options: --nuke Removes all entries in a list .br -\fB-d, debug\fR [-a] +\fB-d, debug\fR [-a] .br - Start a debugging session + Start a debugging session .br -a Enable automated debugging @@ -96,8 +96,7 @@ Available commands and options: .br Flush the Pi-hole log .br - -.br + \fB-r, reconfigure\fR .br Reconfigure or Repair Pi-hole subsystems @@ -129,11 +128,10 @@ Available commands and options: .br -l, privacylevel Set privacy level (0 = lowest, 3 = highest) .br - -.br + \fB-c, chronometer\fR [options] .br - Calculates stats and displays to an LCD + Calculates stats and displays to an LCD .br (Chronometer Options): @@ -145,12 +143,12 @@ Available commands and options: -e, --exit Output stats and exit witout refreshing .br -\fB-g, updateGravity\fR +\fB-g, updateGravity\fR .br Update the list of ad-serving domains .br -\fB-q, query\fR [option] +\fB-q, query\fR [option] .br Query the adlists for a specified domain .br @@ -164,7 +162,7 @@ Available commands and options: -all Return all query matches within a block list .br -\fB-h, --help, help\fR +\fB-h, --help, help\fR .br Show a help dialog .br @@ -178,21 +176,20 @@ Available commands and options: .br on Enable the Pi-hole log at /var/log/pihole.log .br - off Disable and flush the Pi-hole log at /var/log/pihole.log + off Disable and flush the Pi-hole log at /var/log/pihole.log .br off noflush Disable the Pi-hole log at /var/log/pihole.log .br - + +\fB-up, updat\fBe\fR\fR\fBPihole\fR [--check-only] .br -\fB-up, updat\fBe\fR\fR\fBPihole\fR [--check-only] -.br - Update Pi-hole subsystems + Update Pi-hole subsystems .br --check-only Exit script before update is performed. .br -\fB-v, version\fR [repo] [options] +\fB-v, version\fR [repo] [options] .br Show installed versions of Pi-hole, Web Interface & FTL .br @@ -234,8 +231,7 @@ Available commands and options: .br Disable Pi-hole subsystems, optionally for a set duration .br - -.br + (time options): .br #s Disable Pi-hole functionality for # second(s) @@ -248,7 +244,7 @@ Available commands and options: Restart Pi-hole subsystems .br -\fBcheckout\fR [repo] [branch] +\fBcheckout\fR [repo] [branch] .br Switch Pi-hole subsystems to a different Github branch .br @@ -281,50 +277,43 @@ Some usage examples .br \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist .br - \fBpihole -wild example.com\fR Add "example.com" as wildcard - would block ads.example.com, www.example.com etc. + \fB\fBpihole -wild example\fR.com\fR Add "example" as wildcard - would block ads.example.com, www.example.com etc. .br - Changing the web ui password -.br - + Changing the Web Interface password .br + \fBpihole -a -p ExamplePassword\fR Change the password to "ExamplePassword" .br Updating lists from internet sources .br - -.br + \fBpihole -g\fR Update the list of ad-serving domains .br Displaying version information .br - -.br + \fBpihole -v -a -c\fR Display the current version of AdminLTE .br - -.br + Temporarily disabling Pi-hole .br - -.br + \fBpihole disable 5m\fR Disable Pi-hole functionality for five minutes .br - -.br + Switching Pi-hole subsystem branches .br - -.br + \fBpihole checkout master\fR Switch to master branch .br \fBpihole checkout core dev\fR Switch to core development branch .br .SH "SEE ALSO" -dnsmasq(8), lighttpd(8) +\fBlighttpd\fR(8), \fBpihole-FTL\fR(8) .br .SH "COLOPHON" From 3149a95d6ac98154cedde481bafcf92f05a8a6e1 Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Sun, 3 Jun 2018 13:33:33 -0400 Subject: [PATCH 53/87] Fix gravity_ParseFileIntoDomains Awk comment Signed-off-by: Mark Drobnak --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 58419029..dfcb753a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -277,9 +277,9 @@ gravity_ParseFileIntoDomains() { # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth - #Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only. - #Last awk command takes non-commented lines and if they have 2 fields, take the left field (the domain) and leave - #+ the right (IP address), otherwise grab the single field. + # Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only. + # Last awk command takes non-commented lines and if they have 2 fields, take the right field (the domain) and leave + # the left (IP address), otherwise grab the single field. < ${source} awk -F '#' '{print $1}' | \ awk -F '/' '{print $1}' | \ From 49fb4421dd10d491e1bae7998e86e52cc2c49bce Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 4 Jun 2018 09:54:53 +1000 Subject: [PATCH 54/87] Requested changes to manpages - now align with docs.pi-hole.net/ftldns. weird bolding issues fixed Signed-off-by: Rob Gill --- manpages/pihole-FTL.8 | 20 ++++++++++++++- manpages/pihole-FTL.conf.5 | 50 ++++++++++++++++++++++++++------------ manpages/pihole.8 | 4 +-- 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/manpages/pihole-FTL.8 b/manpages/pihole-FTL.8 index b11f00de..812801a4 100644 --- a/manpages/pihole-FTL.8 +++ b/manpages/pihole-FTL.8 @@ -18,8 +18,12 @@ pihole-FTL - Pi-hole : The Faster-Than-Light (FTL) Engine .br \fBpihole-FTL -f\fR .br +\fBpihole-FTL -h\fR +.br \fBpihole-FTL dnsmasq-test\fR .br +\fBpihole-FTL --\fR (\fBoptions\fR) +.br .SH "DESCRIPTION" Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built daemon used to provide statistics needed for the Pi-hole Web Interface, and its API can be easily integrated into your own projects. Although it is an optional component of the Pi-hole ecosystem, it will be installed by default to provide statistics. As the name implies, FTL does its work \fIvery\fR \fIquickly\fR! @@ -28,7 +32,7 @@ Pi-hole : The Faster-Than-Light (FTL) Engine is a lightweight, purpose-built dae Usage .br -\fB\fBservi\fRce pihole-FTL start\fR +\fBservice pihole-FTL start\fR .br Start the pihole-FTL daemon .br @@ -80,6 +84,16 @@ Command line arguments .br Don't start FTL, show help .br + +\fBdnsmasq-test\fR +.br + Test resolver config file syntax +.br + +\fB--\fR (options) +.br + Pass options to internal resolver +.br .SH "EXAMPLE" Command line arguments can be arbitrarily combined, e.g: .br @@ -92,3 +106,7 @@ Start ftl in foreground with more verbose logging, process everything and shutdo .SH "SEE ALSO" \fBpihole\fR(8), \fBpihole-FTL.conf\fR(5) .br +.SH "COLOPHON" + +Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net +.br diff --git a/manpages/pihole-FTL.conf.5 b/manpages/pihole-FTL.conf.5 index 1db71ace..b99a6c1d 100644 --- a/manpages/pihole-FTL.conf.5 +++ b/manpages/pihole-FTL.conf.5 @@ -8,57 +8,77 @@ pihole-FTL.conf - FTL's config file /etc/pihole/pihole-FTL.conf will be read by \fBpihole-FTL(8)\fR on startup. .br -SOCKET_LISTENING=localonly|all +\fBSOCKET_LISTENING=localonly|all\fR .br Listen only for local socket connections or permit all connections .br -QUERY_DISPLAY=yes|no +\fBQUERY_DISPLAY=yes|no\fR .br Display all queries? Set to no to hide query display .br -AAAA_QUERY_ANALYSIS=yes|no +\fBAAAA_QUERY_ANALYSIS=yes|no\fR .br Allow FTL to analyze AAAA queries from pihole.log? .br -MAXDBDAYS=365 -.br - How long should queries be stored in the database? -.br - Setting this to 0 disables the database altogether -.br - -RESOLVE_IPV6=yes|no +\fBRESOLVE_IPV6=yes|no\fR .br Should FTL try to resolve IPv6 addresses to host names? .br -RESOLVE_IPV4=yes|no +\fBRESOLVE_IPV4=yes|no\fR .br Should FTL try to resolve IPv4 addresses to host names? .br -DBINTERVAL=1.0 +\fBMAXDBDAYS=365\fR +.br + How long should queries be stored in the database? +.br + Setting this to 0 disables the database +.br + +\fBDBINTERVAL=1.0\fR .br How often do we store queries in FTL's database [minutes]? .br -DBFILE=/etc/pihole/pihole-FTL.db +\fBDBFILE=/etc/pihole/pihole-FTL.db\fR .br Specify path and filename of FTL's SQLite long-term database. .br Setting this to DBFILE= disables the database altogether .br -MAXLOGAGE=24.0 +\fBMAXLOGAGE=24.0\fR .br Up to how many hours of queries should be imported from the database and logs? .br Maximum is 744 (31 days) .br +\fBFTLPORT=4711\fR +.br + On which port should FTL be listening? +.br + +\fBPRIVACYLEVEL=0|1|2|3\fR +.br + Which privacy level is used? +.br + +\fBIGNORE_LOCALHOST=no|yes\fR +.br + Should FTL ignore queries coming from the local machine? +.br + +\fBBLOCKINGMODE=IP|IP-AAAA-NODATA|NXDOMAIN|NULL\fR +.br + How should FTL reply to blocked queries? +.br + For each setting, the option shown first is the default. .br .SH "SEE ALSO" diff --git a/manpages/pihole.8 b/manpages/pihole.8 index fc719ffb..54bf4a31 100644 --- a/manpages/pihole.8 +++ b/manpages/pihole.8 @@ -181,7 +181,7 @@ Available commands and options: off noflush Disable the Pi-hole log at /var/log/pihole.log .br -\fB-up, updat\fBe\fR\fR\fBPihole\fR [--check-only] +\fB-up, updatePihole\fR [--check-only] .br Update Pi-hole subsystems .br @@ -277,7 +277,7 @@ Some usage examples .br \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist .br - \fB\fBpihole -wild example\fR.com\fR Add "example" as wildcard - would block ads.example.com, www.example.com etc. + \fBpihole -wild example.com\fR Add "example.com" as wildcard - would block ads.example.com, www.example.com etc. .br Changing the Web Interface password From 40bc390c3bd84893cbc5f54cffe020bcceec3d57 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 4 Jun 2018 13:34:42 +1000 Subject: [PATCH 55/87] Admin Console -> "Web Interface" User facing --help text changes Admin Console --> Web Interface and additional branch option Signed-Off-By: Rob Gill --- pihole | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pihole b/pihole index b3f532af..c125d0d9 100755 --- a/pihole +++ b/pihole @@ -541,12 +541,13 @@ Switch Pi-hole subsystems to a different Github branch Repositories: core [branch] Change the branch of Pi-hole's core subsystem - web [branch] Change the branch of Admin Console subsystem + web [branch] Change the branch of Web Interface subsystem ftl [branch] Change the branch of Pi-hole's FTL subsystem Branches: master Update subsystems to the latest stable release - dev Update subsystems to the latest development release" + dev Update subsystems to the latest development release + branchname Update subsystems to the specified branchname" exit 0 fi @@ -610,8 +611,8 @@ Debugging Options: -t, tail View the live output of the Pi-hole log Options: - -a, admin Admin Console options - Add '-h' for more info on admin console usage + -a, admin Web interface options + Add '-h' for more info on Web Interface usage -c, chronometer Calculates stats and displays to an LCD Add '-h' for more info on chronometer usage -g, updateGravity Update the list of ad-serving domains @@ -622,7 +623,7 @@ Options: Add '-h' for more info on query usage -up, updatePihole Update Pi-hole subsystems Add '--check-only' to exit script before update is performed. - -v, version Show installed versions of Pi-hole, Admin Console & FTL + -v, version Show installed versions of Pi-hole, Web Interface & FTL Add '-h' for more info on version usage uninstall Uninstall Pi-hole from your system status Display the running status of Pi-hole subsystems From a11e5e2debac1efde56b8e00ca7a439d73329a56 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 10:23:23 +1000 Subject: [PATCH 56/87] dnsmasq Signed-off-by: Rob Gill --- manpages/pihole-FTL.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manpages/pihole-FTL.8 b/manpages/pihole-FTL.8 index 812801a4..2928f2d8 100644 --- a/manpages/pihole-FTL.8 +++ b/manpages/pihole-FTL.8 @@ -92,7 +92,7 @@ Command line arguments \fB--\fR (options) .br - Pass options to internal resolver + Pass options to internal dnsmasq resolver .br .SH "EXAMPLE" Command line arguments can be arbitrarily combined, e.g: From 4188fb536e1fd78914ffb22de923a8e2cf2c9393 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 10:25:51 +1000 Subject: [PATCH 57/87] Privacy levels Signed-off-by: Rob Gill --- manpages/pihole-FTL.conf.5 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manpages/pihole-FTL.conf.5 b/manpages/pihole-FTL.conf.5 index b99a6c1d..50536279 100644 --- a/manpages/pihole-FTL.conf.5 +++ b/manpages/pihole-FTL.conf.5 @@ -68,6 +68,14 @@ pihole-FTL.conf - FTL's config file .br Which privacy level is used? .br + 0 - show everything +.br + 1 - hide domains +.br + 2 - hide domains and clients +.br + 3 - paranoia mode (hide everything) +.br \fBIGNORE_LOCALHOST=no|yes\fR .br From 7398a9ebf937cadeb3f47537684ed60facce5ffe Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 4 Jun 2018 19:59:23 -0500 Subject: [PATCH 58/87] remove projects that are not compliant with our trademarks Signed-off-by: Jacob Salmela --- README.md | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 60c54f87..40a9254f 100644 --- a/README.md +++ b/README.md @@ -178,32 +178,13 @@ Pi-hole being a **advertising-aware DNS/Web server**, makes use of the following * [AdminLTE Dashboard](https://github.com/almasaeed2010/AdminLTE) - premium admin control panel based on Bootstrap 3.x While quite outdated at this point, [this original blog post about Pi-hole](https://jacobsalmela.com/2015/06/16/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0/) goes into **great detail** about how Pi-hole was originally setup and how it works. Syntactically, it's no longer accurate, but the same basic principles and logic still apply to Pi-hole's current state. - ------ - -## Pi-hole Projects -- [The Big Blocklist Collection](https://wally3k.github.io) -- [Docker Pi-hole container (x86 and ARM)](https://hub.docker.com/r/diginc/pi-hole/) -- [Pi-Hole in the cloud](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/) -- [Pie in the Sky-Hole [A Pi-Hole in the cloud for ad-blocking via DNS]](https://dlaa.me/blog/post/skyhole) -- [Pi-hole Enable/Disable Button](http://thetimmy.silvernight.org/pages/endisbutton/) -- [Minibian Pi-hole](https://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) -- [CHiP-hole: Network-wide Ad-blocker](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037) -- [Chrome Extension: Pi-Hole List Editor](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([Source Code](https://github.com/packtloss/pihole-extension)) -- [Splunk: Pi-hole Visualiser](https://splunkbase.splunk.com/app/3023/) -- [Adblocking with Pi-hole and Ubuntu 14.04 on VirtualBox](https://hbalagtas.blogspot.com.au/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) -- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py) -- [Pi-hole unRAID Template](https://forums.lime-technology.com/topic/36810-support-spants-nodered-mqtt-dashing-couchdb/) -- [Copernicus: Windows Tray Application](https://github.com/goldbattle/copernicus) -- [Let your blink1 device blink when Pi-hole filters ads](https://gist.github.com/elpatron68/ec0b4c582e5abf604885ac1e068d233f) -- [Pi-hole metrics](https://github.com/nlamirault/pihole_exporter) exporter for [Prometheus](https://prometheus.io/) -- [Magic Mirror with DNS Filtering](https://zonksec.com/blog/magic-mirror-dns-filtering/#dnssoftware) -- [Pi-hole Droid: Android client](https://github.com/friimaind/pi-hole-droid) -- [Windows DNS Swapper](https://github.com/roots84/DNS-Swapper), see [#1400](https://github.com/pi-hole/pi-hole/issues/1400) -- [Pi-hole Visualizer](https://www.reddit.com/r/pihole/comments/82ikgb/pihole_visualizer_update/) ----- ## Coverage +- [Software Engineering Daily: Interview with the creator of Pi-hole](https://softwareengineeringdaily.com/2018/05/29/pi-hole-ad-blocker-hardware-with-jacob-salmela/) +- [Bloomberg Business Week: Brotherhood of the Ad blockers](https://www.bloomberg.com/news/features/2018-05-10/inside-the-brotherhood-of-pi-hole-ad-blockers) +- [Securing DNS across all of my devices with Pi-Hole + DNS-over-HTTPS + 1.1.1.1](https://scotthelme.co.uk/securing-dns-across-all-of-my-devices-with-pihole-dns-over-https-1-1-1-1/) +- [Adafruit: installing Pi-hole on a Pi Zero W](https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w/install-pi-hole) - [Lifehacker: Turn A Raspberry Pi Into An Ad Blocker With A Single Command](https://www.lifehacker.com.au/2015/02/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-command/) - [MakeUseOf: Adblock Everywhere: The Raspberry Pi-Hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) - [Catchpoint: Ad-Blocking on Apple iOS9: Valuing the End User Experience](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) @@ -222,3 +203,12 @@ While quite outdated at this point, [this original blog post about Pi-hole](http - [CryptoAUSTRALIA: How We Tried 5 Privacy Focused Raspberry Pi Projects](https://blog.cryptoaustralia.org.au/2017/10/05/5-privacy-focused-raspberry-pi-projects/) - [CryptoAUSTRALIA: Pi-hole Workshop](https://blog.cryptoaustralia.org.au/2017/11/02/pi-hole-network-wide-ad-blocker/) - [Know How 355: Killing ads with a Raspberry Pi-Hole!](https://www.twit.tv/shows/know-how/episodes/355) + +----- + +## Pi-hole Projects +- [The Big Blocklist Collection](https://wally3k.github.io) +- [Pie in the Sky-Hole](https://dlaa.me/blog/post/skyhole) +- [Copernicus: Windows Tray Application](https://github.com/goldbattle/copernicus) +- [Magic Mirror with DNS Filtering](https://zonksec.com/blog/magic-mirror-dns-filtering/#dnssoftware) +- [Windows DNS Swapper](https://github.com/roots84/DNS-Swapper) From 35ca54d98f7760e329f11b133431d3bef96623a7 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Mon, 4 Jun 2018 20:00:26 -0500 Subject: [PATCH 59/87] add patreon and adjust affiliate links Signed-off-by: Jacob Salmela --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 40a9254f..77f259e6 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,11 @@ Sending a donation using our links below is **extremely helpful** in offsetting ### Alternative support If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us: - +- [Patreon](https://patreon.com/pihole) _Become a patron for rewards_ - [Digital Ocean](http://www.digitalocean.com/?refcode=344d234950e1) _affiliate link_ - [UNIXstickers.com](http://unixstickers.refr.cc/jacobs) _save $5 when you spend $9 using our affiliate link_ - [Pi-hole Swag Store](https://pi-hole.net/shop/) _affiliate link_ - [Amazon](http://www.amazon.com/exec/obidos/redirect-home/pihole09-20) _affiliate link_ -- [Ho-ost](https://clients.ho-ost.com/aff.php?aff=19) _save 50% with our affiliate link_ - [DNS Made Easy](https://cp.dnsmadeeasy.com/u/133706) _affiliate link_ - [Vultr](http://www.vultr.com/?ref=7190426) _affiliate link_ - Spreading the word about our software, and how you have benefited from it @@ -99,9 +98,6 @@ While we are primarily reachable on our Frequently Asked Questions
  • Pi-hole Wiki
  • Feature Requests
  • - -
    -
    • Discourse User Forum
    • Reddit
    • Gitter (Real-time chat)
    • From 9422d57283e0d9f0c5413c1d10cc644f7a22d5ab Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 12:08:27 +1000 Subject: [PATCH 60/87] Check version of installed php Signed-off-by: Rob Gill --- automated install/basic-install.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 395a6203..4cd1e9aa 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -160,13 +160,27 @@ if command -v apt-get &> /dev/null; then # use iproute iproute_pkg="iproute" fi - # We prefer the php metapackage if it's there - if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then - phpVer="php" - # If not, - else + # Check for and determine version number, major and minor of current php install + if command -v php &> /dev/null; then + phpInsVersion="$(php -v | head -n1 | grep -Po '(? /dev/null 2>&1; then + phpVer="php" # fall back on the php5 packages - phpVer="php5" + else + phpVer="php5" + fi + else + # Supported php is installed, its common, cgi & sqlite counterparts are deps + phpInsMajor="$(echo $phpInsVer | cut -d\. -f1)" + phpInsMinor="$(echo $phpInsVer | cut -d\. -f2)" + phpVer="php$phpInsMajor.phpInsMinor" + fi + fi # We also need the correct version for `php-sqlite` (which differs across distros) if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then From 7181d7ae6a87dda776ca3579fc6dcbb00ca5948d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 14:30:18 +1000 Subject: [PATCH 61/87] Left that fi Signed-off-by: Rob Gill --- 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 4cd1e9aa..f3f76bd3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -180,8 +180,6 @@ if command -v apt-get &> /dev/null; then phpInsMinor="$(echo $phpInsVer | cut -d\. -f2)" phpVer="php$phpInsMajor.phpInsMinor" fi - - fi # We also need the correct version for `php-sqlite` (which differs across distros) if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then phpSqlite="sqlite3" From 714b6c98ef6da478eb46adab9ff34c1b50a6ba09 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 14:45:01 +1000 Subject: [PATCH 62/87] codacy Signed-off-by: Rob Gill --- 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 f3f76bd3..4c26f1a9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -176,8 +176,8 @@ if command -v apt-get &> /dev/null; then fi else # Supported php is installed, its common, cgi & sqlite counterparts are deps - phpInsMajor="$(echo $phpInsVer | cut -d\. -f1)" - phpInsMinor="$(echo $phpInsVer | cut -d\. -f2)" + phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)" + phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)" phpVer="php$phpInsMajor.phpInsMinor" fi # We also need the correct version for `php-sqlite` (which differs across distros) From 36dbdf955d7ef06cefcdb4eed22c3bf617216172 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 14:48:24 +1000 Subject: [PATCH 63/87] Update basic-install.sh Signed-off-by: Rob Gill --- 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 4c26f1a9..481e26db 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -178,7 +178,7 @@ if command -v apt-get &> /dev/null; then # Supported php is installed, its common, cgi & sqlite counterparts are deps phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)" phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)" - phpVer="php$phpInsMajor.phpInsMinor" + phpVer="php$phpInsMajor.$phpInsMinor" fi # We also need the correct version for `php-sqlite` (which differs across distros) if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then From 13b8e1a2aea2e1d0b57c32ce3d620b407c870d84 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 15:09:07 +1000 Subject: [PATCH 64/87] quotes. Signed-off-by: Rob Gill --- 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 481e26db..a4869d24 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -166,7 +166,7 @@ if command -v apt-get &> /dev/null; then echo -e " ${INFO} Existing PHP installation detected : PHP version $phpInsVersion" fi # Check if installed php is supported version (5.4 is EOL) - if [[ $phpInsVersion < "5.5" ]]; then + if [[ "$phpInsVersion" < "5.5" ]]; then # Prefer the php metapackage if it's there if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then phpVer="php" From 7f81cfd45a50476e9654b76f9c4a0393841b75c6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 5 Jun 2018 09:09:35 +0100 Subject: [PATCH 65/87] Stats can still be generated without logging, no need for this sentence Signed-off-by: Adam Warner --- 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 395a6203..3d9a902a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -977,7 +977,7 @@ setLogging() { local LogChoices # Ask if the user wants to log queries - LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?\\n (Disabling will render graphs on the Admin page useless):" ${r} ${c} 6) + LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?" ${r} ${c} 6) # The default selection is on LogChooseOptions=("On (Recommended)" "" on Off "" off) From f2f6b6ede9fedf26a0a7b56f365746b7fdaaf14a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 5 Jun 2018 09:29:03 +0100 Subject: [PATCH 66/87] stickler complaints Signed-off-by: Adam Warner --- 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 3d9a902a..3d2e5784 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -977,7 +977,7 @@ setLogging() { local LogChoices # Ask if the user wants to log queries - LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?" ${r} ${c} 6) + LogToggleCommand=(whiptail --separate-output --radiolist "Do you want to log queries?" "${r}" "${c}" 6) # The default selection is on LogChooseOptions=("On (Recommended)" "" on Off "" off) From a3569d88c95ed2dae32753ffa25fab3a217e5f5b Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 5 Jun 2018 21:42:42 +1000 Subject: [PATCH 67/87] Version strings & bash. Fixed up the version checking. Thanks for your help @dschaper. No longer uses the version string as returned, but uses the major and minor version numbers extracted from it, against the minimum of 5.5. Tested against real install of php 7.0, (and the version check logic separately tested against a variety of artificial version numbers, of multiple digits for both major and minor version. - Lesson learned, I'm never trusting bash again) Signed-off-by: Rob Gill --- automated install/basic-install.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a4869d24..67cd3a4c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -160,13 +160,19 @@ if command -v apt-get &> /dev/null; then # use iproute iproute_pkg="iproute" fi - # Check for and determine version number, major and minor of current php install + # Check for and determine version number (major and minor) of current php install if command -v php &> /dev/null; then - phpInsVersion="$(php -v | head -n1 | grep -Po '(? /dev/null 2>&1; then phpVer="php" @@ -176,8 +182,6 @@ if command -v apt-get &> /dev/null; then fi else # Supported php is installed, its common, cgi & sqlite counterparts are deps - phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)" - phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)" phpVer="php$phpInsMajor.$phpInsMinor" fi # We also need the correct version for `php-sqlite` (which differs across distros) From 80040806430417625fe624c58e9dd95f9c597656 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 6 Jun 2018 22:37:43 +1000 Subject: [PATCH 68/87] Additional command-line completion Signed-off-by: Rob Gill --- advanced/bash-completion/pihole | 74 +++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole index fc8f2162..5a893f19 100644 --- a/advanced/bash-completion/pihole +++ b/advanced/bash-completion/pihole @@ -1,11 +1,79 @@ _pihole() { - local cur prev opts + local cur prev opts opts_admin opts_checkout opts_chronometer opts_debug opts_interface opts_logging opts_privacy opts_query opts_update opts_version COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist checkout" + prev2="${COMP_WORDS[COMP_CWORD-2]}" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + case "${prev}" in + "pihole") + opts="admin blacklist checkout chronometer debug disable enable flush help logging query reconfigure restartdns status tail uninstall updateGravity updatePihole version wildcard whitelist" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + ;; + "whitelist"|"blacklist"|"wildcard") + opts_lists="\--delmode \--noreload \--quiet \--list \--nuke" + COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) ) + ;; + "admin") + opts_admin="celsius email fahrenheit hostrecord interface kelvin password privacylevel" + COMPREPLY=( $(compgen -W "${opts_admin}" -- ${cur}) ) + ;; + "checkout") + opts_checkout="core ftl web master dev" + COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) ) + ;; + "chronometer") + opts_chronometer="\--exit \--jason \--refresh" + COMPREPLY=( $(compgen -W "${opts_chronometer}" -- ${cur}) ) + ;; + "debug") + opts_debug="-a" + COMPREPLY=( $(compgen -W "${opts_debug}" -- ${cur}) ) + ;; + "logging") + opts_logging="on off 'off noflush'" + COMPREPLY=( $(compgen -W "${opts_logging}" -- ${cur}) ) + ;; + "query") + opts_query="-adlist -all -exact" + COMPREPLY=( $(compgen -W "${opts_query}" -- ${cur}) ) + ;; + "updatePihole"|"-up") + opts_update="--check-only" + COMPREPLY=( $(compgen -W "${opts_update}" -- ${cur}) ) + ;; + "version") + opts_version="\--admin \--current \--ftl \--hash \--latest \--pihole" + COMPREPLY=( $(compgen -W "${opts_version}" -- ${cur}) ) + ;; + "interface") + if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then + opts_interface="$(cat /proc/net/dev | cut -d: -s -f1)" + COMPREPLY=( $(compgen -W "${opts_interface}" -- ${cur}) ) + else + return 1 + fi + ;; + "privacylevel") + if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then + opts_privacy="0 1 2 3" + COMPREPLY=( $(compgen -W "${opts_privacy}" -- ${cur}) ) + else + return 1 + fi + ;; + "core"|"admin"|"ftl") + if [[ "$prev2" == "checkout" ]]; then + opts_checkout="master dev" + COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) ) + else + return 1 + fi + ;; + *) + return 1 + ;; + esac return 0 } complete -F _pihole pihole From 52aa52c3b136e7bbeadc0646f75b91e3fc53b05e Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Thu, 7 Jun 2018 08:19:26 +1000 Subject: [PATCH 69/87] remove duplicate declaration Signed-off-by: Rob Gill --- 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 e1702187..4d825c60 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2028,7 +2028,6 @@ FTLinstall() { local ftlBranch local url - local ftlBranch if [[ -f "/etc/pihole/ftlbranch" ]];then ftlBranch=$( Date: Sat, 9 Jun 2018 10:30:04 +1000 Subject: [PATCH 70/87] --json not --jason Signed-off-by: Rob Gill --- advanced/bash-completion/pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole index 5a893f19..ff8fee56 100644 --- a/advanced/bash-completion/pihole +++ b/advanced/bash-completion/pihole @@ -23,7 +23,7 @@ _pihole() { COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) ) ;; "chronometer") - opts_chronometer="\--exit \--jason \--refresh" + opts_chronometer="\--exit \--json \--refresh" COMPREPLY=( $(compgen -W "${opts_chronometer}" -- ${cur}) ) ;; "debug") From 6381bdbf334e6583e96cb3c0e2bb6e2f21507201 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 9 Jun 2018 11:35:30 +1000 Subject: [PATCH 71/87] don't use major.minor for PHP 5 Signed-off-by: --- automated install/basic-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 67cd3a4c..9fcb478b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -166,13 +166,13 @@ if command -v apt-get &> /dev/null; then echo -e " ${INFO} Existing PHP installation detected : PHP version $phpInsVersion" phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)" phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)" - # Is installed php version supported? (php 5.4 is EOL) - if [ "$(echo "$phpInsMajor.$phpInsMinor < 5.5" | bc )" == 0 ]; then - phpInsSupported=true + # Is installed php version newer than php5? + if [ "$(echo "$phpInsMajor.$phpInsMinor < 7.0" | bc )" == 0 ]; then + phpInsNewer=true fi fi # Check if installed php is unsupported version (5.4 is EOL) - if [[ "$phpInsSupported" != true ]]; then + if [[ "$phpInsNewer" != true ]]; then # Prefer the php metapackage if it's there if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then phpVer="php" @@ -181,7 +181,7 @@ if command -v apt-get &> /dev/null; then phpVer="php5" fi else - # Supported php is installed, its common, cgi & sqlite counterparts are deps + # Newer php is installed, its common, cgi & sqlite counterparts are deps phpVer="php$phpInsMajor.$phpInsMinor" fi # We also need the correct version for `php-sqlite` (which differs across distros) From 11f0ade921aa0945cf9b20aad3f0097c92c4bd8d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Sat, 9 Jun 2018 13:18:36 +1000 Subject: [PATCH 72/87] comments Signed-off-by: Rob Gill --- 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 9fcb478b..5186b3cf 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -166,12 +166,12 @@ if command -v apt-get &> /dev/null; then echo -e " ${INFO} Existing PHP installation detected : PHP version $phpInsVersion" phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)" phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)" - # Is installed php version newer than php5? + # Is installed php version 7.0 or greater if [ "$(echo "$phpInsMajor.$phpInsMinor < 7.0" | bc )" == 0 ]; then phpInsNewer=true fi fi - # Check if installed php is unsupported version (5.4 is EOL) + # Check if installed php is v 7.0, or newer to determine packages to install if [[ "$phpInsNewer" != true ]]; then # Prefer the php metapackage if it's there if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then From e422f4154f4a05fa8bcd45e018328fb5c2d5d461 Mon Sep 17 00:00:00 2001 From: Alex Villarreal Date: Mon, 11 Jun 2018 12:56:27 -0500 Subject: [PATCH 73/87] Clean error message on successful response Signed-off-by: Alejandro Villarreal --- advanced/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/advanced/index.php b/advanced/index.php index 1575bafc..cad59ec7 100644 --- a/advanced/index.php +++ b/advanced/index.php @@ -329,6 +329,7 @@ setHeader(); setTimeout(function(){window.location.reload(1);}, 10000); $("#bpOutput").removeClass("add"); $("#bpOutput").addClass("success"); + $("#bpOutput").html(""); } else { $("#bpOutput").removeClass("add"); $("#bpOutput").addClass("error"); @@ -338,6 +339,7 @@ setHeader(); error: function(jqXHR, exception) { $("#bpOutput").removeClass("add"); $("#bpOutput").addClass("exception"); + $("#bpOutput").html(""); } }); } From d61fd01d61d95d86f79d1d041319adfc46c59c61 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 15:47:08 +1000 Subject: [PATCH 74/87] Split queryFunc() into query.sh Signed-off-by: Rob Gill --- advanced/query.sh | 220 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 advanced/query.sh diff --git a/advanced/query.sh b/advanced/query.sh new file mode 100644 index 00000000..3bae7422 --- /dev/null +++ b/advanced/query.sh @@ -0,0 +1,220 @@ +#!/usr/bin/env bash +# Pi-hole: A black hole for Internet advertisements +# (c) 2018 Pi-hole, LLC (https://pi-hole.net) +# Network-wide ad blocking via your own hardware. +# +# Query Domain Lists +# +# This file is copyright under the latest version of the EUPL. +# Please see LICENSE file for your rights under this license. + +# Globals +piholeDir="/etc/pihole" +adListsList="$piholeDir/adlists.list" +options="$*" +adlist="" +all="" +exact="" +blockpage="" +matchType="match" + +colfile="/opt/pihole/COL_TABLE" +source ${colfile} + +# Scan an array of files for matching strings +scanList(){ + # Escape full stops + local domain="${1//./\\.}" lists="${2}" type="${3:-}" + + # Prevent grep from printing file path + cd "$piholeDir" || exit 1 + + # Prevent grep -i matching slowly: http://bit.ly/2xFXtUX + export LC_CTYPE=C + + # /dev/null forces filename to be printed when only one list has been generated + # shellcheck disable=SC2086 + case "${type}" in + "exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null;; + "wc" ) grep -i -o -m 1 "/${domain}/" ${lists};; + * ) grep -i "${domain}" ${lists} /dev/null;; + esac +} + +if [[ "${options}" == "-h" ]] || [[ "${options}" == "--help" ]]; then + echo "Usage: pihole -q [option] +Example: 'pihole -q -exact domain.com' +Query the adlists for a specified domain + +Options: + -adlist Print the name of the block list URL + -exact Search the block lists for exact domain matches + -all Return all query matches within a block list + -h, --help Show this help dialog" + exit 0 +fi + +if [[ ! -e "$adListsList" ]]; then + echo -e "${COL_LIGHT_RED}The file '/etc/pihole/adlists.list' was not found${COL_NC}" + exit 1 +fi + +# Handle valid options +if [[ "${options}" == *"-bp"* ]]; then + exact="exact"; blockpage=true +else + [[ "${options}" == *"-adlist"* ]] && adlist=true + [[ "${options}" == *"-all"* ]] && all=true + if [[ "${options}" == *"-exact"* ]]; then + exact="exact"; matchType="exact ${matchType}" + fi +fi + +# Strip valid options, leaving only the domain and invalid options +# This allows users to place the options before or after the domain +options=$(sed -E 's/ ?-(bp|adlists?|all|exact) ?//g' <<< "${options}") + +# Handle remaining options +# If $options contain non ASCII characters, convert to punycode +case "${options}" in + "" ) str="No domain specified";; + *" "* ) str="Unknown query option specified";; + *[![:ascii:]]* ) domainQuery=$(idn2 "${options}");; + * ) domainQuery="${options}";; +esac + +if [[ -n "${str:-}" ]]; then + echo -e "${str}${COL_NC}\\nTry 'pihole -q --help' for more information." + exit 1 +fi + +# Scan Whitelist and Blacklist +lists="whitelist.txt blacklist.txt" +mapfile -t results <<< "$(scanList "${domainQuery}" "${lists}" "${exact}")" + if [[ -n "${results[*]}" ]]; then + wbMatch=true + # Loop through each result in order to print unique file title once + for result in "${results[@]}"; do + fileName="${result%%.*}" + if [[ -n "${blockpage}" ]]; then + echo "π ${result}" + exit 0 + elif [[ -n "${exact}" ]]; then + echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}" + else + # Only print filename title once per file + if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then + echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}" + fileName_prev="${fileName}" + fi + echo " ${result#*:}" + fi + done +fi + +# Scan Wildcards +if [[ -e "${wildcardlist}" ]]; then + # Determine all subdomains, domain and TLDs + mapfile -t wildcards <<< "$(processWildcards "${domainQuery}")" + for match in "${wildcards[@]}"; do + # Search wildcard list for matches + mapfile -t results <<< "$(scanList "${match}" "${wildcardlist}" "wc")" + if [[ -n "${results[*]}" ]]; then + if [[ -z "${wcMatch:-}" ]] && [[ -z "${blockpage}" ]]; then + wcMatch=true + echo " ${matchType^} found in ${COL_BOLD}Wildcards${COL_NC}:" + fi + case "${blockpage}" in + true ) echo "π ${wildcardlist##*/}"; exit 0;; + * ) echo " *.${match}";; + esac + fi + done +fi + +# Get version sorted *.domains filenames (without dir path) +lists=("$(cd "$piholeDir" || exit 0; printf "%s\\n" -- *.domains | sort -V)") + +# Query blocklists for occurences of domain +mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")" + +# Handle notices +if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then + echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists" + exit 0 +elif [[ -z "${results[*]}" ]]; then + # Result found in WL/BL/Wildcards + exit 0 +elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then + echo -e " ${INFO} Over 100 ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} + This can be overridden using the -all option" + exit 0 +fi + +# Remove unwanted content from non-exact $results +if [[ -z "${exact}" ]]; then + # Delete lines starting with # + # Remove comments after domain + # Remove hosts format IP address + mapfile -t results <<< "$(IFS=$'\n'; sed \ + -e "/:#/d" \ + -e "s/[ \\t]#.*//g" \ + -e "s/:.*[ \\t]/:/g" \ + <<< "${results[*]}")" + # Exit if result was in a comment + [[ -z "${results[*]}" ]] && exit 0 +fi + +# Get adlist file content as array +if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then + for adlistUrl in $(< "adListsList"); do + if [[ "${adlistUrl:0:4}" =~ (http|www.) ]]; then + adlists+=("${adlistUrl}") + fi + done +fi + +# Print "Exact matches for" title +if [[ -n "${exact}" ]] && [[ -z "${blockpage}" ]]; then + plural=""; [[ "${#results[*]}" -gt 1 ]] && plural="es" + echo " ${matchType^}${plural} for ${COL_BOLD}${domainQuery}${COL_NC} found in:" +fi + +for result in "${results[@]}"; do + fileName="${result/:*/}" + + # Determine *.domains URL using filename's number + if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then + fileNum="${fileName/list./}"; fileNum="${fileNum%%.*}" + fileName="${adlists[$fileNum]}" + + # Discrepency occurs when adlists has been modified, but Gravity has not been run + if [[ -z "${fileName}" ]]; then + fileName="${COL_LIGHT_RED}(no associated adlists URL found)${COL_NC}" + fi + fi + + if [[ -n "${blockpage}" ]]; then + echo "${fileNum} ${fileName}" + elif [[ -n "${exact}" ]]; then + echo " ${fileName}" + else + if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then + count="" + echo " ${matchType^} found in ${COL_BOLD}${fileName}${COL_NC}:" + fileName_prev="${fileName}" + fi + : $((count++)) + + # Print matching domain if $max_count has not been reached + [[ -z "${all}" ]] && max_count="50" + if [[ -z "${all}" ]] && [[ "${count}" -ge "${max_count}" ]]; then + [[ "${count}" -gt "${max_count}" ]] && continue + echo " ${COL_GRAY}Over ${count} results found, skipping rest of file${COL_NC}" + else + echo " ${result#*:}" + fi + fi +done + +exit 0 From b1207949ac00ea984f57b2b4b9b233a2b33e1db8 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 15:49:52 +1000 Subject: [PATCH 75/87] Call query.sh to replace queryFunc() Signed-off-by: Rob Gill --- pihole | 186 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 185 deletions(-) diff --git a/pihole b/pihole index c125d0d9..b0cab88e 100755 --- a/pihole +++ b/pihole @@ -125,191 +125,7 @@ processWildcards() { queryFunc() { shift - local options="$*" adlist="" all="" exact="" blockpage="" matchType="match" - - if [[ "${options}" == "-h" ]] || [[ "${options}" == "--help" ]]; then - echo "Usage: pihole -q [option] -Example: 'pihole -q -exact domain.com' -Query the adlists for a specified domain - -Options: - -adlist Print the name of the block list URL - -exact Search the block lists for exact domain matches - -all Return all query matches within a block list - -h, --help Show this help dialog" - exit 0 - fi - - if [[ ! -e "/etc/pihole/adlists.list" ]]; then - echo -e "${COL_LIGHT_RED}The file '/etc/pihole/adlists.list' was not found${COL_NC}" - exit 1 - fi - - # Handle valid options - if [[ "${options}" == *"-bp"* ]]; then - exact="exact"; blockpage=true - else - [[ "${options}" == *"-adlist"* ]] && adlist=true - [[ "${options}" == *"-all"* ]] && all=true - if [[ "${options}" == *"-exact"* ]]; then - exact="exact"; matchType="exact ${matchType}" - fi - fi - - # Strip valid options, leaving only the domain and invalid options - # This allows users to place the options before or after the domain - options=$(sed -E 's/ ?-(bp|adlists?|all|exact) ?//g' <<< "${options}") - - # Handle remaining options - # If $options contain non ASCII characters, convert to punycode - case "${options}" in - "" ) str="No domain specified";; - *" "* ) str="Unknown query option specified";; - *[![:ascii:]]* ) domainQuery=$(idn2 "${options}");; - * ) domainQuery="${options}";; - esac - - if [[ -n "${str:-}" ]]; then - echo -e "${str}${COL_NC}\\nTry 'pihole -q --help' for more information." - exit 1 - fi - - # Scan Whitelist and Blacklist - lists="whitelist.txt blacklist.txt" - mapfile -t results <<< "$(scanList "${domainQuery}" "${lists}" "${exact}")" - - if [[ -n "${results[*]}" ]]; then - wbMatch=true - - # Loop through each result in order to print unique file title once - for result in "${results[@]}"; do - fileName="${result%%.*}" - - if [[ -n "${blockpage}" ]]; then - echo "π ${result}" - exit 0 - elif [[ -n "${exact}" ]]; then - echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}" - else - # Only print filename title once per file - if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then - echo " ${matchType^} found in ${COL_BOLD}${fileName^}${COL_NC}" - fileName_prev="${fileName}" - fi - echo " ${result#*:}" - fi - done - fi - - # Scan Wildcards - if [[ -e "${wildcardlist}" ]]; then - # Determine all subdomains, domain and TLDs - mapfile -t wildcards <<< "$(processWildcards "${domainQuery}")" - - for match in "${wildcards[@]}"; do - # Search wildcard list for matches - mapfile -t results <<< "$(scanList "${match}" "${wildcardlist}" "wc")" - - if [[ -n "${results[*]}" ]]; then - if [[ -z "${wcMatch:-}" ]] && [[ -z "${blockpage}" ]]; then - wcMatch=true - echo " ${matchType^} found in ${COL_BOLD}Wildcards${COL_NC}:" - fi - - case "${blockpage}" in - true ) echo "π ${wildcardlist##*/}"; exit 0;; - * ) echo " *.${match}";; - esac - fi - done - fi - - # Get version sorted *.domains filenames (without dir path) - lists=("$(cd "/etc/pihole" || exit 0; printf "%s\\n" -- *.domains | sort -V)") - - # Query blocklists for occurences of domain - mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")" - - # Handle notices - if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then - echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists" - exit 0 - elif [[ -z "${results[*]}" ]]; then - # Result found in WL/BL/Wildcards - exit 0 - elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then - echo -e " ${INFO} Over 100 ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} - This can be overridden using the -all option" - exit 0 - fi - - # Remove unwanted content from non-exact $results - if [[ -z "${exact}" ]]; then - # Delete lines starting with # - # Remove comments after domain - # Remove hosts format IP address - mapfile -t results <<< "$(IFS=$'\n'; sed \ - -e "/:#/d" \ - -e "s/[ \\t]#.*//g" \ - -e "s/:.*[ \\t]/:/g" \ - <<< "${results[*]}")" - - # Exit if result was in a comment - [[ -z "${results[*]}" ]] && exit 0 - fi - - # Get adlist file content as array - if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then - for adlistUrl in $(< "/etc/pihole/adlists.list"); do - if [[ "${adlistUrl:0:4}" =~ (http|www.) ]]; then - adlists+=("${adlistUrl}") - fi - done - fi - - # Print "Exact matches for" title - if [[ -n "${exact}" ]] && [[ -z "${blockpage}" ]]; then - plural=""; [[ "${#results[*]}" -gt 1 ]] && plural="es" - echo " ${matchType^}${plural} for ${COL_BOLD}${domainQuery}${COL_NC} found in:" - fi - - for result in "${results[@]}"; do - fileName="${result/:*/}" - - # Determine *.domains URL using filename's number - if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then - fileNum="${fileName/list./}"; fileNum="${fileNum%%.*}" - fileName="${adlists[$fileNum]}" - - # Discrepency occurs when adlists has been modified, but Gravity has not been run - if [[ -z "${fileName}" ]]; then - fileName="${COL_LIGHT_RED}(no associated adlists URL found)${COL_NC}" - fi - fi - - if [[ -n "${blockpage}" ]]; then - echo "${fileNum} ${fileName}" - elif [[ -n "${exact}" ]]; then - echo " ${fileName}" - else - if [[ ! "${fileName}" == "${fileName_prev:-}" ]]; then - count="" - echo " ${matchType^} found in ${COL_BOLD}${fileName}${COL_NC}:" - fileName_prev="${fileName}" - fi - : $((count++)) - - # Print matching domain if $max_count has not been reached - [[ -z "${all}" ]] && max_count="50" - if [[ -z "${all}" ]] && [[ "${count}" -ge "${max_count}" ]]; then - [[ "${count}" -gt "${max_count}" ]] && continue - echo " ${COL_GRAY}Over ${count} results found, skipping rest of file${COL_NC}" - else - echo " ${result#*:}" - fi - fi - done - + "${PI_HOLE_SCRIPT_DIR}"/query.sh "$@" exit 0 } From 45a8eda49b7d632ca4d6652558aa8d349fe2bbd3 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 16:08:21 +1000 Subject: [PATCH 76/87] Stop grep leak in query Fix grep error leak from #1805 Signed-off-by: Rob Gill --- advanced/{ => Scripts}/query.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename advanced/{ => Scripts}/query.sh (97%) diff --git a/advanced/query.sh b/advanced/Scripts/query.sh similarity index 97% rename from advanced/query.sh rename to advanced/Scripts/query.sh index 3bae7422..88118ee1 100644 --- a/advanced/query.sh +++ b/advanced/Scripts/query.sh @@ -35,9 +35,9 @@ scanList(){ # /dev/null forces filename to be printed when only one list has been generated # shellcheck disable=SC2086 case "${type}" in - "exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null;; - "wc" ) grep -i -o -m 1 "/${domain}/" ${lists};; - * ) grep -i "${domain}" ${lists} /dev/null;; + "exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;; + "wc" ) grep -i -o -m 1 "/${domain}/" ${lists} 2>/dev/null;; + * ) grep -i "${domain}" ${lists} /dev/null 2>/dev/null;; esac } From 2255d05664d07c581ca3a81eb37e20cff9c95a19 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 16:09:49 +1000 Subject: [PATCH 77/87] Remove scanlist(), now in query.sh Signed-off-by: Rob Gill --- pihole | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/pihole b/pihole index b0cab88e..59ab760f 100755 --- a/pihole +++ b/pihole @@ -86,26 +86,6 @@ updateGravityFunc() { exit 0 } -# Scan an array of files for matching strings -scanList(){ - # Escape full stops - local domain="${1//./\\.}" lists="${2}" type="${3:-}" - - # Prevent grep from printing file path - cd "/etc/pihole" || exit 1 - - # Prevent grep -i matching slowly: http://bit.ly/2xFXtUX - export LC_CTYPE=C - - # /dev/null forces filename to be printed when only one list has been generated - # shellcheck disable=SC2086 - case "${type}" in - "exact" ) grep -i -E -l "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null;; - "wc" ) grep -i -o -m 1 "/${domain}/" ${lists};; - * ) grep -i "${domain}" ${lists} /dev/null;; - esac -} - # Print each subdomain # e.g: foo.bar.baz.com = "foo.bar.baz.com bar.baz.com baz.com com" processWildcards() { From b8e1849cec356d2ccfa5a9cd519636dd8858daa6 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 16:19:07 +1000 Subject: [PATCH 78/87] wildcardlist Signed-off-by: Rob Gill --- advanced/Scripts/query.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 88118ee1..8b570ffe 100644 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -11,6 +11,7 @@ # Globals piholeDir="/etc/pihole" adListsList="$piholeDir/adlists.list" +wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf" options="$*" adlist="" all="" @@ -19,7 +20,7 @@ blockpage="" matchType="match" colfile="/opt/pihole/COL_TABLE" -source ${colfile} +source "$colfile" # Scan an array of files for matching strings scanList(){ From 8ab0b0e46073c6e06e03745113484d422bdf6afc Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 16:25:43 +1000 Subject: [PATCH 79/87] colfile Signed-off-by: Rob Gill --- advanced/Scripts/query.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 8b570ffe..42f9c895 100644 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -20,7 +20,7 @@ blockpage="" matchType="match" colfile="/opt/pihole/COL_TABLE" -source "$colfile" +source "${colfile}" # Scan an array of files for matching strings scanList(){ From bf5566649251273f5be5a25593c40f73dfaa7c1d Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Wed, 13 Jun 2018 16:29:07 +1000 Subject: [PATCH 80/87] Appease stickler. Signed-off-by: Rob Gill --- advanced/Scripts/query.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 42f9c895..e1cd6457 100644 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC1090 # Pi-hole: A black hole for Internet advertisements # (c) 2018 Pi-hole, LLC (https://pi-hole.net) # Network-wide ad blocking via your own hardware. From a7347238e6b22a9b78addef55809d59be7ca9e65 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 15 Jun 2018 14:42:30 +1000 Subject: [PATCH 81/87] $adListsList replace filename in text Signed-off-by: Rob Gill --- advanced/Scripts/query.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index e1cd6457..f9d25511 100644 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -57,7 +57,7 @@ Options: fi if [[ ! -e "$adListsList" ]]; then - echo -e "${COL_LIGHT_RED}The file '/etc/pihole/adlists.list' was not found${COL_NC}" + echo -e "${COL_LIGHT_RED}The file "$adListsList" was not found${COL_NC}" exit 1 fi From 23adbf9540dbe1034a87d81adc15d7b03f609a51 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Fri, 15 Jun 2018 14:45:27 +1000 Subject: [PATCH 82/87] remove quotes Signed-off-by: Rob Gill --- advanced/Scripts/query.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index f9d25511..5dc80f6b 100644 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -57,7 +57,7 @@ Options: fi if [[ ! -e "$adListsList" ]]; then - echo -e "${COL_LIGHT_RED}The file "$adListsList" was not found${COL_NC}" + echo -e "${COL_LIGHT_RED}The file $adListsList was not found${COL_NC}" exit 1 fi From a7c73036f0b7801feea2b643221d420caec84282 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 17 Jun 2018 13:37:41 +0200 Subject: [PATCH 83/87] pihole -t: Warn user if Pi-hole's logging is disabled Signed-off-by: DL6ER --- pihole | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pihole b/pihole index 59ab760f..21329849 100755 --- a/pihole +++ b/pihole @@ -312,6 +312,13 @@ statusFunc() { } tailFunc() { + # Warn user if Pi-hole's logging is disabled + local logging_enabled=$(grep -c "^log-queries" /etc/dnsmasq.d/01-pihole.conf) + if [[ "${logging_enabled}" == "0" ]]; then + # No "log-queries" lines are found. + # Commented out lines (such as "#log-queries") are ignored + echo " ${CROSS} Warning: Query logging is disabled" + fi echo -e " ${INFO} Press Ctrl-C to exit" # Retrieve IPv4/6 addresses From e71492a2b3995cb123fe0266438be5d571da54f4 Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Wed, 20 Jun 2018 20:19:38 -0400 Subject: [PATCH 84/87] Update debug script for simple list format Gravity is now just a list of domains, not IP addresses and domains separated by a space. Signed-off-by: Mcat12 --- 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 a7fa4c2a..cffbfe82 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -780,7 +780,7 @@ dig_at() { # Find a random blocked url that has not been whitelisted. # This helps emulate queries to different domains that a user might query # It will also give extra assurance that Pi-hole is correctly resolving and blocking domains - local random_url=$(shuf -n 1 "${PIHOLE_BLOCKLIST_FILE}" | awk -F ' ' '{ print $2 }') + local random_url=$(shuf -n 1 "${PIHOLE_BLOCKLIST_FILE}") # First, do a dig on localhost to see if Pi-hole can use itself to block a domain if local_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @${local_address} +short "${record_type}"); then From 868948509a4a7b70feff67537f709eb933cfc33c Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Wed, 20 Jun 2018 20:30:42 -0400 Subject: [PATCH 85/87] Split declaration and assignment of random_url Signed-off-by: Mcat12 --- advanced/Scripts/piholeDebug.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index cffbfe82..2f2b3745 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -780,7 +780,8 @@ dig_at() { # Find a random blocked url that has not been whitelisted. # This helps emulate queries to different domains that a user might query # It will also give extra assurance that Pi-hole is correctly resolving and blocking domains - local random_url=$(shuf -n 1 "${PIHOLE_BLOCKLIST_FILE}") + local random_url + random_url=$(shuf -n 1 "${PIHOLE_BLOCKLIST_FILE}") # First, do a dig on localhost to see if Pi-hole can use itself to block a domain if local_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @${local_address} +short "${record_type}"); then From d5547f5c7c6eb450a85fde721579ac3835bad50c Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 24 Jun 2018 16:06:55 -0700 Subject: [PATCH 86/87] Revert "Fix error: /opt/pihole/gravity.sh: 385: Warning: command substitution: ignored null byte in input" --- gravity.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index ade27b8a..dfcb753a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -387,8 +387,9 @@ gravity_ConsolidateDownloadedBlocklists() { if [[ -r "${i}" ]]; then # Remove windows CRs from file, convert list to lower case, and append into $matterAndLight tr -d '\r' < "${i}" | tr '[:upper:]' '[:lower:]' >> "${piholeDir}/${matterAndLight}" + # Ensure that the first line of a new list is on a new line - IFS= read -r -d '' lastLine <"${piholeDir}/${matterAndLight}" || [[ $lastLine ]] + lastLine=$(tail -1 "${piholeDir}/${matterAndLight}") if [[ "${#lastLine}" -gt 0 ]]; then echo "" >> "${piholeDir}/${matterAndLight}" fi From b74fb3f179f6cc29f71d7284a86e9b4e1ea64134 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 29 Jun 2018 00:28:43 +1000 Subject: [PATCH 87/87] typo fix --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3152d9c1..2be62865 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -850,7 +850,7 @@ setDNS() { fi # Dialog for the user to enter custom upstream servers - piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), seperated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r} ${c} "${prePopulate}" 3>&1 1>&2 2>&3) || \ + piholeDNS=$(whiptail --backtitle "Specify Upstream DNS Provider(s)" --inputbox "Enter your desired upstream DNS provider(s), separated by a comma.\\n\\nFor example '8.8.8.8, 8.8.4.4'" ${r} ${c} "${prePopulate}" 3>&1 1>&2 2>&3) || \ { echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; exit 1; } # PIHOLE_DNS_1=$(echo "${piholeDNS}" | sed 's/[, \t]\+/,/g' | awk -F, '{print$1}')