From 2c8dcd86e570df2c1b1372b330b095d749f804d9 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Thu, 9 Nov 2017 20:47:15 +0000 Subject: [PATCH 01/25] 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/25] 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/25] 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 5ecfc58e5fb016d1f8fd031325d8f7c98aa8cb4a Mon Sep 17 00:00:00 2001 From: Ryan Knapper Date: Wed, 28 Feb 2018 13:06:07 -0500 Subject: [PATCH 04/25] 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 05/25] 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 1a275ba18458363f66da62ff6ab0481cf472e3a7 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 1 Apr 2018 06:40:48 -0500 Subject: [PATCH 06/25] debug user locale; improve function to parse variables and files Signed-off-by: Jacob Salmela --- advanced/Scripts/piholeDebug.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index a16457a0..33114794 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -493,6 +493,12 @@ parse_setup_vars() { fi } +parse_locale() { + echo_current_diagnostic "Locale" + local pihole_locale="$(locale)" + parse_file "${pihole_locale}" +} + does_ip_match_setup_vars() { # Check for IPv4 or 6 local protocol="${1}" @@ -879,8 +885,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, @@ -1165,6 +1174,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 From 250b445eeee8691d9b5a3bfee30f48d46e87853f Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 10 Apr 2018 21:37:04 -0700 Subject: [PATCH 07/25] Split declaration and population for stickler. Signed-off-by: Dan Schaper --- 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 33114794..f34b8646 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -494,8 +494,9 @@ parse_setup_vars() { } parse_locale() { + local pihole_locale echo_current_diagnostic "Locale" - local pihole_locale="$(locale)" + pihole_locale="$(locale)" parse_file "${pihole_locale}" } From 5ffc3561eda57963e5b88b74816184869574f66e Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Wed, 11 Apr 2018 20:35:51 -0500 Subject: [PATCH 08/25] 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 d3dda443cd03aa6a9ad3b1c87d3d12a68c9bb60d Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 4 May 2018 00:02:47 -0600 Subject: [PATCH 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] 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 2f24e5ceb732d75d1c70967c9a3abe19a73f3fab Mon Sep 17 00:00:00 2001 From: RamSet Date: Mon, 14 May 2018 12:21:20 -0600 Subject: [PATCH 18/25] Minor correction for double instance of the word "found". Signed-off-by: RamSet --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b89a78ce1787dd917e604cbc6372473aacd36d4c Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Tue, 15 May 2018 19:42:18 +1000 Subject: [PATCH 19/25] 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 20/25] 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 21/25] 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 22/25] 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 23/25] 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 24/25] 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 25/25] 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