Compare commits
54 Commits
feature/lu
...
developmen
Author | SHA1 | Date | |
---|---|---|---|
|
0e3205386a | ||
|
a76231216a | ||
|
34f464bd6f | ||
|
a52a5e7ef2 | ||
|
a0d74d1e9d | ||
|
0cbf77eb9f | ||
|
36470eb138 | ||
|
e80e54a61a | ||
|
118c0d209d | ||
|
9b9e907013 | ||
|
4ac4bc5c18 | ||
|
8c926d6af6 | ||
|
a1d85155fd | ||
|
2d0619afec | ||
|
ab9d589995 | ||
|
4fb5157719 | ||
|
641eb7821b | ||
|
b0a1d6f08a | ||
|
005c75ebf6 | ||
|
5fc89c11d9 | ||
|
dc5673af5c | ||
|
a02b7e09d1 | ||
|
ffeb8cae87 | ||
|
c9042022ea | ||
|
6a312500a0 | ||
|
3a122ed11a | ||
|
8cb175811f | ||
|
8336d49853 | ||
|
08710746e2 | ||
|
87f2ae82cd | ||
|
469b715442 | ||
|
04ffd22b4d | ||
|
c120f8a8d8 | ||
|
0a5eee4d99 | ||
|
2b49988013 | ||
|
954b3e784f | ||
|
0612685fac | ||
|
e3a22dcbfa | ||
|
4f660966d0 | ||
|
7df22cd8e0 | ||
|
01764cc581 | ||
|
08cf9aa5a7 | ||
|
1ae67e1de8 | ||
|
f2cba6cad1 | ||
|
df3c46349a | ||
|
a2d5b8050a | ||
|
01c310a78f | ||
|
a9e761ec13 | ||
|
c901443676 | ||
|
60513f93a3 | ||
|
3b574096b8 | ||
|
58905a1188 | ||
|
aa88be335e | ||
|
f90dffbf1a |
@@ -498,10 +498,6 @@ chronoFunc() {
|
|||||||
printFunc " RAM usage: " "$ram_perc%" "$ram_info"
|
printFunc " RAM usage: " "$ram_perc%" "$ram_info"
|
||||||
printFunc " HDD usage: " "$disk_perc" "$disk_info"
|
printFunc " HDD usage: " "$disk_perc" "$disk_info"
|
||||||
|
|
||||||
if [[ "$scr_lines" -gt 17 ]] && [[ "$chrono_width" != "small" ]]; then
|
|
||||||
printFunc " LAN addr: " "${IPV4_ADDRESS/\/*/}" "$lan_info"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$DHCP_ACTIVE" == "true" ]]; then
|
if [[ "$DHCP_ACTIVE" == "true" ]]; then
|
||||||
printFunc "DHCP usage: " "$ph_dhcp_percent%" "$dhcp_info"
|
printFunc "DHCP usage: " "$ph_dhcp_percent%" "$dhcp_info"
|
||||||
fi
|
fi
|
||||||
|
@@ -72,8 +72,8 @@ PIHOLE_SCRIPTS_DIRECTORY="/opt/pihole"
|
|||||||
BIN_DIRECTORY="/usr/local/bin"
|
BIN_DIRECTORY="/usr/local/bin"
|
||||||
RUN_DIRECTORY="/run"
|
RUN_DIRECTORY="/run"
|
||||||
LOG_DIRECTORY="/var/log"
|
LOG_DIRECTORY="/var/log"
|
||||||
WEB_SERVER_LOG_DIRECTORY="${LOG_DIRECTORY}/lighttpd"
|
#WEB_SERVER_LOG_DIRECTORY="${LOG_DIRECTORY}/lighttpd" #TODO: FTL access log?
|
||||||
WEB_SERVER_CONFIG_DIRECTORY="/etc/lighttpd"
|
#WEB_SERVER_CONFIG_DIRECTORY="/etc/lighttpd" #TODO: web server config?
|
||||||
HTML_DIRECTORY="/var/www/html"
|
HTML_DIRECTORY="/var/www/html"
|
||||||
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
|
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
|
||||||
#BLOCK_PAGE_DIRECTORY="${HTML_DIRECTORY}/pihole"
|
#BLOCK_PAGE_DIRECTORY="${HTML_DIRECTORY}/pihole"
|
||||||
@@ -87,8 +87,8 @@ PIHOLE_DNS_CONFIG_FILE="${DNSMASQ_D_DIRECTORY}/01-pihole.conf"
|
|||||||
PIHOLE_DHCP_CONFIG_FILE="${DNSMASQ_D_DIRECTORY}/02-pihole-dhcp.conf"
|
PIHOLE_DHCP_CONFIG_FILE="${DNSMASQ_D_DIRECTORY}/02-pihole-dhcp.conf"
|
||||||
PIHOLE_WILDCARD_CONFIG_FILE="${DNSMASQ_D_DIRECTORY}/03-wildcard.conf"
|
PIHOLE_WILDCARD_CONFIG_FILE="${DNSMASQ_D_DIRECTORY}/03-wildcard.conf"
|
||||||
|
|
||||||
WEB_SERVER_CONFIG_FILE="${WEB_SERVER_CONFIG_DIRECTORY}/lighttpd.conf"
|
#WEB_SERVER_CONFIG_FILE="${WEB_SERVER_CONFIG_DIRECTORY}/lighttpd.conf"
|
||||||
WEB_SERVER_CUSTOM_CONFIG_FILE="${WEB_SERVER_CONFIG_DIRECTORY}/external.conf"
|
#WEB_SERVER_CUSTOM_CONFIG_FILE="${WEB_SERVER_CONFIG_DIRECTORY}/external.conf"
|
||||||
|
|
||||||
PIHOLE_INSTALL_LOG_FILE="${PIHOLE_DIRECTORY}/install.log"
|
PIHOLE_INSTALL_LOG_FILE="${PIHOLE_DIRECTORY}/install.log"
|
||||||
PIHOLE_RAW_BLOCKLIST_FILES="${PIHOLE_DIRECTORY}/list.*"
|
PIHOLE_RAW_BLOCKLIST_FILES="${PIHOLE_DIRECTORY}/list.*"
|
||||||
@@ -138,15 +138,15 @@ PIHOLE_LOG_GZIPS="${LOG_DIRECTORY}/pihole.log.[0-9].*"
|
|||||||
PIHOLE_DEBUG_LOG="${LOG_DIRECTORY}/pihole_debug.log"
|
PIHOLE_DEBUG_LOG="${LOG_DIRECTORY}/pihole_debug.log"
|
||||||
PIHOLE_FTL_LOG="$(get_ftl_conf_value "LOGFILE" "${LOG_DIRECTORY}/pihole-FTL.log")"
|
PIHOLE_FTL_LOG="$(get_ftl_conf_value "LOGFILE" "${LOG_DIRECTORY}/pihole-FTL.log")"
|
||||||
|
|
||||||
PIHOLE_WEB_SERVER_ACCESS_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/access.log"
|
# PIHOLE_WEB_SERVER_ACCESS_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/access.log" #TODO: FTL access log?
|
||||||
PIHOLE_WEB_SERVER_ERROR_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/error.log"
|
# PIHOLE_WEB_SERVER_ERROR_LOG_FILE="${WEB_SERVER_LOG_DIRECTORY}/error.log" #TODO: FTL Error log?
|
||||||
|
|
||||||
# An array of operating system "pretty names" that we officially support
|
# An array of operating system "pretty names" that we officially support
|
||||||
# We can loop through the array at any time to see if it matches a value
|
# We can loop through the array at any time to see if it matches a value
|
||||||
#SUPPORTED_OS=("Raspbian" "Ubuntu" "Fedora" "Debian" "CentOS")
|
#SUPPORTED_OS=("Raspbian" "Ubuntu" "Fedora" "Debian" "CentOS")
|
||||||
|
|
||||||
# Store Pi-hole's processes in an array for easy use and parsing
|
# Store Pi-hole's processes in an array for easy use and parsing
|
||||||
PIHOLE_PROCESSES=( "lighttpd" "pihole-FTL" )
|
PIHOLE_PROCESSES=( "pihole-FTL" )
|
||||||
|
|
||||||
# Store the required directories in an array so it can be parsed through
|
# Store the required directories in an array so it can be parsed through
|
||||||
#REQUIRED_DIRECTORIES=("${CORE_GIT_DIRECTORY}"
|
#REQUIRED_DIRECTORIES=("${CORE_GIT_DIRECTORY}"
|
||||||
@@ -168,8 +168,8 @@ REQUIRED_FILES=("${PIHOLE_CRON_FILE}"
|
|||||||
"${PIHOLE_DNS_CONFIG_FILE}"
|
"${PIHOLE_DNS_CONFIG_FILE}"
|
||||||
"${PIHOLE_DHCP_CONFIG_FILE}"
|
"${PIHOLE_DHCP_CONFIG_FILE}"
|
||||||
"${PIHOLE_WILDCARD_CONFIG_FILE}"
|
"${PIHOLE_WILDCARD_CONFIG_FILE}"
|
||||||
"${WEB_SERVER_CONFIG_FILE}"
|
#"${WEB_SERVER_CONFIG_FILE}"
|
||||||
"${WEB_SERVER_CUSTOM_CONFIG_FILE}"
|
#"${WEB_SERVER_CUSTOM_CONFIG_FILE}"
|
||||||
"${PIHOLE_INSTALL_LOG_FILE}"
|
"${PIHOLE_INSTALL_LOG_FILE}"
|
||||||
"${PIHOLE_RAW_BLOCKLIST_FILES}"
|
"${PIHOLE_RAW_BLOCKLIST_FILES}"
|
||||||
"${PIHOLE_LOCAL_HOSTS_FILE}"
|
"${PIHOLE_LOCAL_HOSTS_FILE}"
|
||||||
@@ -373,39 +373,6 @@ check_component_versions() {
|
|||||||
check_ftl_version
|
check_ftl_version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get_program_version() {
|
|
||||||
local program_name="${1}"
|
|
||||||
# Create a local variable so this function can be safely reused
|
|
||||||
local program_version
|
|
||||||
echo_current_diagnostic "${program_name} version"
|
|
||||||
# Evaluate the program we are checking, if it is any of the ones below, show the version
|
|
||||||
case "${program_name}" in
|
|
||||||
"lighttpd") program_version="$(${program_name} -v 2> /dev/null | head -n1 | cut -d '/' -f2 | cut -d ' ' -f1)"
|
|
||||||
;;
|
|
||||||
"php") program_version="$(${program_name} -v 2> /dev/null | head -n1 | cut -d '-' -f1 | cut -d ' ' -f2)"
|
|
||||||
;;
|
|
||||||
# If a match is not found, show an error
|
|
||||||
*) echo "Unrecognized program";
|
|
||||||
esac
|
|
||||||
# If the program does not have a version (the variable is empty)
|
|
||||||
if [[ -z "${program_version}" ]]; then
|
|
||||||
# Display and error
|
|
||||||
log_write "${CROSS} ${COL_RED}${program_name} version could not be detected.${COL_NC}"
|
|
||||||
else
|
|
||||||
# Otherwise, display the version
|
|
||||||
log_write "${INFO} ${program_version}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# These are the most critical dependencies of Pi-hole, so we check for them
|
|
||||||
# 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 "lighttpd"
|
|
||||||
get_program_version "php"
|
|
||||||
}
|
|
||||||
|
|
||||||
os_check() {
|
os_check() {
|
||||||
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
||||||
# and determines whether or not the script is running on one of those systems
|
# and determines whether or not the script is running on one of those systems
|
||||||
@@ -758,10 +725,10 @@ compare_port_to_service_assigned() {
|
|||||||
|
|
||||||
check_required_ports() {
|
check_required_ports() {
|
||||||
echo_current_diagnostic "Ports in use"
|
echo_current_diagnostic "Ports in use"
|
||||||
# Since Pi-hole needs 53, 80, and 4711, check what they are being used by
|
# Since Pi-hole needs 53 and 4711, check what they are being used by
|
||||||
# so we can detect any issues
|
# so we can detect any issues
|
||||||
local resolver="pihole-FTL"
|
local resolver="pihole-FTL"
|
||||||
local web_server="lighttpd"
|
local web_server="pihole-FTL"
|
||||||
local ftl="pihole-FTL"
|
local ftl="pihole-FTL"
|
||||||
# Create an array for these ports in use
|
# Create an array for these ports in use
|
||||||
ports_in_use=()
|
ports_in_use=()
|
||||||
@@ -859,13 +826,13 @@ dig_at() {
|
|||||||
|
|
||||||
# Store the arguments as variables with names
|
# Store the arguments as variables with names
|
||||||
local protocol="${1}"
|
local protocol="${1}"
|
||||||
local IP="${2}"
|
|
||||||
echo_current_diagnostic "Name resolution (IPv${protocol}) using a random blocked domain and a known ad-serving domain"
|
echo_current_diagnostic "Name resolution (IPv${protocol}) using a random blocked domain and a known ad-serving domain"
|
||||||
# Set more local variables
|
# Set more local variables
|
||||||
# We need to test name resolution locally, via Pi-hole, and via a public resolver
|
# We need to test name resolution locally, via Pi-hole, and via a public resolver
|
||||||
local local_dig
|
local local_dig
|
||||||
local pihole_dig
|
|
||||||
local remote_dig
|
local remote_dig
|
||||||
|
local interfaces
|
||||||
|
local addresses
|
||||||
# Use a static domain that we know has IPv4 and IPv6 to avoid false positives
|
# Use a static domain that we know has IPv4 and IPv6 to avoid false positives
|
||||||
# Sometimes the randomly chosen domains don't use IPv6, or something else is wrong with them
|
# Sometimes the randomly chosen domains don't use IPv6, or something else is wrong with them
|
||||||
local remote_url="doubleclick.com"
|
local remote_url="doubleclick.com"
|
||||||
@@ -874,15 +841,15 @@ dig_at() {
|
|||||||
if [[ ${protocol} == "6" ]]; then
|
if [[ ${protocol} == "6" ]]; then
|
||||||
# Set the IPv6 variables and record type
|
# Set the IPv6 variables and record type
|
||||||
local local_address="::1"
|
local local_address="::1"
|
||||||
local pihole_address="${IP}"
|
|
||||||
local remote_address="2001:4860:4860::8888"
|
local remote_address="2001:4860:4860::8888"
|
||||||
|
local sed_selector="inet6"
|
||||||
local record_type="AAAA"
|
local record_type="AAAA"
|
||||||
# Otherwise, it should be 4
|
# Otherwise, it should be 4
|
||||||
else
|
else
|
||||||
# so use the IPv4 values
|
# so use the IPv4 values
|
||||||
local local_address="127.0.0.1"
|
local local_address="127.0.0.1"
|
||||||
local pihole_address="${IP}"
|
|
||||||
local remote_address="8.8.8.8"
|
local remote_address="8.8.8.8"
|
||||||
|
local sed_selector="inet"
|
||||||
local record_type="A"
|
local record_type="A"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -892,32 +859,51 @@ dig_at() {
|
|||||||
local random_url
|
local random_url
|
||||||
random_url=$(sqlite3 "${PIHOLE_GRAVITY_DB_FILE}" "SELECT domain FROM vw_gravity ORDER BY RANDOM() LIMIT 1")
|
random_url=$(sqlite3 "${PIHOLE_GRAVITY_DB_FILE}" "SELECT domain FROM vw_gravity ORDER BY RANDOM() LIMIT 1")
|
||||||
|
|
||||||
# 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
|
|
||||||
# If it can, show success
|
|
||||||
log_write "${TICK} ${random_url} ${COL_GREEN}is ${local_dig}${COL_NC} via ${COL_CYAN}localhost$COL_NC (${local_address})"
|
|
||||||
else
|
|
||||||
# Otherwise, show a failure
|
|
||||||
log_write "${CROSS} ${COL_RED}Failed to resolve${COL_NC} ${random_url} via ${COL_RED}localhost${COL_NC} (${local_address})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Next we need to check if Pi-hole can resolve a domain when the query is sent to it's IP address
|
# Next we need to check if Pi-hole can resolve a domain when the query is sent to it's IP address
|
||||||
# This better emulates how clients will interact with Pi-hole as opposed to above where Pi-hole is
|
# This better emulates how clients will interact with Pi-hole as opposed to above where Pi-hole is
|
||||||
# just asing itself locally
|
# just asing itself locally
|
||||||
# The default timeouts and tries are reduced in case the DNS server isn't working, so the user isn't waiting for too long
|
# The default timeouts and tries are reduced in case the DNS server isn't working, so the user isn't
|
||||||
|
# waiting for too long
|
||||||
|
#
|
||||||
|
# Turn off history expansion such that the "!" in the sed command cannot do silly things
|
||||||
|
set +H
|
||||||
|
# Get interfaces
|
||||||
|
# sed logic breakdown:
|
||||||
|
# / master /d;
|
||||||
|
# Removes all interfaces that are slaves of others (e.g. virtual docker interfaces)
|
||||||
|
# /UP/!d;
|
||||||
|
# Removes all interfaces which are not UP
|
||||||
|
# s/^[0-9]*: //g;
|
||||||
|
# Removes interface index
|
||||||
|
# s/: <.*//g;
|
||||||
|
# Removes everything after the interface name
|
||||||
|
interfaces="$(ip link show | sed "/ master /d;/UP/!d;s/^[0-9]*: //g;s/: <.*//g;")"
|
||||||
|
|
||||||
# If Pi-hole can dig itself from it's IP (not the loopback address)
|
while IFS= read -r iface ; do
|
||||||
if pihole_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @"${pihole_address}" +short "${record_type}"); then
|
# Get addresses of current interface
|
||||||
# show a success
|
# sed logic breakdown:
|
||||||
log_write "${TICK} ${random_url} ${COL_GREEN}is ${pihole_dig}${COL_NC} via ${COL_CYAN}Pi-hole${COL_NC} (${pihole_address})"
|
# /inet(|6) /!d;
|
||||||
else
|
# Removes all lines from ip a that do not contain either "inet " or "inet6 "
|
||||||
# Otherwise, show a failure
|
# s/^.*inet(|6) //g;
|
||||||
log_write "${CROSS} ${COL_RED}Failed to resolve${COL_NC} ${random_url} via ${COL_RED}Pi-hole${COL_NC} (${pihole_address})"
|
# Removes all leading whitespace as well as the "inet " or "inet6 " string
|
||||||
fi
|
# s/\/.*$//g;
|
||||||
|
# Removes CIDR and everything thereafter (e.g., scope properties)
|
||||||
|
addresses="$(ip address show dev "${iface}" | sed "/${sed_selector} /!d;s/^.*${sed_selector} //g;s/\/.*$//g;")"
|
||||||
|
while IFS= read -r local_address ; do
|
||||||
|
# Check 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
|
||||||
|
# If it can, show success
|
||||||
|
log_write "${TICK} ${random_url} ${COL_GREEN}is ${local_dig}${COL_NC} on ${COL_CYAN}${iface}${COL_NC} (${COL_CYAN}${local_address}${COL_NC})"
|
||||||
|
else
|
||||||
|
# Otherwise, show a failure
|
||||||
|
log_write "${CROSS} ${COL_RED}Failed to resolve${COL_NC} ${random_url} on ${COL_RED}${iface}${COL_NC} (${COL_RED}${local_address}${COL_NC})"
|
||||||
|
fi
|
||||||
|
done <<< "${addresses}"
|
||||||
|
done <<< "${interfaces}"
|
||||||
|
|
||||||
# Finally, we need to make sure legitimate queries can out to the Internet using an external, public DNS server
|
# Finally, we need to make sure legitimate queries can out to the Internet using an external, public DNS server
|
||||||
# We are using the static remote_url here instead of a random one because we know it works with IPv4 and IPv6
|
# We are using the static remote_url here instead of a random one because we know it works with IPv4 and IPv6
|
||||||
if remote_dig=$(dig +tries=1 +time=2 -"${protocol}" "${remote_url}" @${remote_address} +short "${record_type}" | head -n1); then
|
if remote_dig=$(dig +tries=1 +time=2 -"${protocol}" "${remote_url}" @"${remote_address}" +short "${record_type}" | head -n1); then
|
||||||
# If successful, the real IP of the domain will be returned instead of Pi-hole's IP
|
# If successful, the real IP of the domain will be returned instead of Pi-hole's IP
|
||||||
log_write "${TICK} ${remote_url} ${COL_GREEN}is ${remote_dig}${COL_NC} via ${COL_CYAN}a remote, public DNS server${COL_NC} (${remote_address})"
|
log_write "${TICK} ${remote_url} ${COL_GREEN}is ${remote_dig}${COL_NC} via ${COL_CYAN}a remote, public DNS server${COL_NC} (${remote_address})"
|
||||||
else
|
else
|
||||||
@@ -1032,7 +1018,7 @@ parse_file() {
|
|||||||
local file_lines
|
local file_lines
|
||||||
# For each line in the file,
|
# For each line in the file,
|
||||||
for file_lines in "${file_info[@]}"; do
|
for file_lines in "${file_info[@]}"; do
|
||||||
if [[ ! -z "${file_lines}" ]]; then
|
if [[ -n "${file_lines}" ]]; then
|
||||||
# don't include the Web password hash
|
# don't include the Web password hash
|
||||||
[[ "${file_lines}" =~ ^\#.*$ || ! "${file_lines}" || "${file_lines}" == "WEBPASSWORD="* ]] && continue
|
[[ "${file_lines}" =~ ^\#.*$ || ! "${file_lines}" || "${file_lines}" == "WEBPASSWORD="* ]] && continue
|
||||||
# otherwise, display the lines of the file
|
# otherwise, display the lines of the file
|
||||||
@@ -1046,12 +1032,8 @@ parse_file() {
|
|||||||
check_name_resolution() {
|
check_name_resolution() {
|
||||||
# Check name resolution from localhost, Pi-hole's IP, and Google's name severs
|
# Check name resolution from localhost, Pi-hole's IP, and Google's name severs
|
||||||
# using the function we created earlier
|
# using the function we created earlier
|
||||||
dig_at 4 "${IPV4_ADDRESS%/*}"
|
dig_at 4
|
||||||
# If IPv6 enabled,
|
dig_at 6
|
||||||
if [[ "${IPV6_ADDRESS}" ]]; then
|
|
||||||
# check resolution
|
|
||||||
dig_at 6 "${IPV6_ADDRESS%/*}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function can check a directory exists
|
# This function can check a directory exists
|
||||||
@@ -1281,56 +1263,74 @@ analyze_gravity_list() {
|
|||||||
IFS="$OLD_IFS"
|
IFS="$OLD_IFS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obfuscated_pihole_log() {
|
||||||
|
local pihole_log=("$@")
|
||||||
|
local line
|
||||||
|
local error_to_check_for
|
||||||
|
local line_to_obfuscate
|
||||||
|
local obfuscated_line
|
||||||
|
for line in "${pihole_log[@]}"; do
|
||||||
|
# A common error in the pihole.log is when there is a non-hosts formatted file
|
||||||
|
# that the DNS server is attempting to read. Since it's not formatted
|
||||||
|
# correctly, there will be an entry for "bad address at line n"
|
||||||
|
# So we can check for that here and highlight it in red so the user can see it easily
|
||||||
|
error_to_check_for=$(echo "${line}" | grep 'bad address at')
|
||||||
|
# Some users may not want to have the domains they visit sent to us
|
||||||
|
# To that end, we check for lines in the log that would contain a domain name
|
||||||
|
line_to_obfuscate=$(echo "${line}" | grep ': query\|: forwarded\|: reply')
|
||||||
|
# If the variable contains a value, it found an error in the log
|
||||||
|
if [[ -n ${error_to_check_for} ]]; then
|
||||||
|
# So we can print it in red to make it visible to the user
|
||||||
|
log_write " ${CROSS} ${COL_RED}${line}${COL_NC} (${FAQ_BAD_ADDRESS})"
|
||||||
|
else
|
||||||
|
# If the variable does not a value (the current default behavior), so do not obfuscate anything
|
||||||
|
if [[ -z ${OBFUSCATE} ]]; then
|
||||||
|
log_write " ${line}"
|
||||||
|
# Othwerise, a flag was passed to this command to obfuscate domains in the log
|
||||||
|
else
|
||||||
|
# So first check if there are domains in the log that should be obfuscated
|
||||||
|
if [[ -n ${line_to_obfuscate} ]]; then
|
||||||
|
# If there are, we need to use awk to replace only the domain name (the 6th field in the log)
|
||||||
|
# so we substitute the domain for the placeholder value
|
||||||
|
obfuscated_line=$(echo "${line_to_obfuscate}" | awk -v placeholder="${OBFUSCATED_PLACEHOLDER}" '{sub($6,placeholder); print $0}')
|
||||||
|
log_write " ${obfuscated_line}"
|
||||||
|
else
|
||||||
|
log_write " ${line}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
analyze_pihole_log() {
|
analyze_pihole_log() {
|
||||||
echo_current_diagnostic "Pi-hole log"
|
echo_current_diagnostic "Pi-hole log"
|
||||||
local head_line
|
local pihole_log_head=()
|
||||||
# Put the current Internal Field Separator into another variable so it can be restored later
|
local pihole_log_tail=()
|
||||||
OLD_IFS="$IFS"
|
local pihole_log_permissions
|
||||||
# Get the lines that are in the file(s) and store them in an array for parsing later
|
local logging_enabled
|
||||||
IFS=$'\r\n'
|
|
||||||
local pihole_log_permissions
|
logging_enabled=$(grep -c "^log-queries" /etc/dnsmasq.d/01-pihole.conf)
|
||||||
pihole_log_permissions=$(ls -ld "${PIHOLE_LOG}")
|
if [[ "${logging_enabled}" == "0" ]]; then
|
||||||
log_write "${COL_GREEN}${pihole_log_permissions}${COL_NC}"
|
# Inform user that logging has been disabled and pihole.log does not contain queries
|
||||||
local pihole_log_head=()
|
log_write "${INFO} Query logging is disabled"
|
||||||
mapfile -t pihole_log_head < <(head -n 20 ${PIHOLE_LOG})
|
log_write ""
|
||||||
log_write " ${COL_CYAN}-----head of $(basename ${PIHOLE_LOG})------${COL_NC}"
|
fi
|
||||||
local error_to_check_for
|
# Put the current Internal Field Separator into another variable so it can be restored later
|
||||||
local line_to_obfuscate
|
OLD_IFS="$IFS"
|
||||||
local obfuscated_line
|
# Get the lines that are in the file(s) and store them in an array for parsing later
|
||||||
for head_line in "${pihole_log_head[@]}"; do
|
IFS=$'\r\n'
|
||||||
# A common error in the pihole.log is when there is a non-hosts formatted file
|
pihole_log_permissions=$(ls -ld "${PIHOLE_LOG}")
|
||||||
# that the DNS server is attempting to read. Since it's not formatted
|
log_write "${COL_GREEN}${pihole_log_permissions}${COL_NC}"
|
||||||
# correctly, there will be an entry for "bad address at line n"
|
mapfile -t pihole_log_head < <(head -n 20 ${PIHOLE_LOG})
|
||||||
# So we can check for that here and highlight it in red so the user can see it easily
|
log_write " ${COL_CYAN}-----head of $(basename ${PIHOLE_LOG})------${COL_NC}"
|
||||||
error_to_check_for=$(echo "${head_line}" | grep 'bad address at')
|
obfuscated_pihole_log "${pihole_log_head[@]}"
|
||||||
# Some users may not want to have the domains they visit sent to us
|
log_write ""
|
||||||
# To that end, we check for lines in the log that would contain a domain name
|
mapfile -t pihole_log_tail < <(tail -n 20 ${PIHOLE_LOG})
|
||||||
line_to_obfuscate=$(echo "${head_line}" | grep ': query\|: forwarded\|: reply')
|
log_write " ${COL_CYAN}-----tail of $(basename ${PIHOLE_LOG})------${COL_NC}"
|
||||||
# If the variable contains a value, it found an error in the log
|
obfuscated_pihole_log "${pihole_log_tail[@]}"
|
||||||
if [[ -n ${error_to_check_for} ]]; then
|
log_write ""
|
||||||
# So we can print it in red to make it visible to the user
|
# Set the IFS back to what it was
|
||||||
log_write " ${CROSS} ${COL_RED}${head_line}${COL_NC} (${FAQ_BAD_ADDRESS})"
|
IFS="$OLD_IFS"
|
||||||
else
|
|
||||||
# If the variable does not a value (the current default behavior), so do not obfuscate anything
|
|
||||||
if [[ -z ${OBFUSCATE} ]]; then
|
|
||||||
log_write " ${head_line}"
|
|
||||||
# Othwerise, a flag was passed to this command to obfuscate domains in the log
|
|
||||||
else
|
|
||||||
# So first check if there are domains in the log that should be obfuscated
|
|
||||||
if [[ -n ${line_to_obfuscate} ]]; then
|
|
||||||
# If there are, we need to use awk to replace only the domain name (the 6th field in the log)
|
|
||||||
# so we substitute the domain for the placeholder value
|
|
||||||
obfuscated_line=$(echo "${line_to_obfuscate}" | awk -v placeholder="${OBFUSCATED_PLACEHOLDER}" '{sub($6,placeholder); print $0}')
|
|
||||||
log_write " ${obfuscated_line}"
|
|
||||||
else
|
|
||||||
log_write " ${head_line}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
log_write ""
|
|
||||||
# Set the IFS back to what it was
|
|
||||||
IFS="$OLD_IFS"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tricorder_use_nc_or_curl() {
|
tricorder_use_nc_or_curl() {
|
||||||
@@ -1423,7 +1423,6 @@ initialize_debug
|
|||||||
# available to the other functions
|
# available to the other functions
|
||||||
source_setup_variables
|
source_setup_variables
|
||||||
check_component_versions
|
check_component_versions
|
||||||
check_critical_program_versions
|
|
||||||
diagnose_operating_system
|
diagnose_operating_system
|
||||||
check_selinux
|
check_selinux
|
||||||
check_firewalld
|
check_firewalld
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
# (c) 2018 Pi-hole, LLC (https://pi-hole.net)
|
# (c) 2018 Pi-hole, LLC (https://pi-hole.net)
|
||||||
# Network-wide ad blocking via your own hardware.
|
# Network-wide ad blocking via your own hardware.
|
||||||
|
@@ -273,11 +273,6 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prevent Firefox from automatically switching over to DNS-over-HTTPS
|
|
||||||
# This follows https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https
|
|
||||||
# (sourced 7th September 2019)
|
|
||||||
add_dnsmasq_setting "server=/use-application-dns.net/"
|
|
||||||
|
|
||||||
# We need to process DHCP settings here as well to account for possible
|
# We need to process DHCP settings here as well to account for possible
|
||||||
# changes in the non-FQDN forwarding. This cannot be done in 01-pihole.conf
|
# changes in the non-FQDN forwarding. This cannot be done in 01-pihole.conf
|
||||||
# as we don't want to delete all local=/.../ lines so it's much safer to
|
# as we don't want to delete all local=/.../ lines so it's much safer to
|
||||||
@@ -426,7 +421,7 @@ dhcp-leasefile=/etc/pihole/dhcp.leases
|
|||||||
echo "#quiet-dhcp6
|
echo "#quiet-dhcp6
|
||||||
#enable-ra
|
#enable-ra
|
||||||
dhcp-option=option6:dns-server,[::]
|
dhcp-option=option6:dns-server,[::]
|
||||||
dhcp-range=::100,::1ff,constructor:${interface},ra-names,slaac,${leasetime}
|
dhcp-range=::100,::1ff,constructor:${interface},ra-names,slaac,64,3600
|
||||||
ra-param=*,0,0
|
ra-param=*,0,0
|
||||||
" >> "${dhcpconfig}"
|
" >> "${dhcpconfig}"
|
||||||
fi
|
fi
|
||||||
@@ -716,7 +711,7 @@ RemoveCustomDNSAddress() {
|
|||||||
host="${args[3]}"
|
host="${args[3]}"
|
||||||
|
|
||||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
sed -i "/${ip} ${host}/d" "${dnscustomfile}"
|
sed -i "/^${ip} ${host}$/d" "${dnscustomfile}"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Invalid IP has been passed"
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -731,7 +726,6 @@ AddCustomCNAMERecord() {
|
|||||||
|
|
||||||
domain="${args[2]}"
|
domain="${args[2]}"
|
||||||
target="${args[3]}"
|
target="${args[3]}"
|
||||||
|
|
||||||
echo "cname=${domain},${target}" >> "${dnscustomcnamefile}"
|
echo "cname=${domain},${target}" >> "${dnscustomcnamefile}"
|
||||||
|
|
||||||
# Restart dnsmasq to load new custom CNAME records
|
# Restart dnsmasq to load new custom CNAME records
|
||||||
@@ -748,7 +742,7 @@ RemoveCustomCNAMERecord() {
|
|||||||
if [[ -n "${validDomain}" ]]; then
|
if [[ -n "${validDomain}" ]]; then
|
||||||
validTarget="$(checkDomain "${target}")"
|
validTarget="$(checkDomain "${target}")"
|
||||||
if [[ -n "${validDomain}" ]]; then
|
if [[ -n "${validDomain}" ]]; then
|
||||||
sed -i "/cname=${validDomain},${validTarget}/d" "${dnscustomcnamefile}"
|
sed -i "/cname=${validDomain},${validTarget}$/d" "${dnscustomcnamefile}"
|
||||||
else
|
else
|
||||||
echo " ${CROSS} Invalid Target Passed!"
|
echo " ${CROSS} Invalid Target Passed!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@@ -50,9 +50,6 @@ EOM
|
|||||||
installLogLoc=/etc/pihole/install.log
|
installLogLoc=/etc/pihole/install.log
|
||||||
# This is an important file as it contains information specific to the machine it's being installed on
|
# This is an important file as it contains information specific to the machine it's being installed on
|
||||||
setupVars=/etc/pihole/setupVars.conf
|
setupVars=/etc/pihole/setupVars.conf
|
||||||
# Pi-hole uses lighttpd as a Web server, and this is the config file for it
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
lighttpdConfig=/etc/lighttpd/lighttpd.conf
|
|
||||||
# This is a file used for the colorized output
|
# This is a file used for the colorized output
|
||||||
coltable=/opt/pihole/COL_TABLE
|
coltable=/opt/pihole/COL_TABLE
|
||||||
|
|
||||||
@@ -87,6 +84,7 @@ IPV6_ADDRESS=${IPV6_ADDRESS}
|
|||||||
# Give settings their default values. These may be changed by prompts later in the script.
|
# Give settings their default values. These may be changed by prompts later in the script.
|
||||||
QUERY_LOGGING=true
|
QUERY_LOGGING=true
|
||||||
INSTALL_WEB_INTERFACE=true
|
INSTALL_WEB_INTERFACE=true
|
||||||
|
WEBPORT=8080
|
||||||
PRIVACY_LEVEL=0
|
PRIVACY_LEVEL=0
|
||||||
CACHE_SIZE=10000
|
CACHE_SIZE=10000
|
||||||
|
|
||||||
@@ -118,13 +116,11 @@ c=$(( c < 70 ? 70 : c ))
|
|||||||
# The runUnattended flag is one example of this
|
# The runUnattended flag is one example of this
|
||||||
reconfigure=false
|
reconfigure=false
|
||||||
runUnattended=false
|
runUnattended=false
|
||||||
INSTALL_WEB_SERVER=true
|
|
||||||
# Check arguments for the undocumented flags
|
# Check arguments for the undocumented flags
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"--reconfigure" ) reconfigure=true;;
|
"--reconfigure" ) reconfigure=true;;
|
||||||
"--unattended" ) runUnattended=true;;
|
"--unattended" ) runUnattended=true;;
|
||||||
"--disable-install-webserver" ) INSTALL_WEB_SERVER=false;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -303,88 +299,29 @@ if is_command apt-get ; then
|
|||||||
printf " %b Enabled %s\\n" "${TICK}" "'universe' repository"
|
printf " %b Enabled %s\\n" "${TICK}" "'universe' repository"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Update package cache. This is required already here to assure apt-cache calls have package lists available.
|
# Update package cache
|
||||||
update_package_cache || exit 1
|
update_package_cache || exit 1
|
||||||
# Debian 7 doesn't have iproute2 so check if it's available first
|
|
||||||
if apt-cache show iproute2 > /dev/null 2>&1; then
|
|
||||||
iproute_pkg="iproute2"
|
|
||||||
# Otherwise, check if iproute is available
|
|
||||||
elif apt-cache show iproute > /dev/null 2>&1; then
|
|
||||||
iproute_pkg="iproute"
|
|
||||||
# Else print error and exit
|
|
||||||
else
|
|
||||||
printf " %b Aborting installation: iproute2 and iproute packages were not found in APT repository.\\n" "${CROSS}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Check for and determine version number (major and minor) of current php install
|
|
||||||
if is_command php ; then
|
|
||||||
printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "$(php <<< "<?php echo PHP_VERSION ?>")"
|
|
||||||
printf -v phpInsMajor "%d" "$(php <<< "<?php echo PHP_MAJOR_VERSION ?>")"
|
|
||||||
printf -v phpInsMinor "%d" "$(php <<< "<?php echo PHP_MINOR_VERSION ?>")"
|
|
||||||
# Is installed php version 7.0 or greater
|
|
||||||
if [ "${phpInsMajor}" -ge 7 ]; then
|
|
||||||
phpInsNewer=true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Several other packages depend on the version of PHP. If PHP is not installed, or an insufficient version,
|
|
||||||
# those packages should fall back to the default (latest?)
|
|
||||||
if [[ "$phpInsNewer" != true ]]; then
|
|
||||||
# Prefer the php metapackage if it's there
|
|
||||||
if apt-cache show php > /dev/null 2>&1; then
|
|
||||||
phpVer="php"
|
|
||||||
# Else fall back on the php5 package if it's there
|
|
||||||
elif apt-cache show php5 > /dev/null 2>&1; then
|
|
||||||
phpVer="php5"
|
|
||||||
# Else print error and exit
|
|
||||||
else
|
|
||||||
printf " %b Aborting installation: No PHP packages were found in APT repository.\\n" "${CROSS}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Else, PHP is already installed at a version beyond v7.0, so the additional packages
|
|
||||||
# should match version with the current PHP version.
|
|
||||||
phpVer="php$phpInsMajor.$phpInsMinor"
|
|
||||||
fi
|
|
||||||
# We also need the correct version for `php-sqlite` (which differs across distros)
|
|
||||||
if apt-cache show "${phpVer}-sqlite3" > /dev/null 2>&1; then
|
|
||||||
phpSqlite="sqlite3"
|
|
||||||
elif apt-cache show "${phpVer}-sqlite" > /dev/null 2>&1; then
|
|
||||||
phpSqlite="sqlite"
|
|
||||||
else
|
|
||||||
printf " %b Aborting installation: No SQLite PHP module was found in APT repository.\\n" "${CROSS}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Packages required to run this install script (stored as an array)
|
|
||||||
INSTALLER_DEPS=(dhcpcd5 git "${iproute_pkg}" whiptail dnsutils)
|
|
||||||
# Packages required to run Pi-hole (stored as an array)
|
|
||||||
PIHOLE_DEPS=(cron curl iputils-ping lsof netcat psmisc sudo unzip idn2 sqlite3 libcap2-bin dns-root-data libcap2)
|
|
||||||
# Packages required for the Web admin interface (stored as an array)
|
|
||||||
# It's useful to separate this from Pi-hole, since the two repos are also setup separately
|
|
||||||
PIHOLE_WEB_DEPS=(lighttpd "${phpVer}-common" "${phpVer}-cgi" "${phpVer}-${phpSqlite}" "${phpVer}-xml" "${phpVer}-intl")
|
|
||||||
# Prior to PHP8.0, JSON functionality is provided as dedicated module, required by Pi-hole AdminLTE: https://www.php.net/manual/json.installation.php
|
|
||||||
if [[ "${phpInsNewer}" != true || "${phpInsMajor}" -lt 8 ]]; then
|
|
||||||
PIHOLE_WEB_DEPS+=("${phpVer}-json")
|
|
||||||
fi
|
|
||||||
# The Web server user,
|
|
||||||
LIGHTTPD_USER="www-data"
|
|
||||||
# group,
|
|
||||||
LIGHTTPD_GROUP="www-data"
|
|
||||||
# and config file
|
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
|
||||||
|
|
||||||
# This function waits for dpkg to unlock, which signals that the previous apt-get command has finished.
|
# Since our install script is so large, we need several other programs to successfully get a machine provisioned
|
||||||
|
# These programs are stored in an array so they can be looped through later
|
||||||
|
INSTALLER_DEPS=(dhcpcd5 git iproute2 whiptail dnsutils)
|
||||||
|
# Pi-hole itself has several dependencies that also need to be installed
|
||||||
|
PIHOLE_DEPS=(cron curl iputils-ping lsof netcat psmisc sudo unzip wget idn2 sqlite3 libcap2-bin dns-root-data libcap2)
|
||||||
|
|
||||||
|
# A function to check...
|
||||||
test_dpkg_lock() {
|
test_dpkg_lock() {
|
||||||
|
# An iterator used for counting loop iterations
|
||||||
i=0
|
i=0
|
||||||
# fuser is a program to show which processes use the named files, sockets, or filesystems
|
# fuser is a program to show which processes use the named files, sockets, or filesystems
|
||||||
# So while the lock is held,
|
# So while the command is true
|
||||||
while fuser /var/lib/dpkg/lock >/dev/null 2>&1
|
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
|
||||||
do
|
# Wait half a second
|
||||||
# we wait half a second,
|
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
# increase the iterator,
|
# and increase the iterator
|
||||||
((i=i+1))
|
((i=i+1))
|
||||||
done
|
done
|
||||||
# and then report success once dpkg is unlocked.
|
# Always return success, since we only return if there is no
|
||||||
|
# lock (anymore)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,92 +339,27 @@ elif is_command rpm ; then
|
|||||||
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
|
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
|
||||||
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig bind-utils)
|
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig bind-utils)
|
||||||
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlite libcap lsof)
|
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlite libcap lsof)
|
||||||
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xml php-json php-intl)
|
|
||||||
LIGHTTPD_USER="lighttpd"
|
|
||||||
LIGHTTPD_GROUP="lighttpd"
|
|
||||||
LIGHTTPD_CFG="lighttpd.conf.fedora"
|
|
||||||
# If the host OS is Fedora,
|
# If the host OS is Fedora,
|
||||||
if grep -qiE 'fedora|fedberry' /etc/redhat-release; then
|
if grep -qiE 'fedora' /etc/redhat-release; then
|
||||||
# all required packages should be available by default with the latest fedora release
|
# all required packages should be available by default with the latest fedora release
|
||||||
: # continue
|
: # continue
|
||||||
# or if host OS is CentOS,
|
# or if host OS is CentOS,
|
||||||
elif grep -qiE 'centos|scientific' /etc/redhat-release; then
|
elif grep -qiE 'centos|scientific' /etc/redhat-release; then
|
||||||
# Pi-Hole currently supports CentOS 7+ with PHP7+
|
# CentOS 7 requires the EPEL repository for the following package(s): libidn2
|
||||||
SUPPORTED_CENTOS_VERSION=7
|
|
||||||
SUPPORTED_CENTOS_PHP_VERSION=7
|
|
||||||
# Check current CentOS major release version
|
|
||||||
CURRENT_CENTOS_VERSION=$(grep -oP '(?<= )[0-9]+(?=\.?)' /etc/redhat-release)
|
CURRENT_CENTOS_VERSION=$(grep -oP '(?<= )[0-9]+(?=\.?)' /etc/redhat-release)
|
||||||
# Check if CentOS version is supported
|
|
||||||
if [[ $CURRENT_CENTOS_VERSION -lt $SUPPORTED_CENTOS_VERSION ]]; then
|
|
||||||
printf " %b CentOS %s is not supported.\\n" "${CROSS}" "${CURRENT_CENTOS_VERSION}"
|
|
||||||
printf " Please update to CentOS release %s or later.\\n" "${SUPPORTED_CENTOS_VERSION}"
|
|
||||||
# exit the installer
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
# php-json is not required on CentOS 7 as it is already compiled into php
|
|
||||||
# verifiy via `php -m | grep json`
|
|
||||||
if [[ $CURRENT_CENTOS_VERSION -eq 7 ]]; then
|
if [[ $CURRENT_CENTOS_VERSION -eq 7 ]]; then
|
||||||
# create a temporary array as arrays are not designed for use as mutable data structures
|
printf " %b CentOS 7 requires EPEL Repository.\\n" "${INFO}"
|
||||||
CENTOS7_PIHOLE_WEB_DEPS=()
|
EPEL_PKG="epel-release"
|
||||||
for i in "${!PIHOLE_WEB_DEPS[@]}"; do
|
rpm -q ${EPEL_PKG} &> /dev/null || rc=$?
|
||||||
if [[ ${PIHOLE_WEB_DEPS[i]} != "php-json" ]]; then
|
if [[ $rc -ne 0 ]]; then
|
||||||
CENTOS7_PIHOLE_WEB_DEPS+=( "${PIHOLE_WEB_DEPS[i]}" )
|
printf " %b Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)\\n" "${INFO}"
|
||||||
fi
|
"${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null
|
||||||
done
|
printf " %b Installed %s\\n" "${TICK}" "${EPEL_PKG}"
|
||||||
# re-assign the clean dependency array back to PIHOLE_WEB_DEPS
|
|
||||||
PIHOLE_WEB_DEPS=("${CENTOS7_PIHOLE_WEB_DEPS[@]}")
|
|
||||||
unset CENTOS7_PIHOLE_WEB_DEPS
|
|
||||||
fi
|
|
||||||
# CentOS requires 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
|
|
||||||
printf " %b Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)\\n" "${INFO}"
|
|
||||||
"${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null
|
|
||||||
printf " %b Installed %s\\n" "${TICK}" "${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
|
|
||||||
printf " %b User opt-out of PHP 7 upgrade on CentOS. Deprecated PHP may be in use.\\n" "${INFO}"
|
|
||||||
: # continue with unsupported php version
|
|
||||||
else
|
|
||||||
printf " %b Enabling Remi's RPM repository (https://rpms.remirepo.net)\\n" "${INFO}"
|
|
||||||
"${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
|
|
||||||
printf " %b Remi's RPM repository has been enabled for PHP7\\n" "${TICK}"
|
|
||||||
# trigger an install/update of PHP to ensure previous version of PHP is updated from REMI
|
|
||||||
if "${PKG_INSTALL[@]}" "php-cli" &> /dev/null; then
|
|
||||||
printf " %b PHP7 installed/updated via Remi's RPM repository\\n" "${TICK}"
|
|
||||||
else
|
|
||||||
printf " %b There was a problem updating to PHP7 via Remi's RPM repository\\n" "${CROSS}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# Warn user of unsupported version of Fedora or CentOS
|
printf " %b Continuing installation with unsupported RPM based distribution\\n" "${INFO}"
|
||||||
if ! whiptail --defaultno --title "Unsupported RPM based distribution" --yesno "Would you like to continue installation on an unsupported RPM based distribution?\\n\\nPlease ensure the following packages have been installed manually:\\n\\n- lighttpd\\n- lighttpd-fastcgi\\n- PHP version 7+" "${r}" "${c}"; then
|
|
||||||
printf " %b Aborting installation due to unsupported RPM based distribution\\n" "${CROSS}"
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
printf " %b Continuing installation with unsupported RPM based distribution\\n" "${INFO}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If neither apt-get or yum/dnf package managers were found
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
@@ -1249,40 +1121,20 @@ setAdminFlag() {
|
|||||||
printf " %b Web Interface On\\n" "${INFO}"
|
printf " %b Web Interface On\\n" "${INFO}"
|
||||||
# Set it to true
|
# Set it to true
|
||||||
INSTALL_WEB_INTERFACE=true
|
INSTALL_WEB_INTERFACE=true
|
||||||
|
|
||||||
|
#Web port
|
||||||
|
# Ask for the IPv4 address
|
||||||
|
WEBPORT=$(whiptail --backtitle "Setting web interface port" --title "Web Port" --inputbox "By default, pihole-FTL listens for http traffic on port 8080. If you wish to change the port, you may do so now. You can also do it later by editing /etc/pihole/pihole-FTL.conf" "${r}" "${c}" "${WEBPORT}" 3>&1 1>&2 2>&3) || \
|
||||||
|
# Canceling IPv4 settings window
|
||||||
|
{ echo -e " ${COL_LIGHT_RED}Cancel was selected, exiting installer${COL_NC}"; exit 1; }
|
||||||
|
printf " %b The Web interface will be accessible on port: %s\\n" "${INFO}" "${WEBPORT}"
|
||||||
;;
|
;;
|
||||||
Off)
|
Off)
|
||||||
printf " %b Web Interface Off\\n" "${INFO}"
|
printf " %b Web Interface Off\\n" "${INFO}"
|
||||||
# or false
|
# or false
|
||||||
INSTALL_WEB_INTERFACE=false
|
INSTALL_WEB_INTERFACE=false
|
||||||
# Deselect the web server as well, since it is obsolete then
|
|
||||||
INSTALL_WEB_SERVER=false
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# If the user wants to install the Web admin interface (i.e. it has not been deselected above)
|
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
# Get list of required PHP modules, excluding base package (common) and handler (cgi)
|
|
||||||
local i php_modules
|
|
||||||
for i in "${PIHOLE_WEB_DEPS[@]}"; do [[ $i == 'php'* && $i != *'-common' && $i != *'-cgi' ]] && php_modules+=" ${i#*-}"; done
|
|
||||||
WebToggleCommand=(whiptail --separate-output --radiolist "Do you wish to install the web server (lighttpd) and required PHP modules?\\n\\nNB: If you disable this, and, do not have an existing web server and required PHP modules (${php_modules# }) installed, the web interface will not function. Additionally the web server user needs to be member of the \"pihole\" group for full functionality." "${r}" "${c}" 6)
|
|
||||||
# Enable as default and recommended option
|
|
||||||
WebChooseOptions=("On (Recommended)" "" on
|
|
||||||
Off "" off)
|
|
||||||
WebChoices=$("${WebToggleCommand[@]}" "${WebChooseOptions[@]}" 2>&1 >/dev/tty) || (printf " %bCancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" && exit 1)
|
|
||||||
# Depending on their choice
|
|
||||||
case ${WebChoices} in
|
|
||||||
"On (Recommended)")
|
|
||||||
printf " %b Web Server On\\n" "${INFO}"
|
|
||||||
# set it to true, as clearly seen below.
|
|
||||||
INSTALL_WEB_SERVER=true
|
|
||||||
;;
|
|
||||||
Off)
|
|
||||||
printf " %b Web Server Off\\n" "${INFO}"
|
|
||||||
# or false
|
|
||||||
INSTALL_WEB_SERVER=false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# A function to display a list of example blocklists for users to select
|
# A function to display a list of example blocklists for users to select
|
||||||
@@ -1485,35 +1337,6 @@ installConfigs() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the user chose to install the dashboard,
|
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
# and if the Web server conf directory does not exist,
|
|
||||||
if [[ ! -d "/etc/lighttpd" ]]; then
|
|
||||||
# make it and set the owners
|
|
||||||
install -d -m 755 -o "${USER}" -g root /etc/lighttpd
|
|
||||||
# Otherwise, if the config file already exists
|
|
||||||
elif [[ -f "/etc/lighttpd/lighttpd.conf" ]]; then
|
|
||||||
# back up the original
|
|
||||||
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
|
|
||||||
fi
|
|
||||||
# and copy in the config file Pi-hole needs
|
|
||||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
|
||||||
# Make sure the external.conf file exists, as lighttpd v1.4.50 crashes without it
|
|
||||||
touch /etc/lighttpd/external.conf
|
|
||||||
chmod 644 /etc/lighttpd/external.conf
|
|
||||||
# If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config
|
|
||||||
if [[ -f "${PI_HOLE_BLOCKPAGE_DIR}/custom.php" ]]; then
|
|
||||||
sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"pihole\/custom\.php"/' /etc/lighttpd/lighttpd.conf
|
|
||||||
fi
|
|
||||||
# Make the directories if they do not exist and set the owners
|
|
||||||
mkdir -p /run/lighttpd
|
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /run/lighttpd
|
|
||||||
mkdir -p /var/cache/lighttpd/compress
|
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress
|
|
||||||
mkdir -p /var/cache/lighttpd/uploads
|
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_manpage() {
|
install_manpage() {
|
||||||
@@ -1651,9 +1474,6 @@ disable_resolved_stublistener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_package_cache() {
|
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)
|
|
||||||
|
|
||||||
# Update package cache on apt based OSes. Do this every time since
|
# Update package cache on apt based OSes. Do this every time since
|
||||||
# it's quick and packages can be updated at any time.
|
# it's quick and packages can be updated at any time.
|
||||||
|
|
||||||
@@ -1731,6 +1551,8 @@ install_dependent_packages() {
|
|||||||
# If there's anything to install, install everything in the list.
|
# If there's anything to install, install everything in the list.
|
||||||
if [[ "${#installArray[@]}" -gt 0 ]]; then
|
if [[ "${#installArray[@]}" -gt 0 ]]; then
|
||||||
test_dpkg_lock
|
test_dpkg_lock
|
||||||
|
# Running apt-get install with minimal output can cause some issues with
|
||||||
|
# requiring user input (e.g password for phpmyadmin see #218)
|
||||||
printf " %b Processing %s install(s) for: %s, please wait...\\n" "${INFO}" "${PKG_MANAGER}" "${installArray[*]}"
|
printf " %b Processing %s install(s) for: %s, please wait...\\n" "${INFO}" "${PKG_MANAGER}" "${installArray[*]}"
|
||||||
printf '%*s\n' "$columns" '' | tr " " -;
|
printf '%*s\n' "$columns" '' | tr " " -;
|
||||||
"${PKG_INSTALL[@]}" "${installArray[@]}"
|
"${PKG_INSTALL[@]}" "${installArray[@]}"
|
||||||
@@ -1764,58 +1586,6 @@ install_dependent_packages() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install the Web interface dashboard
|
|
||||||
installPiholeWeb() {
|
|
||||||
printf "\\n %b Installing blocking page...\\n" "${INFO}"
|
|
||||||
|
|
||||||
local str="Creating directory for blocking page, and copying files"
|
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
|
||||||
# Install the directory,
|
|
||||||
install -d -m 0755 ${PI_HOLE_BLOCKPAGE_DIR}
|
|
||||||
# and the blockpage
|
|
||||||
install -D -m 644 ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* ${PI_HOLE_BLOCKPAGE_DIR}/
|
|
||||||
|
|
||||||
# Remove superseded file
|
|
||||||
if [[ -e "${PI_HOLE_BLOCKPAGE_DIR}/index.js" ]]; then
|
|
||||||
rm "${PI_HOLE_BLOCKPAGE_DIR}/index.js"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
|
||||||
|
|
||||||
local str="Backing up index.lighttpd.html"
|
|
||||||
printf " %b %s..." "${INFO}" "${str}"
|
|
||||||
# If the default index file exists,
|
|
||||||
if [[ -f "${webroot}/index.lighttpd.html" ]]; then
|
|
||||||
# back it up
|
|
||||||
mv ${webroot}/index.lighttpd.html ${webroot}/index.lighttpd.orig
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
|
||||||
else
|
|
||||||
# Otherwise, don't do anything
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${INFO}" "${str}"
|
|
||||||
printf " No default index.lighttpd.html file found... not backing up\\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install Sudoers file
|
|
||||||
local str="Installing sudoer file"
|
|
||||||
printf "\\n %b %s..." "${INFO}" "${str}"
|
|
||||||
# Make the .d directory if it doesn't exist,
|
|
||||||
install -d -m 755 /etc/sudoers.d/
|
|
||||||
# and copy in the pihole sudoers file
|
|
||||||
install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole
|
|
||||||
# Add lighttpd user (OS dependent) to sudoers file
|
|
||||||
echo "${LIGHTTPD_USER} ALL=NOPASSWD: ${PI_HOLE_BIN_DIR}/pihole" >> /etc/sudoers.d/pihole
|
|
||||||
|
|
||||||
# If the Web server user is lighttpd,
|
|
||||||
if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
|
|
||||||
# Allow executing pihole via sudo with Fedora
|
|
||||||
# Usually /usr/local/bin ${PI_HOLE_BIN_DIR} is not permitted as directory for sudoable programs
|
|
||||||
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:${PI_HOLE_BIN_DIR}" >> /etc/sudoers.d/pihole
|
|
||||||
fi
|
|
||||||
# Set the strict permissions on the file
|
|
||||||
chmod 0440 /etc/sudoers.d/pihole
|
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Installs a cron file
|
# Installs a cron file
|
||||||
installCron() {
|
installCron() {
|
||||||
# Install the cron job
|
# Install the cron job
|
||||||
@@ -1891,25 +1661,29 @@ create_pihole_user() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function saves any changes to the setup variables into the setupvars.conf file for future runs
|
#
|
||||||
finalExports() {
|
finalExports() {
|
||||||
# If the Web interface is not set to be installed,
|
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == false ]]; then
|
#TODO: The following is only for lighttpd when block page is installed.. we have discussed determining this within FTL
|
||||||
# and if there is not an IPv4 address,
|
#TODO: talk to @DL6ER
|
||||||
if [[ "${IPV4_ADDRESS}" ]]; then
|
|
||||||
# there is no block page, so set IPv4 to 0.0.0.0 (all IP addresses)
|
# # If the Web interface is not set to be installed,
|
||||||
IPV4_ADDRESS="0.0.0.0"
|
# if [[ "${INSTALL_WEB_INTERFACE}" == false ]]; then
|
||||||
fi
|
# # and if there is not an IPv4 address,
|
||||||
if [[ "${IPV6_ADDRESS}" ]]; then
|
# if [[ "${IPV4_ADDRESS}" ]]; then
|
||||||
# and IPv6 to ::/0
|
# # there is no block page, so set IPv4 to 0.0.0.0 (all IP addresses)
|
||||||
IPV6_ADDRESS="::/0"
|
# IPV4_ADDRESS="0.0.0.0"
|
||||||
fi
|
# fi
|
||||||
fi
|
# if [[ "${IPV6_ADDRESS}" ]]; then
|
||||||
|
# # and IPv6 to ::/0
|
||||||
|
# IPV6_ADDRESS="::/0"
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
# If the setup variable file exists,
|
# If the setup variable file exists,
|
||||||
if [[ -e "${setupVars}" ]]; then
|
if [[ -e "${setupVars}" ]]; then
|
||||||
# update the variables in the file
|
# update the variables in the file
|
||||||
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1\b/d;/PIHOLE_DNS_2\b/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;/CACHE_SIZE/d;' "${setupVars}"
|
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1\b/d;/PIHOLE_DNS_2\b/d;/QUERY_LOGGING/d;/INSTALL_WEB_INTERFACE/d;/CACHE_SIZE/d;' "${setupVars}"
|
||||||
fi
|
fi
|
||||||
# echo the information to the user
|
# echo the information to the user
|
||||||
{
|
{
|
||||||
@@ -1919,9 +1693,7 @@ finalExports() {
|
|||||||
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
||||||
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
||||||
echo "QUERY_LOGGING=${QUERY_LOGGING}"
|
echo "QUERY_LOGGING=${QUERY_LOGGING}"
|
||||||
echo "INSTALL_WEB_SERVER=${INSTALL_WEB_SERVER}"
|
|
||||||
echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}"
|
echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}"
|
||||||
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
|
|
||||||
echo "CACHE_SIZE=${CACHE_SIZE}"
|
echo "CACHE_SIZE=${CACHE_SIZE}"
|
||||||
}>> "${setupVars}"
|
}>> "${setupVars}"
|
||||||
chmod 644 "${setupVars}"
|
chmod 644 "${setupVars}"
|
||||||
@@ -1930,6 +1702,10 @@ finalExports() {
|
|||||||
sed -i '/PRIVACYLEVEL/d' "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
sed -i '/PRIVACYLEVEL/d' "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
||||||
echo "PRIVACYLEVEL=${PRIVACY_LEVEL}" >> "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
echo "PRIVACYLEVEL=${PRIVACY_LEVEL}" >> "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
||||||
|
|
||||||
|
# Set the web port
|
||||||
|
sed -i '/WEBPORT/d' "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
||||||
|
echo "WEBPORT=${WEBPORT}" >> "${PI_HOLE_CONFIG_DIR}/pihole-FTL.conf"
|
||||||
|
|
||||||
# Bring in the current settings and the functions to manipulate them
|
# Bring in the current settings and the functions to manipulate them
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
source "${PI_HOLE_LOCAL_REPO}/advanced/Scripts/webpage.sh"
|
source "${PI_HOLE_LOCAL_REPO}/advanced/Scripts/webpage.sh"
|
||||||
@@ -1944,9 +1720,17 @@ finalExports() {
|
|||||||
# Install the logrotate script
|
# Install the logrotate script
|
||||||
installLogrotate() {
|
installLogrotate() {
|
||||||
local str="Installing latest logrotate script"
|
local str="Installing latest logrotate script"
|
||||||
|
local target=/etc/pihole/logrotate
|
||||||
|
|
||||||
printf "\\n %b %s..." "${INFO}" "${str}"
|
printf "\\n %b %s..." "${INFO}" "${str}"
|
||||||
|
if [[ -f ${target} ]]; then
|
||||||
|
printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${INFO}"
|
||||||
|
# Return value isn't that important, using 2 to indicate that it's not a fatal error but
|
||||||
|
# the function did not complete.
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
# Copy the file over from the local repo
|
# Copy the file over from the local repo
|
||||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/Templates/logrotate /etc/pihole/logrotate
|
install -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${target}
|
||||||
# Different operating systems have different user / group
|
# Different operating systems have different user / group
|
||||||
# settings for logrotate that makes it impossible to create
|
# settings for logrotate that makes it impossible to create
|
||||||
# a static logrotate file that will work with e.g.
|
# a static logrotate file that will work with e.g.
|
||||||
@@ -1955,9 +1739,9 @@ installLogrotate() {
|
|||||||
# the local properties of the /var/log directory
|
# the local properties of the /var/log directory
|
||||||
logusergroup="$(stat -c '%U %G' /var/log)"
|
logusergroup="$(stat -c '%U %G' /var/log)"
|
||||||
# If there is a usergroup for log rotation,
|
# If there is a usergroup for log rotation,
|
||||||
if [[ ! -z "${logusergroup}" ]]; then
|
if [[ -n "${logusergroup}" ]]; then
|
||||||
# replace the line in the logrotate script with that usergroup.
|
# replace the line in the logrotate script with that usergroup.
|
||||||
sed -i "s/# su #/su ${logusergroup}/g;" /etc/pihole/logrotate
|
sed -i "s/# su #/su ${logusergroup}/g;" ${target}
|
||||||
fi
|
fi
|
||||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
}
|
}
|
||||||
@@ -1973,14 +1757,7 @@ accountForRefactor() {
|
|||||||
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' "${setupVars}"
|
sed -i 's/piholeDNS1/PIHOLE_DNS_1/g' "${setupVars}"
|
||||||
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' "${setupVars}"
|
sed -i 's/piholeDNS2/PIHOLE_DNS_2/g' "${setupVars}"
|
||||||
sed -i 's/^INSTALL_WEB=/INSTALL_WEB_INTERFACE=/' "${setupVars}"
|
sed -i 's/^INSTALL_WEB=/INSTALL_WEB_INTERFACE=/' "${setupVars}"
|
||||||
# Add 'INSTALL_WEB_SERVER', if its not been applied already: https://github.com/pi-hole/pi-hole/pull/2115
|
#TODO: Use this to tidy things up?
|
||||||
if ! grep -q '^INSTALL_WEB_SERVER=' ${setupVars}; then
|
|
||||||
local webserver_installed=false
|
|
||||||
if grep -q '^INSTALL_WEB_INTERFACE=true' ${setupVars}; then
|
|
||||||
webserver_installed=true
|
|
||||||
fi
|
|
||||||
echo -e "INSTALL_WEB_SERVER=$webserver_installed" >> "${setupVars}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install base files and web interface
|
# Install base files and web interface
|
||||||
@@ -1991,27 +1768,6 @@ installPihole() {
|
|||||||
# make the Web directory if necessary
|
# make the Web directory if necessary
|
||||||
install -d -m 0755 ${webroot}
|
install -d -m 0755 ${webroot}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
# Set the owner and permissions
|
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} ${webroot}
|
|
||||||
chmod 0775 ${webroot}
|
|
||||||
# Repair permissions if webroot is not world readable
|
|
||||||
chmod a+rx /var/www
|
|
||||||
chmod a+rx ${webroot}
|
|
||||||
# Give lighttpd access to the pihole group so the web interface can
|
|
||||||
# manage the gravity.db database
|
|
||||||
usermod -a -G pihole ${LIGHTTPD_USER}
|
|
||||||
# If the lighttpd command is executable,
|
|
||||||
if is_command lighty-enable-mod ; then
|
|
||||||
# enable fastcgi and fastcgi-php
|
|
||||||
lighty-enable-mod fastcgi fastcgi-php > /dev/null || true
|
|
||||||
else
|
|
||||||
# Otherwise, show info about installing them
|
|
||||||
printf " %b Warning: 'lighty-enable-mod' utility not found\\n" "${INFO}"
|
|
||||||
printf " Please ensure fastcgi is enabled if you experience issues\\n"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
# For updates and unattended install.
|
# For updates and unattended install.
|
||||||
if [[ "${useUpdateVars}" == true ]]; then
|
if [[ "${useUpdateVars}" == true ]]; then
|
||||||
@@ -2027,11 +1783,6 @@ installPihole() {
|
|||||||
printf " %b Failure in dependent config copy function.\\n" "${CROSS}"
|
printf " %b Failure in dependent config copy function.\\n" "${CROSS}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# If the user wants to install the dashboard,
|
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
|
||||||
# do so
|
|
||||||
installPiholeWeb
|
|
||||||
fi
|
|
||||||
# Install the cron file
|
# Install the cron file
|
||||||
installCron
|
installCron
|
||||||
# Install the logrotate file
|
# Install the logrotate file
|
||||||
@@ -2109,7 +1860,7 @@ displayFinalMessage() {
|
|||||||
# If the user wants to install the dashboard,
|
# If the user wants to install the dashboard,
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
||||||
# Store a message in a variable and display it
|
# Store a message in a variable and display it
|
||||||
additional="View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin
|
additional="View the web interface at http://pi.hole:${WEBPORT}/admin or http://${IPV4_ADDRESS%/*}:${WEBPORT}/admin
|
||||||
|
|
||||||
Your Admin Webpage login password is ${pwstring}"
|
Your Admin Webpage login password is ${pwstring}"
|
||||||
fi
|
fi
|
||||||
@@ -2704,25 +2455,10 @@ main() {
|
|||||||
|
|
||||||
# Install the Core dependencies
|
# Install the Core dependencies
|
||||||
local dep_install_list=("${PIHOLE_DEPS[@]}")
|
local dep_install_list=("${PIHOLE_DEPS[@]}")
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
# And, if the setting says so, install the Web admin interface dependencies
|
|
||||||
dep_install_list+=("${PIHOLE_WEB_DEPS[@]}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
install_dependent_packages "${dep_install_list[@]}"
|
install_dependent_packages "${dep_install_list[@]}"
|
||||||
unset dep_install_list
|
unset dep_install_list
|
||||||
|
|
||||||
# On some systems, lighttpd is not enabled on first install. We need to enable it here if the user
|
|
||||||
# has chosen to install the web interface, else the LIGHTTPD_ENABLED check will fail
|
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
enable_service lighttpd
|
|
||||||
fi
|
|
||||||
# Determine if lighttpd is correctly enabled
|
|
||||||
if check_service_active "lighttpd"; then
|
|
||||||
LIGHTTPD_ENABLED=true
|
|
||||||
else
|
|
||||||
LIGHTTPD_ENABLED=false
|
|
||||||
fi
|
|
||||||
# Create the pihole user
|
# Create the pihole user
|
||||||
create_pihole_user
|
create_pihole_user
|
||||||
|
|
||||||
@@ -2763,16 +2499,6 @@ main() {
|
|||||||
# but before starting or resarting the dnsmasq or ftl services
|
# but before starting or resarting the dnsmasq or ftl services
|
||||||
disable_resolved_stublistener
|
disable_resolved_stublistener
|
||||||
|
|
||||||
# If the Web server was installed,
|
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
|
||||||
if [[ "${LIGHTTPD_ENABLED}" == true ]]; then
|
|
||||||
restart_service lighttpd
|
|
||||||
enable_service lighttpd
|
|
||||||
else
|
|
||||||
printf " %b Lighttpd is disabled, skipping service restart\\n" "${INFO}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf " %b Restarting services...\\n" "${INFO}"
|
printf " %b Restarting services...\\n" "${INFO}"
|
||||||
# Start services
|
# Start services
|
||||||
|
|
||||||
@@ -2807,7 +2533,7 @@ main() {
|
|||||||
if [[ "${useUpdateVars}" == false ]]; then
|
if [[ "${useUpdateVars}" == false ]]; then
|
||||||
# If the Web interface was installed,
|
# If the Web interface was installed,
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
||||||
printf " %b View the web interface at http://pi.hole/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}"
|
printf " %b View the web interface at http://pi.hole:${WEBPORT}/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}:${WEBPORT}"
|
||||||
fi
|
fi
|
||||||
# Explain to the user how to use Pi-hole as their DNS server
|
# Explain to the user how to use Pi-hole as their DNS server
|
||||||
printf " %b You may now configure your devices to use the Pi-hole as their DNS server\\n" "${INFO}"
|
printf " %b You may now configure your devices to use the Pi-hole as their DNS server\\n" "${INFO}"
|
||||||
|
@@ -206,11 +206,7 @@ removeNoPurge() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
if command -v vcgencmd &> /dev/null; then
|
echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed"
|
||||||
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"
|
|
||||||
fi
|
|
||||||
while true; do
|
while true; do
|
||||||
echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:"
|
echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:"
|
||||||
echo -n " "
|
echo -n " "
|
||||||
|
72
gravity.sh
72
gravity.sh
@@ -47,16 +47,6 @@ domainsExtension="domains"
|
|||||||
setupVars="${piholeDir}/setupVars.conf"
|
setupVars="${piholeDir}/setupVars.conf"
|
||||||
if [[ -f "${setupVars}" ]];then
|
if [[ -f "${setupVars}" ]];then
|
||||||
source "${setupVars}"
|
source "${setupVars}"
|
||||||
|
|
||||||
# Remove CIDR mask from IPv4/6 addresses
|
|
||||||
IPV4_ADDRESS="${IPV4_ADDRESS%/*}"
|
|
||||||
IPV6_ADDRESS="${IPV6_ADDRESS%/*}"
|
|
||||||
|
|
||||||
# Determine if IPv4/6 addresses exist
|
|
||||||
if [[ -z "${IPV4_ADDRESS}" ]] && [[ -z "${IPV6_ADDRESS}" ]]; then
|
|
||||||
echo -e " ${COL_LIGHT_RED}No IP addresses found! Please run 'pihole -r' to reconfigure${COL_NC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo -e " ${COL_LIGHT_RED}Installation Failure: ${setupVars} does not exist! ${COL_NC}
|
echo -e " ${COL_LIGHT_RED}Installation Failure: ${setupVars} does not exist! ${COL_NC}
|
||||||
Please run 'pihole -r', and choose the 'reconfigure' option to fix."
|
Please run 'pihole -r', and choose the 'reconfigure' option to fix."
|
||||||
@@ -73,6 +63,8 @@ fi
|
|||||||
# have changed
|
# have changed
|
||||||
gravityDBfile="${GRAVITYDB}"
|
gravityDBfile="${GRAVITYDB}"
|
||||||
gravityTEMPfile="${GRAVITYDB}_temp"
|
gravityTEMPfile="${GRAVITYDB}_temp"
|
||||||
|
gravityDIR="$(dirname -- "${gravityDBfile}")"
|
||||||
|
gravityOLDfile="${gravityDIR}/gravity_old.db"
|
||||||
|
|
||||||
if [[ -z "${BLOCKINGMODE}" ]] ; then
|
if [[ -z "${BLOCKINGMODE}" ]] ; then
|
||||||
BLOCKINGMODE="NULL"
|
BLOCKINGMODE="NULL"
|
||||||
@@ -123,8 +115,19 @@ gravity_swap_databases() {
|
|||||||
fi
|
fi
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
|
||||||
# Swap databases and remove old database
|
# Swap databases and remove or conditionally rename old database
|
||||||
rm "${gravityDBfile}"
|
# Number of available blocks on disk
|
||||||
|
availableBlocks=$(stat -f --format "%a" "${gravityDIR}")
|
||||||
|
# Number of blocks, used by gravity.db
|
||||||
|
gravityBlocks=$(stat --format "%b" ${gravityDBfile})
|
||||||
|
# Only keep the old database if available disk space is at least twice the size of the existing gravity.db.
|
||||||
|
# Better be safe than sorry...
|
||||||
|
if [ "${availableBlocks}" -gt "$(("${gravityBlocks}" * 2))" ] && [ -f "${gravityDBfile}" ]; then
|
||||||
|
echo -e " ${TICK} The old database remains available."
|
||||||
|
mv "${gravityDBfile}" "${gravityOLDfile}"
|
||||||
|
else
|
||||||
|
rm "${gravityDBfile}"
|
||||||
|
fi
|
||||||
mv "${gravityTEMPfile}" "${gravityDBfile}"
|
mv "${gravityTEMPfile}" "${gravityDBfile}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,7 +567,7 @@ compareLists() {
|
|||||||
# Download specified URL and perform checks on HTTP status and file content
|
# Download specified URL and perform checks on HTTP status and file content
|
||||||
gravity_DownloadBlocklistFromUrl() {
|
gravity_DownloadBlocklistFromUrl() {
|
||||||
local url="${1}" cmd_ext="${2}" agent="${3}" adlistID="${4}" saveLocation="${5}" target="${6}" compression="${7}"
|
local url="${1}" cmd_ext="${2}" agent="${3}" adlistID="${4}" saveLocation="${5}" target="${6}" compression="${7}"
|
||||||
local heisenbergCompensator="" patternBuffer str httpCode success=""
|
local heisenbergCompensator="" patternBuffer str httpCode success="" ip
|
||||||
|
|
||||||
# Create temp file to store content on disk instead of RAM
|
# Create temp file to store content on disk instead of RAM
|
||||||
patternBuffer=$(mktemp -p "/tmp" --suffix=".phgpb")
|
patternBuffer=$(mktemp -p "/tmp" --suffix=".phgpb")
|
||||||
@@ -582,7 +585,10 @@ gravity_DownloadBlocklistFromUrl() {
|
|||||||
blocked=false
|
blocked=false
|
||||||
case $BLOCKINGMODE in
|
case $BLOCKINGMODE in
|
||||||
"IP-NODATA-AAAA"|"IP")
|
"IP-NODATA-AAAA"|"IP")
|
||||||
if [[ $(dig "${domain}" +short | grep "${IPV4_ADDRESS}" -c) -ge 1 ]]; then
|
# Get IP address of this domain
|
||||||
|
ip="$(dig "${domain}" +short)"
|
||||||
|
# Check if this IP matches any IP of the system
|
||||||
|
if [[ -n "${ip}" && $(grep -Ec "inet(|6) ${ip}" <<< "$(ip a)") -gt 0 ]]; then
|
||||||
blocked=true
|
blocked=true
|
||||||
fi;;
|
fi;;
|
||||||
"NXDOMAIN")
|
"NXDOMAIN")
|
||||||
@@ -785,43 +791,12 @@ gravity_ShowCount() {
|
|||||||
gravity_Table_Count "vw_regex_whitelist" "regex whitelist filters"
|
gravity_Table_Count "vw_regex_whitelist" "regex whitelist filters"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse list of domains into hosts format
|
|
||||||
gravity_ParseDomainsIntoHosts() {
|
|
||||||
awk -v ipv4="$IPV4_ADDRESS" -v ipv6="$IPV6_ADDRESS" '{
|
|
||||||
# Remove windows CR line endings
|
|
||||||
sub(/\r$/, "")
|
|
||||||
# Parse each line as "ipaddr domain"
|
|
||||||
if(ipv6 && ipv4) {
|
|
||||||
print ipv4" "$0"\n"ipv6" "$0
|
|
||||||
} else if(!ipv6) {
|
|
||||||
print ipv4" "$0
|
|
||||||
} else {
|
|
||||||
print ipv6" "$0
|
|
||||||
}
|
|
||||||
}' >> "${2}" < "${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create "localhost" entries into hosts format
|
# Create "localhost" entries into hosts format
|
||||||
gravity_generateLocalList() {
|
gravity_generateLocalList() {
|
||||||
local hostname
|
|
||||||
|
|
||||||
if [[ -s "/etc/hostname" ]]; then
|
|
||||||
hostname=$(< "/etc/hostname")
|
|
||||||
elif command -v hostname &> /dev/null; then
|
|
||||||
hostname=$(hostname -f)
|
|
||||||
else
|
|
||||||
echo -e " ${CROSS} Unable to determine fully qualified domain name of host"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${hostname}\\npi.hole" > "${localList}.tmp"
|
|
||||||
|
|
||||||
# Empty $localList if it already exists, otherwise, create it
|
# Empty $localList if it already exists, otherwise, create it
|
||||||
: > "${localList}"
|
echo "### Do not modify this file, it will be overwritten by pihole -g" > "${localList}"
|
||||||
chmod 644 "${localList}"
|
chmod 644 "${localList}"
|
||||||
|
|
||||||
gravity_ParseDomainsIntoHosts "${localList}.tmp" "${localList}"
|
|
||||||
|
|
||||||
# Add additional LAN hosts provided by OpenVPN (if available)
|
# Add additional LAN hosts provided by OpenVPN (if available)
|
||||||
if [[ -f "${VPNList}" ]]; then
|
if [[ -f "${VPNList}" ]]; then
|
||||||
awk -F, '{printf $2"\t"$1".vpn\n"}' "${VPNList}" >> "${localList}"
|
awk -F, '{printf $2"\t"$1".vpn\n"}' "${VPNList}" >> "${localList}"
|
||||||
@@ -890,6 +865,11 @@ for var in "$@"; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Remove OLD (backup) gravity file, if it exists
|
||||||
|
if [[ -f "${gravityOLDfile}" ]]; then
|
||||||
|
rm "${gravityOLDfile}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Trap Ctrl-C
|
# Trap Ctrl-C
|
||||||
gravity_Trap
|
gravity_Trap
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ Available commands and options:
|
|||||||
|
|
||||||
\fB-w, whitelist\fR [options] [<domain1> <domain2 ...>]
|
\fB-w, whitelist\fR [options] [<domain1> <domain2 ...>]
|
||||||
.br
|
.br
|
||||||
Adds or removes specified domain or domains tho the Whitelist
|
Adds or removes specified domain or domains to the Whitelist
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-b, blacklist\fR [options] [<domain1> <domain2 ...>]
|
\fB-b, blacklist\fR [options] [<domain1> <domain2 ...>]
|
||||||
|
14
pihole
14
pihole
@@ -363,16 +363,13 @@ tailFunc() {
|
|||||||
fi
|
fi
|
||||||
echo -e " ${INFO} Press Ctrl-C to exit"
|
echo -e " ${INFO} Press Ctrl-C to exit"
|
||||||
|
|
||||||
# Retrieve IPv4/6 addresses
|
|
||||||
source /etc/pihole/setupVars.conf
|
|
||||||
|
|
||||||
# Strip date from each line
|
# Strip date from each line
|
||||||
# Color blocklist/blacklist/wildcard entries as red
|
# Color blocklist/blacklist/wildcard entries as red
|
||||||
# Color A/AAAA/DHCP strings as white
|
# Color A/AAAA/DHCP strings as white
|
||||||
# Color everything else as gray
|
# Color everything else as gray
|
||||||
tail -f /var/log/pihole.log | sed -E \
|
tail -f /var/log/pihole.log | grep --line-buffered "${1}" | sed -E \
|
||||||
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
||||||
-e "s,(.*(blacklisted |gravity blocked ).* is (0.0.0.0|::|NXDOMAIN|${IPV4_ADDRESS%/*}|${IPV6_ADDRESS:-NULL}).*),${COL_RED}&${COL_NC}," \
|
-e "s,(.*(blacklisted |gravity blocked ).* is (0.0.0.0|::|NXDOMAIN).*),${COL_RED}&${COL_NC}," \
|
||||||
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
||||||
-e "s,.*,${COL_GRAY}&${COL_NC},"
|
-e "s,.*,${COL_GRAY}&${COL_NC},"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -456,7 +453,10 @@ Debugging Options:
|
|||||||
Add '-a' to automatically upload the log to tricorder.pi-hole.net
|
Add '-a' to automatically upload the log to tricorder.pi-hole.net
|
||||||
-f, flush Flush the Pi-hole log
|
-f, flush Flush the Pi-hole log
|
||||||
-r, reconfigure Reconfigure or Repair Pi-hole subsystems
|
-r, reconfigure Reconfigure or Repair Pi-hole subsystems
|
||||||
-t, tail View the live output of the Pi-hole log
|
-t, tail [arg] View the live output of the Pi-hole log.
|
||||||
|
Add an optional argument to filter the log
|
||||||
|
(regular expressions are supported)
|
||||||
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-a, admin Web interface options
|
-a, admin Web interface options
|
||||||
@@ -530,7 +530,7 @@ case "${1}" in
|
|||||||
"status" ) statusFunc "$2";;
|
"status" ) statusFunc "$2";;
|
||||||
"restartdns" ) restartDNS "$2";;
|
"restartdns" ) restartDNS "$2";;
|
||||||
"-a" | "admin" ) webpageFunc "$@";;
|
"-a" | "admin" ) webpageFunc "$@";;
|
||||||
"-t" | "tail" ) tailFunc;;
|
"-t" | "tail" ) tailFunc "$2";;
|
||||||
"checkout" ) piholeCheckoutFunc "$@";;
|
"checkout" ) piholeCheckoutFunc "$@";;
|
||||||
"tricorder" ) tricorderFunc;;
|
"tricorder" ) tricorderFunc;;
|
||||||
"updatechecker" ) updateCheckFunc "$@";;
|
"updatechecker" ) updateCheckFunc "$@";;
|
||||||
|
@@ -2,4 +2,4 @@ Raspbian=9,10
|
|||||||
Ubuntu=16,18,20
|
Ubuntu=16,18,20
|
||||||
Debian=9,10
|
Debian=9,10
|
||||||
Fedora=32,33
|
Fedora=32,33
|
||||||
CentOS=7,8
|
CentOS=7,8
|
||||||
|
@@ -8,8 +8,6 @@ check_output = testinfra.get_backend(
|
|||||||
|
|
||||||
SETUPVARS = {
|
SETUPVARS = {
|
||||||
'PIHOLE_INTERFACE': 'eth99',
|
'PIHOLE_INTERFACE': 'eth99',
|
||||||
'IPV4_ADDRESS': '1.1.1.1',
|
|
||||||
'IPV6_ADDRESS': 'FE80::240:D0FF:FE48:4672',
|
|
||||||
'PIHOLE_DNS_1': '4.2.2.1',
|
'PIHOLE_DNS_1': '4.2.2.1',
|
||||||
'PIHOLE_DNS_2': '4.2.2.2'
|
'PIHOLE_DNS_2': '4.2.2.2'
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,6 @@ def test_setupVars_are_sourced_to_global_scope(Pihole):
|
|||||||
# Currently debug test function only
|
# Currently debug test function only
|
||||||
echo "Outputting sourced variables"
|
echo "Outputting sourced variables"
|
||||||
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
||||||
echo "IPV4_ADDRESS=${IPV4_ADDRESS}"
|
|
||||||
echo "IPV6_ADDRESS=${IPV6_ADDRESS}"
|
|
||||||
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
||||||
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
||||||
}
|
}
|
||||||
@@ -106,31 +104,6 @@ def test_selinux_not_detected(Pihole):
|
|||||||
assert check_selinux.rc == 0
|
assert check_selinux.rc == 0
|
||||||
|
|
||||||
|
|
||||||
def test_installPiholeWeb_fresh_install_no_errors(Pihole):
|
|
||||||
'''
|
|
||||||
confirms all web page assets from Core repo are installed on a fresh build
|
|
||||||
'''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + ' Installing blocking page...'
|
|
||||||
assert expected_stdout in installWeb.stdout
|
|
||||||
expected_stdout = tick_box + (' Creating directory for blocking page, '
|
|
||||||
'and copying files')
|
|
||||||
assert expected_stdout in installWeb.stdout
|
|
||||||
expected_stdout = info_box + ' Backing up index.lighttpd.html'
|
|
||||||
assert expected_stdout in installWeb.stdout
|
|
||||||
expected_stdout = ('No default index.lighttpd.html file found... '
|
|
||||||
'not backing up')
|
|
||||||
assert expected_stdout in installWeb.stdout
|
|
||||||
expected_stdout = tick_box + ' Installing sudoer file'
|
|
||||||
assert expected_stdout in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
|
|
||||||
def test_update_package_cache_success_no_errors(Pihole):
|
def test_update_package_cache_success_no_errors(Pihole):
|
||||||
'''
|
'''
|
||||||
confirms package cache was updated without any errors
|
confirms package cache was updated without any errors
|
||||||
@@ -597,3 +570,42 @@ def test_os_check_passes(Pihole):
|
|||||||
''')
|
''')
|
||||||
expected_stdout = 'Supported OS detected'
|
expected_stdout = 'Supported OS detected'
|
||||||
assert expected_stdout in detectOS.stdout
|
assert expected_stdout in detectOS.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_package_manager_has_installer_deps(Pihole):
|
||||||
|
''' Confirms OS is able to install the required packages for the installer'''
|
||||||
|
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
||||||
|
output = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
distro_check
|
||||||
|
install_dependent_packages ${INSTALLER_DEPS[@]}
|
||||||
|
''')
|
||||||
|
|
||||||
|
assert 'No package' not in output.stdout # centos7 still exits 0...
|
||||||
|
assert output.rc == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_package_manager_has_pihole_deps(Pihole):
|
||||||
|
''' Confirms OS is able to install the required packages for Pi-hole '''
|
||||||
|
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
||||||
|
output = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
distro_check
|
||||||
|
install_dependent_packages ${PIHOLE_DEPS[@]}
|
||||||
|
''')
|
||||||
|
|
||||||
|
assert 'No package' not in output.stdout # centos7 still exits 0...
|
||||||
|
assert output.rc == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_package_manager_has_web_deps(Pihole):
|
||||||
|
''' Confirms OS is able to install the required packages for web '''
|
||||||
|
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
||||||
|
output = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
distro_check
|
||||||
|
install_dependent_packages ${PIHOLE_WEB_DEPS[@]}
|
||||||
|
''')
|
||||||
|
|
||||||
|
assert 'No package' not in output.stdout # centos7 still exits 0...
|
||||||
|
assert output.rc == 0
|
||||||
|
@@ -5,56 +5,18 @@ from .conftest import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_php_upgrade_default_optout_centos_eq_7(Pihole):
|
def test_epel_installed_centos_7(Pihole):
|
||||||
'''
|
'''
|
||||||
confirms the default behavior to opt-out of installing PHP7 from REMI
|
confirms the EPEL package repository is enabled when installed on CentOS
|
||||||
'''
|
'''
|
||||||
distro_check = Pihole.run('''
|
distro_check = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
distro_check
|
distro_check
|
||||||
''')
|
''')
|
||||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
expected_stdout = info_box + (' Enabling EPEL package repository '
|
||||||
'Deprecated PHP may be in use.')
|
'(https://fedoraproject.org/wiki/EPEL)')
|
||||||
assert expected_stdout in distro_check.stdout
|
assert expected_stdout in distro_check.stdout
|
||||||
remi_package = Pihole.package('remi-release')
|
expected_stdout = tick_box + ' Installed epel-release'
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
|
||||||
|
|
||||||
def test_php_upgrade_user_optout_centos_eq_7(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer behavior when user opt-out of installing PHP7 from REMI
|
|
||||||
(php not currently installed)
|
|
||||||
'''
|
|
||||||
# Whiptail dialog returns Cancel for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '1')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
||||||
'Deprecated PHP may be in use.')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
assert expected_stdout in distro_check.stdout
|
||||||
remi_package = Pihole.package('remi-release')
|
epel_package = Pihole.package('epel-release')
|
||||||
assert not remi_package.is_installed
|
assert epel_package.is_installed
|
||||||
|
|
||||||
|
|
||||||
def test_php_upgrade_user_optin_centos_eq_7(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer behavior when user opt-in to installing PHP7 from REMI
|
|
||||||
(php not currently installed)
|
|
||||||
'''
|
|
||||||
# Whiptail dialog returns Continue for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
assert 'opt-out' not in distro_check.stdout
|
|
||||||
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
|
||||||
'(https://rpms.remirepo.net)')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
expected_stdout = tick_box + (' Remi\'s RPM repository has '
|
|
||||||
'been enabled for PHP7')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert remi_package.is_installed
|
|
||||||
|
@@ -5,61 +5,15 @@ from .conftest import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_php_upgrade_default_continue_centos_gte_8(Pihole):
|
def test_epel_not_installed_centos_gt7(Pihole):
|
||||||
'''
|
'''
|
||||||
confirms the latest version of CentOS continues / does not optout
|
confirms installer does not attempt to install EPEL repository on CentOS 8+
|
||||||
(should trigger on CentOS7 only)
|
|
||||||
'''
|
'''
|
||||||
distro_check = Pihole.run('''
|
distro_check = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
distro_check
|
distro_check
|
||||||
''')
|
''')
|
||||||
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
|
assert distro_check.stdout == ''
|
||||||
' Deprecated PHP may be in use.')
|
|
||||||
assert unexpected_stdout not in distro_check.stdout
|
|
||||||
# ensure remi was not installed on latest CentOS
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
|
||||||
|
epel_package = Pihole.package('epel-release')
|
||||||
def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole):
|
assert not epel_package.is_installed
|
||||||
'''
|
|
||||||
confirms installer skips user opt-out of installing PHP7 from REMI on
|
|
||||||
latest CentOS (should trigger on CentOS7 only)
|
|
||||||
(php not currently installed)
|
|
||||||
'''
|
|
||||||
# Whiptail dialog returns Cancel for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '1')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
|
|
||||||
' Deprecated PHP may be in use.')
|
|
||||||
assert unexpected_stdout not in distro_check.stdout
|
|
||||||
# ensure remi was not installed on latest CentOS
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
|
||||||
|
|
||||||
def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer skips user opt-in to installing PHP7 from REMI on
|
|
||||||
latest CentOS (should trigger on CentOS7 only)
|
|
||||||
(php not currently installed)
|
|
||||||
'''
|
|
||||||
# Whiptail dialog returns Continue for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
assert 'opt-out' not in distro_check.stdout
|
|
||||||
unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
|
||||||
'(https://rpms.remirepo.net)')
|
|
||||||
assert unexpected_stdout not in distro_check.stdout
|
|
||||||
unexpected_stdout = tick_box + (' Remi\'s RPM repository has '
|
|
||||||
'been enabled for PHP7')
|
|
||||||
assert unexpected_stdout not in distro_check.stdout
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
@@ -1,120 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from .conftest import (
|
|
||||||
tick_box,
|
|
||||||
info_box,
|
|
||||||
cross_box,
|
|
||||||
mock_command,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_release_supported_version_check_centos(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer exits on unsupported releases of CentOS
|
|
||||||
'''
|
|
||||||
# modify /etc/redhat-release to mock an unsupported CentOS release
|
|
||||||
Pihole.run('echo "CentOS Linux release 6.9" > /etc/redhat-release')
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
expected_stdout = cross_box + (' CentOS 6 is not supported.')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
expected_stdout = 'Please update to CentOS release 7 or later'
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_enable_epel_repository_centos(Pihole):
|
|
||||||
'''
|
|
||||||
confirms the EPEL package repository is enabled when installed on CentOS
|
|
||||||
'''
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + (' Enabling EPEL package repository '
|
|
||||||
'(https://fedoraproject.org/wiki/EPEL)')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
expected_stdout = tick_box + ' Installed epel-release'
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
epel_package = Pihole.package('epel-release')
|
|
||||||
assert epel_package.is_installed
|
|
||||||
|
|
||||||
|
|
||||||
def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole):
|
|
||||||
'''
|
|
||||||
confirms the default behavior to opt-out of upgrading to PHP7 from REMI
|
|
||||||
'''
|
|
||||||
# first we will install the default php version to test installer behavior
|
|
||||||
php_install = Pihole.run('yum install -y php')
|
|
||||||
assert php_install.rc == 0
|
|
||||||
php_package = Pihole.package('php')
|
|
||||||
default_centos_php_version = php_package.version.split('.')[0]
|
|
||||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
||||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
||||||
'Deprecated PHP may be in use.')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
|
||||||
|
|
||||||
def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer behavior when user opt-out to upgrade to PHP7 via REMI
|
|
||||||
'''
|
|
||||||
# first we will install the default php version to test installer behavior
|
|
||||||
php_install = Pihole.run('yum install -y php')
|
|
||||||
assert php_install.rc == 0
|
|
||||||
php_package = Pihole.package('php')
|
|
||||||
default_centos_php_version = php_package.version.split('.')[0]
|
|
||||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
||||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
|
||||||
# Whiptail dialog returns Cancel for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '1')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
||||||
'Deprecated PHP may be in use.')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
||||||
|
|
||||||
|
|
||||||
def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer behavior when user opt-in to upgrade to PHP7 via REMI
|
|
||||||
'''
|
|
||||||
# first we will install the default php version to test installer behavior
|
|
||||||
php_install = Pihole.run('yum install -y php')
|
|
||||||
assert php_install.rc == 0
|
|
||||||
php_package = Pihole.package('php')
|
|
||||||
default_centos_php_version = php_package.version.split('.')[0]
|
|
||||||
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
||||||
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
|
||||||
# Whiptail dialog returns Continue for user prompt
|
|
||||||
mock_command('whiptail', {'*': ('', '0')}, Pihole)
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
install_dependent_packages PIHOLE_WEB_DEPS[@]
|
|
||||||
''')
|
|
||||||
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
||||||
'Deprecated PHP may be in use.')
|
|
||||||
assert expected_stdout not in distro_check.stdout
|
|
||||||
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
|
||||||
'(https://rpms.remirepo.net)')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
expected_stdout = tick_box + (' Remi\'s RPM repository has '
|
|
||||||
'been enabled for PHP7')
|
|
||||||
assert expected_stdout in distro_check.stdout
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert remi_package.is_installed
|
|
||||||
updated_php_package = Pihole.package('php')
|
|
||||||
updated_php_version = updated_php_package.version.split('.')[0]
|
|
||||||
assert int(updated_php_version) == 7
|
|
@@ -1,15 +0,0 @@
|
|||||||
def test_epel_and_remi_not_installed_fedora(Pihole):
|
|
||||||
'''
|
|
||||||
confirms installer does not attempt to install EPEL/REMI repositories
|
|
||||||
on Fedora
|
|
||||||
'''
|
|
||||||
distro_check = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
distro_check
|
|
||||||
''')
|
|
||||||
assert distro_check.stdout == ''
|
|
||||||
|
|
||||||
epel_package = Pihole.package('epel-release')
|
|
||||||
assert not epel_package.is_installed
|
|
||||||
remi_package = Pihole.package('remi-release')
|
|
||||||
assert not remi_package.is_installed
|
|
@@ -5,4 +5,4 @@ envlist = py37
|
|||||||
whitelist_externals = docker
|
whitelist_externals = docker
|
||||||
deps = -rrequirements.txt
|
deps = -rrequirements.txt
|
||||||
commands = docker build -f _centos_7.Dockerfile -t pytest_pihole:test_container ../
|
commands = docker build -f _centos_7.Dockerfile -t pytest_pihole:test_container ../
|
||||||
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py ./test_centos_7_support.py
|
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_7_support.py
|
||||||
|
@@ -5,4 +5,4 @@ envlist = py37
|
|||||||
whitelist_externals = docker
|
whitelist_externals = docker
|
||||||
deps = -rrequirements.txt
|
deps = -rrequirements.txt
|
||||||
commands = docker build -f _centos_8.Dockerfile -t pytest_pihole:test_container ../
|
commands = docker build -f _centos_8.Dockerfile -t pytest_pihole:test_container ../
|
||||||
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py ./test_centos_8_support.py
|
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_8_support.py
|
||||||
|
@@ -5,4 +5,4 @@ envlist = py37
|
|||||||
whitelist_externals = docker
|
whitelist_externals = docker
|
||||||
deps = -rrequirements.txt
|
deps = -rrequirements.txt
|
||||||
commands = docker build -f _fedora_32.Dockerfile -t pytest_pihole:test_container ../
|
commands = docker build -f _fedora_32.Dockerfile -t pytest_pihole:test_container ../
|
||||||
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_fedora_support.py
|
pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py
|
||||||
|
Reference in New Issue
Block a user