From 9d59da8974661cf6ad26d967d12e04193589b90a Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Thu, 16 Aug 2018 18:10:55 -0400 Subject: [PATCH 1/5] Remove dnsmasq checks from debugger This also fixes an issue where the port checks weren't running (`compare_port_to_service_assigned`). Signed-off-by: Mcat12 --- advanced/Scripts/piholeDebug.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index ca07b9a1..cb66f97c 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -119,7 +119,7 @@ PIHOLE_WEB_SERVER_ERROR_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/error.log" #SUPPORTED_OS=("Raspbian" "Ubuntu" "Fedora" "Debian" "CentOS") # Store Pi-hole's processes in an array for easy use and parsing -PIHOLE_PROCESSES=( "dnsmasq" "lighttpd" "pihole-FTL" ) +PIHOLE_PROCESSES=( "lighttpd" "pihole-FTL" ) # Store the required directories in an array so it can be parsed through #REQUIRED_DIRECTORIES=("${CORE_GIT_DIRECTORY}" @@ -337,8 +337,6 @@ get_program_version() { case "${program_name}" in "lighttpd") program_version="$(${program_name} -v |& head -n1 | cut -d '/' -f2 | cut -d ' ' -f1)" ;; - "dnsmasq") program_version="$(${program_name} -v |& head -n1 | awk '{print $3}')" - ;; "php") program_version="$(${program_name} -v |& head -n1 | cut -d '-' -f1 | cut -d ' ' -f2)" ;; # If a match is not found, show an error @@ -358,7 +356,6 @@ get_program_version() { # and their versions, using the functions above. check_critical_program_versions() { # Use the function created earlier and bundle them into one function that checks all the version numbers - get_program_version "dnsmasq" get_program_version "lighttpd" get_program_version "php" } @@ -640,11 +637,12 @@ ping_internet() { compare_port_to_service_assigned() { local service_name="${1}" # The programs we use may change at some point, so they are in a varible here - local resolver="dnsmasq" + local resolver="pihole-FTL" local web_server="lighttpd" local ftl="pihole-FTL" + + # If the service is a Pi-hole service, highlight it in green if [[ "${service_name}" == "${resolver}" ]] || [[ "${service_name}" == "${web_server}" ]] || [[ "${service_name}" == "${ftl}" ]]; then - # if port 53 is dnsmasq, show it in green as it's standard log_write "[${COL_GREEN}${port_number}${COL_NC}] is in use by ${COL_GREEN}${service_name}${COL_NC}" # Otherwise, else @@ -657,7 +655,7 @@ check_required_ports() { echo_current_diagnostic "Ports in use" # Since Pi-hole needs 53, 80, and 4711, check what they are being used by # so we can detect any issues - local resolver="dnsmasq" + local resolver="pihole-FTL" local web_server="lighttpd" local ftl="pihole-FTL" # Create an array for these ports in use @@ -682,7 +680,7 @@ check_required_ports() { continue fi # Use a case statement to determine if the right services are using the right ports - case "${port_number}" in + case "$(echo "$port_number" | rev | cut -d: -f1 | rev)" in 53) compare_port_to_service_assigned "${resolver}" ;; 80) compare_port_to_service_assigned "${web_server}" From 3f59b51be19a179d595cf22c1094d44e4a8ed80d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Thu, 8 Nov 2018 22:00:13 -0500 Subject: [PATCH 2/5] Fix restartDNS returning code 1 even when it worked If stdout was not a terminal (the `-t 1` check), `restartDNS` would return code 1 in the success case. This caused the API to fail whenever it tried to restart the DNS server. Signed-off-by: Mcat12 --- pihole | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pihole b/pihole index fb398f29..d4681752 100755 --- a/pihole +++ b/pihole @@ -134,9 +134,11 @@ restartDNS() { if [[ "${status}" -eq 0 ]]; then [[ -t 1 ]] && echo -e "${OVER} ${TICK} ${str}" + return 0 else [[ ! -t 1 ]] && local OVER="" echo -e "${OVER} ${CROSS} ${output}" + return 1 fi } From f9e71bee0a29b44a8586595e998ad6b878ba3ac6 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 12 Nov 2018 17:15:24 -0800 Subject: [PATCH 3/5] Account for port, or lack of, in PIHOLE_DNS_1 Signed-off-by: Dan Schaper --- gravity.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 2b3ffcd8..d9fe2209 100755 --- a/gravity.sh +++ b/gravity.sh @@ -257,7 +257,13 @@ gravity_DownloadBlocklistFromUrl() { esac if [[ "${blocked}" == true ]]; then - ip=$(dig "@${PIHOLE_DNS_1}" +short "${domain}") + printf -v ip_addr "%s" ${PIHOLE_DNS_1%#*} + if [[ ${PIHOLE_DNS_1} != *"#"* ]]; then + port=53 + else + printf -v port "%s" ${PIHOLE_DNS_1#*#} + fi + ip=$(dig "@${ip_addr}" -p "${port}" +short "${domain}") if [[ $(echo "${url}" | awk -F '://' '{print $1}') = "https" ]]; then port=443; else port=80 From 5c621fa2535416e5586adb061ea081f8f611b761 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 12 Nov 2018 17:21:34 -0800 Subject: [PATCH 4/5] Lints Signed-off-by: Dan Schaper --- gravity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index d9fe2209..288fd237 100755 --- a/gravity.sh +++ b/gravity.sh @@ -257,11 +257,11 @@ gravity_DownloadBlocklistFromUrl() { esac if [[ "${blocked}" == true ]]; then - printf -v ip_addr "%s" ${PIHOLE_DNS_1%#*} + printf -v ip_addr "%s" "${PIHOLE_DNS_1%#*}" if [[ ${PIHOLE_DNS_1} != *"#"* ]]; then port=53 else - printf -v port "%s" ${PIHOLE_DNS_1#*#} + printf -v port "%s" "${PIHOLE_DNS_1#*#}" fi ip=$(dig "@${ip_addr}" -p "${port}" +short "${domain}") if [[ $(echo "${url}" | awk -F '://' '{print $1}') = "https" ]]; then From d0125d5aad7d44eb2d17c8512f466e6f5fa61ded Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Nov 2018 17:38:19 +0100 Subject: [PATCH 5/5] Suppress warning if Pi-hole is not used as DHCP server (/etc/pihole/dhcp.leases is not present in this case) Signed-off-by: DL6ER --- advanced/Templates/pihole-FTL.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index 9e73e00b..d19e2bd5 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -36,7 +36,7 @@ start() { rm /var/run/pihole/FTL.sock 2> /dev/null # Ensure that permissions are set so that pihole-FTL can edit all necessary files chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port - chown pihole:pihole /etc/pihole /etc/pihole/dhcp.leases + chown pihole:pihole /etc/pihole /etc/pihole/dhcp.leases 2> /dev/null chown pihole:pihole /var/log/pihole-FTL.log /var/log/pihole.log chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.piholeFTL