* remove package_check to avoid situations like #1760

Signed-off-by: Adam Warner <adamw@rner.email>

* Prevent redundant entries in to adlists.list

Grep ${args[3]} and only add if grep -c -eq 0

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>

* lan to local

Reduced differences.

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>

* Require exact match

Updated to require an exact match to reduce false-positives, as suggested by DL6ER.

Signed-off-by: Ryan Knapper <ryanknapper@gmail.com>

* fix empty ports on some systems

Signed-off-by: Jacob Salmela <jacob.salmela@pi-hole.net>

* debug user locale; improve function to parse variables and files

Signed-off-by: Jacob Salmela <jacob.salmela@pi-hole.net>

* Split declaration and population for stickler.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>

* implement dschapers suggestions--better command, less subshells, and finer formatting

Signed-off-by: Jacob Salmela <jacob.salmela@pi-hole.net>

* flip uninstall compatability check

Signed-off-by: bcambl <blayne@blaynecampbell.com>

* 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 <rrobgill@protonmail.com>

* Update index.php

thanks stickler-ci  .......

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* changes as requested 

changes as requested 

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* oh stickler bot...

accidentally a space

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* linting: Double quote to prevent globbing and word splitting

Signed-off-by: bcambl <blayne@blaynecampbell.com>

* unbind resolved on ubuntu 18.04

Stop systemd-resolved from interfering with dnsmasq/ftl
Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* restore resolvd.conf

If dnsmasq is removed, resolved will need to be restored.

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* Update uninstall.sh

Signed-off-by: Rob Gill <rrobgill@protonmail.com>>

* Minor correction for double instance of the word "found".

Signed-off-by: RamSet <RamSet@gmail.com>

* message text

Signed-off-by: Rob Gill <rrobgill@protonmail.com>>

* 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 <rrobgill@protonmail.com>

* Regex & case fix

grep & sed regexes  match commented or uncommented

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* Update basic-install.sh

Force reloading of relsolved config where available

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* reload resloved

reload resolved config if possible, restart otherwise

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* user-facing messages

Signed-off-by: Rob Gill <rrobgill@protonmail.com>

* move & clarify comments
This commit is contained in:
Rob Gill 2018-06-01 07:14:54 +10:00 committed by GitHub
parent f0dfa4d53d
commit b60a9fa371
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 27 deletions

View file

@ -493,6 +493,13 @@ parse_setup_vars() {
fi fi
} }
parse_locale() {
local pihole_locale
echo_current_diagnostic "Locale"
pihole_locale="$(locale)"
parse_file "${pihole_locale}"
}
does_ip_match_setup_vars() { does_ip_match_setup_vars() {
# Check for IPv4 or 6 # Check for IPv4 or 6
local protocol="${1}" local protocol="${1}"
@ -652,15 +659,22 @@ check_required_ports() {
# Sort the addresses and remove duplicates # Sort the addresses and remove duplicates
while IFS= read -r line; do while IFS= read -r line; do
ports_in_use+=( "$line" ) 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, # Now that we have the values stored,
for i in "${!ports_in_use[@]}"; do for i in "${!ports_in_use[@]}"; do
# loop through them and assign some local variables # loop through them and assign some local variables
local port_number
port_number="$(echo "${ports_in_use[$i]}" | awk '{print $1}')"
local service_name 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 # Use a case statement to determine if the right services are using the right ports
case "${port_number}" in case "${port_number}" in
53) compare_port_to_service_assigned "${resolver}" 53) compare_port_to_service_assigned "${resolver}"
@ -670,7 +684,7 @@ check_required_ports() {
4711) compare_port_to_service_assigned "${ftl}" 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 # 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 esac
done done
} }
@ -879,8 +893,11 @@ parse_file() {
# Put the current Internal Field Separator into another variable so it can be restored later # Put the current Internal Field Separator into another variable so it can be restored later
OLD_IFS="$IFS" OLD_IFS="$IFS"
# Get the lines that are in the file(s) and store them in an array for parsing later # Get the lines that are in the file(s) and store them in an array for parsing later
if [[ -f "$filename" ]]; then
IFS=$'\r\n' command eval 'file_info=( $(cat "${filename}") )' IFS=$'\r\n' command eval 'file_info=( $(cat "${filename}") )'
else
read -a file_info <<< $filename
fi
# Set a named variable for better readability # Set a named variable for better readability
local file_lines local file_lines
# For each line in the file, # For each line in the file,
@ -1193,6 +1210,7 @@ parse_setup_vars
check_x_headers check_x_headers
analyze_gravity_list analyze_gravity_list
show_content_of_pihole_files show_content_of_pihole_files
parse_locale
analyze_pihole_log analyze_pihole_log
copy_to_debug_log copy_to_debug_log
upload_to_tricorder upload_to_tricorder

View file

@ -204,10 +204,6 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}" add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
fi 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 else
change_setting "DNSSEC" "false" change_setting "DNSSEC" "false"
fi 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 ProcessDNSSettings
@ -383,7 +368,9 @@ CustomizeAdLists() {
elif [[ "${args[2]}" == "disable" ]]; then elif [[ "${args[2]}" == "disable" ]]; then
sed -i "\\@${args[3]}@s/^http/#http/g" "${list}" sed -i "\\@${args[3]}@s/^http/#http/g" "${list}"
elif [[ "${args[2]}" == "add" ]]; then elif [[ "${args[2]}" == "add" ]]; then
if [[ $(grep -c "^${args[3]}$" "${list}") -eq 0 ]] ; then
echo "${args[3]}" >> ${list} echo "${args[3]}" >> ${list}
fi
elif [[ "${args[2]}" == "del" ]]; then elif [[ "${args[2]}" == "del" ]]; then
var=$(echo "${args[3]}" | sed 's/\//\\\//g') var=$(echo "${args[3]}" | sed 's/\//\\\//g')
sed -i "/${var}/Id" "${list}" sed -i "/${var}/Id" "${list}"

View file

@ -102,8 +102,10 @@ if ($serverName === "pi.hole") {
$bpAskAdmin = !empty($svEmail) ? '<a href="mailto:'.$svEmail.'?subject=Site Blocked: '.$serverName.'"></a>' : "<span/>"; $bpAskAdmin = !empty($svEmail) ? '<a href="mailto:'.$svEmail.'?subject=Site Blocked: '.$serverName.'"></a>' : "<span/>";
// Determine if at least one block list has been generated // 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 <code>/etc/pihole/</code>! Please update gravity by running <code>pihole -g</code>, or repair Pi-hole using <code>pihole -r</code>."); die("[ERROR] There are no domain lists generated lists within <code>/etc/pihole/</code>! Please update gravity by running <code>pihole -g</code>, or repair Pi-hole using <code>pihole -r</code>.");
}
// Set location of adlists file // Set location of adlists file
if (is_file("/etc/pihole/adlists.list")) { if (is_file("/etc/pihole/adlists.list")) {

View file

@ -1265,6 +1265,30 @@ check_service_active() {
fi 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() { update_package_cache() {
# Running apt-get update/upgrade with minimal output can cause some issues with # Running apt-get update/upgrade with minimal output can cause some issues with
# requiring user input (e.g password for phpmyadmin see #218) # requiring user input (e.g password for phpmyadmin see #218)
@ -2290,8 +2314,11 @@ main() {
fi fi
fi fi
echo -e " ${INFO} Restarting services..." # Check for and disable systemd-resolved-DNSStubListener before reloading resolved
# Start services # 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 the Web server was installed,
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
@ -2304,6 +2331,9 @@ main() {
fi fi
fi fi
echo -e " ${INFO} Restarting services..."
# Start services
# Enable FTL # Enable FTL
start_service pihole-FTL start_service pihole-FTL
enable_service pihole-FTL enable_service pihole-FTL

View file

@ -65,6 +65,7 @@ elif [ -x "$(command -v rpm)" ]; then
package_check() { package_check() {
rpm -qa | grep "^$1-" > /dev/null rpm -qa | grep "^$1-" > /dev/null
} }
else else
echo -e " ${CROSS} OS distribution not supported" echo -e " ${CROSS} OS distribution not supported"
exit 1 exit 1

2
pihole
View file

@ -232,7 +232,7 @@ Options:
# Handle notices # Handle notices
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then 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 exit 0
elif [[ -z "${results[*]}" ]]; then elif [[ -z "${results[*]}" ]]; then
# Result found in WL/BL/Wildcards # Result found in WL/BL/Wildcards