mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-23 07:18:07 +00:00
parse contents of each file in each dir, several log_writes
This commit is contained in:
parent
7ec169ab10
commit
36907edd50
@ -66,7 +66,7 @@ make_temporary_log() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_write() {
|
log_write() {
|
||||||
# echo arguments to both the log and the console"
|
# echo arguments to both the log and the console
|
||||||
echo -e "${@}" | tee -a /proc/$$/fd/3
|
echo -e "${@}" | tee -a /proc/$$/fd/3
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,15 +76,16 @@ copy_to_debug_log() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo_succes_or_fail() {
|
echo_succes_or_fail() {
|
||||||
# Set the first argument passed to this function as a named variable for better readability
|
|
||||||
local message="${1}"
|
|
||||||
# If the command was successful (a zero),
|
# If the command was successful (a zero),
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
|
# Set the first argument passed to this function as a named variable for better readability
|
||||||
|
local message="${1}"
|
||||||
# show success
|
# show success
|
||||||
log_write " ${TICK} ${message}"
|
log_write "${TICK} ${message}"
|
||||||
else
|
else
|
||||||
|
local message="${1}"
|
||||||
# Otherwise, show a error
|
# Otherwise, show a error
|
||||||
log_write " ${CROSS} ${message}"
|
log_write "${CROSS} ${message}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ initiate_debug() {
|
|||||||
# Display that the debug process is beginning
|
# Display that the debug process is beginning
|
||||||
log_write "${COL_LIGHT_PURPLE}*** [ INITIALIZING ]${COL_NC}"
|
log_write "${COL_LIGHT_PURPLE}*** [ INITIALIZING ]${COL_NC}"
|
||||||
# Timestamp the start of the log
|
# Timestamp the start of the log
|
||||||
log_write " ${INFO} $(date "+%Y-%m-%d:%H:%M:%S") debug log has been initiated."
|
log_write "${INFO} $(date "+%Y-%m-%d:%H:%M:%S") debug log has been initiated."
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is a function for visually displaying the curent test that is being run.
|
# This is a function for visually displaying the curent test that is being run.
|
||||||
@ -155,25 +156,25 @@ check_core_version() {
|
|||||||
# echo this information out to the user in a nice format
|
# echo this information out to the user in a nice format
|
||||||
# If the current version matches what pihole -v produces, the user is up-to-date
|
# If the current version matches what pihole -v produces, the user is up-to-date
|
||||||
if [[ "${PI_HOLE_VERSION}" == "$(pihole -v | awk '/Pi-hole/ {print $6}' | cut -d ')' -f1)" ]]; then
|
if [[ "${PI_HOLE_VERSION}" == "$(pihole -v | awk '/Pi-hole/ {print $6}' | cut -d ')' -f1)" ]]; then
|
||||||
log_write " ${TICK} Core: ${COL_LIGHT_GREEN}${PI_HOLE_VERSION}${COL_NC}"
|
log_write "${TICK} Core: ${COL_LIGHT_GREEN}${PI_HOLE_VERSION}${COL_NC}"
|
||||||
# If not,
|
# If not,
|
||||||
else
|
else
|
||||||
# echo the current version in yellow, signifying it's something to take a look at, but not a critical error
|
# echo the current version in yellow, signifying it's something to take a look at, but not a critical error
|
||||||
# Also add a URL to an FAQ
|
# Also add a URL to an FAQ
|
||||||
log_write " ${INFO} Core: ${COL_YELLOW}${PI_HOLE_VERSION:-Untagged}${COL_NC} (${COL_CYAN}${FAQ_UPDATE_PI_HOLE}${COL_NC})"
|
log_write "${INFO} Core: ${COL_YELLOW}${PI_HOLE_VERSION:-Untagged}${COL_NC} (${COL_CYAN}${FAQ_UPDATE_PI_HOLE}${COL_NC})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the repo is on the master branch, they are on the stable codebase
|
# If the repo is on the master branch, they are on the stable codebase
|
||||||
if [[ "${PI_HOLE_BRANCH}" == "master" ]]; then
|
if [[ "${PI_HOLE_BRANCH}" == "master" ]]; then
|
||||||
# so the color of the text is green
|
# so the color of the text is green
|
||||||
log_write " ${INFO} Branch: ${COL_LIGHT_GREEN}${PI_HOLE_BRANCH}${COL_NC}"
|
log_write "${INFO} Branch: ${COL_LIGHT_GREEN}${PI_HOLE_BRANCH}${COL_NC}"
|
||||||
# If it is any other branch, they are in a developement branch
|
# If it is any other branch, they are in a developement branch
|
||||||
else
|
else
|
||||||
# So show that in yellow, signifying it's something to take a look at, but not a critical error
|
# So show that in yellow, signifying it's something to take a look at, but not a critical error
|
||||||
log_write " ${INFO} Branch: ${COL_YELLOW}${PI_HOLE_BRANCH:-Detached}${COL_NC} (${COL_CYAN}${FAQ_CHECKOUT_COMMAND}${COL_NC})"
|
log_write "${INFO} Branch: ${COL_YELLOW}${PI_HOLE_BRANCH:-Detached}${COL_NC} (${COL_CYAN}${FAQ_CHECKOUT_COMMAND}${COL_NC})"
|
||||||
fi
|
fi
|
||||||
# echo the current commit
|
# echo the current commit
|
||||||
log_write " ${INFO} Commit: ${PI_HOLE_COMMIT}"
|
log_write "${INFO} Commit: ${PI_HOLE_COMMIT}\n"
|
||||||
# If git status failed,
|
# If git status failed,
|
||||||
else
|
else
|
||||||
# Return an error message
|
# Return an error message
|
||||||
@ -204,25 +205,25 @@ check_web_version() {
|
|||||||
# If the Web version reported by pihole -v matches the current version
|
# If the Web version reported by pihole -v matches the current version
|
||||||
if [[ "${WEB_VERSION}" == "$(pihole -v | awk '/AdminLTE/ {print $6}' | cut -d ')' -f1)" ]]; then
|
if [[ "${WEB_VERSION}" == "$(pihole -v | awk '/AdminLTE/ {print $6}' | cut -d ')' -f1)" ]]; then
|
||||||
# echo it in green
|
# echo it in green
|
||||||
log_write " ${TICK} Web: ${COL_LIGHT_GREEN}${WEB_VERSION}${COL_NC}"
|
log_write "${TICK} Web: ${COL_LIGHT_GREEN}${WEB_VERSION}${COL_NC}"
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# Show it in yellow with a link to update Pi-hole
|
# Show it in yellow with a link to update Pi-hole
|
||||||
log_write " ${INFO} Web: ${COL_YELLOW}${WEB_VERSION:-Untagged}${COL_NC} (${COL_CYAN}${FAQ_UPDATE_PI_HOLE}${COL_NC})"
|
log_write "${INFO} Web: ${COL_YELLOW}${WEB_VERSION:-Untagged}${COL_NC} (${COL_CYAN}${FAQ_UPDATE_PI_HOLE}${COL_NC})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# If the repo is on the master branch, they are on the stable codebase
|
# If the repo is on the master branch, they are on the stable codebase
|
||||||
if [[ "${WEB_BRANCH}" == "master" ]]; then
|
if [[ "${WEB_BRANCH}" == "master" ]]; then
|
||||||
# so the color of the text is green
|
# so the color of the text is green
|
||||||
log_write " ${TICK} Branch: ${COL_LIGHT_GREEN}${WEB_BRANCH}${COL_NC}"
|
log_write "${TICK} Branch: ${COL_LIGHT_GREEN}${WEB_BRANCH}${COL_NC}"
|
||||||
else
|
else
|
||||||
# If it is any other branch, they are in a developement branch
|
# If it is any other branch, they are in a developement branch
|
||||||
# So show that in yellow, signifying it's something to take a look at, but not a critical error
|
# So show that in yellow, signifying it's something to take a look at, but not a critical error
|
||||||
log_write " ${INFO} Branch: ${COL_YELLOW}${WEB_BRANCH:-Detached}${COL_NC} (${COL_CYAN}${FAQ_CHECKOUT_COMMAND}${COL_NC})"
|
log_write "${INFO} Branch: ${COL_YELLOW}${WEB_BRANCH:-Detached}${COL_NC} (${COL_CYAN}${FAQ_CHECKOUT_COMMAND}${COL_NC})"
|
||||||
fi
|
fi
|
||||||
# echo the current commit
|
# echo the current commit
|
||||||
log_write " ${INFO} Commit: ${WEB_COMMIT}"
|
log_write "${INFO} Commit: ${WEB_COMMIT}\n"
|
||||||
# If git status failed,
|
# If git status failed,
|
||||||
else
|
else
|
||||||
# Return an error message
|
# Return an error message
|
||||||
@ -238,10 +239,10 @@ check_ftl_version() {
|
|||||||
# Compare the current FTL version to the remote version
|
# Compare the current FTL version to the remote version
|
||||||
if [[ "${FTL_VERSION}" == "$(pihole -v | awk '/FTL/ {print $6}' | cut -d ')' -f1)" ]]; then
|
if [[ "${FTL_VERSION}" == "$(pihole -v | awk '/FTL/ {print $6}' | cut -d ')' -f1)" ]]; then
|
||||||
# If they are the same, FTL is up-to-date
|
# If they are the same, FTL is up-to-date
|
||||||
log_write " ${TICK} FTL: ${COL_LIGHT_GREEN}${FTL_VERSION}${COL_NC}"
|
log_write "${TICK} FTL: ${COL_LIGHT_GREEN}${FTL_VERSION}${COL_NC}"
|
||||||
else
|
else
|
||||||
# If not, show it in yellow, signifying there is an update
|
# If not, show it in yellow, signifying there is an update
|
||||||
log_write " ${TICK} FTL: ${COL_YELLOW}${FTL_VERSION}${COL_NC}"
|
log_write "${TICK} FTL: ${COL_YELLOW}${FTL_VERSION}${COL_NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,10 +255,10 @@ check_web_server_version() {
|
|||||||
# If the Web server does not have a version (the variable is empty)
|
# If the Web server does not have a version (the variable is empty)
|
||||||
if [[ -z "${WEB_SERVER_VERSON}" ]]; then
|
if [[ -z "${WEB_SERVER_VERSON}" ]]; then
|
||||||
# Display and error
|
# Display and error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}${WEB_SERVER} version could not be detected.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}${WEB_SERVER} version could not be detected.${COL_NC}"
|
||||||
else
|
else
|
||||||
# Otherwise, display the version
|
# Otherwise, display the version
|
||||||
log_write " ${TICK} ${WEB_SERVER}: ${WEB_SERVER_VERSON}"
|
log_write "${TICK} ${WEB_SERVER}: ${WEB_SERVER_VERSON}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,10 +271,10 @@ check_resolver_server_version() {
|
|||||||
# If the DNS server does not have a version (the variable is empty)
|
# If the DNS server does not have a version (the variable is empty)
|
||||||
if [[ -z "${RESOVLER_VERSON}" ]]; then
|
if [[ -z "${RESOVLER_VERSON}" ]]; then
|
||||||
# Display and error
|
# Display and error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}${RESOLVER} version could not be detected.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}${RESOLVER} version could not be detected.${COL_NC}"
|
||||||
else
|
else
|
||||||
# Otherwise, display the version
|
# Otherwise, display the version
|
||||||
log_write " ${TICK} ${RESOLVER}: ${RESOVLER_VERSON}"
|
log_write "${TICK} ${RESOLVER}: ${RESOVLER_VERSON}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,10 +284,10 @@ check_php_version() {
|
|||||||
# If no version is detected,
|
# If no version is detected,
|
||||||
if [[ -z "${PHP_VERSION}" ]]; then
|
if [[ -z "${PHP_VERSION}" ]]; then
|
||||||
# show an error
|
# show an error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}PHP version could not be detected.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}PHP version could not be detected.${COL_NC}"
|
||||||
else
|
else
|
||||||
# Otherwise, show the version
|
# Otherwise, show the version
|
||||||
log_write " ${TICK} PHP: ${PHP_VERSION}"
|
log_write "${TICK} PHP: ${PHP_VERSION}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +319,7 @@ get_distro_attributes() {
|
|||||||
# so print it when we find it
|
# so print it when we find it
|
||||||
PRETTY_NAME_VALUE=$(echo "${distro_attribute}" | grep "PRETTY_NAME" | cut -d '=' -f2- | tr -d '"')
|
PRETTY_NAME_VALUE=$(echo "${distro_attribute}" | grep "PRETTY_NAME" | cut -d '=' -f2- | tr -d '"')
|
||||||
# and then echoed out to the screen
|
# and then echoed out to the screen
|
||||||
log_write " ${INFO} ${PRETTY_NAME_VALUE}"
|
log_write "${INFO} ${PRETTY_NAME_VALUE}"
|
||||||
else
|
else
|
||||||
# Since we only need the pretty name, we can just skip over anything that is not a match
|
# Since we only need the pretty name, we can just skip over anything that is not a match
|
||||||
:
|
:
|
||||||
@ -341,7 +342,7 @@ diagnose_operating_system() {
|
|||||||
# display the attributes to the user from the function made earlier
|
# display the attributes to the user from the function made earlier
|
||||||
get_distro_attributes || \
|
get_distro_attributes || \
|
||||||
# If it doesn't exist, it's not a system we currently support and link to FAQ
|
# If it doesn't exist, it's not a system we currently support and link to FAQ
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}${error_msg}${COL_NC} (${COL_CYAN}${FAQ_HARDWARE_REQUIREMENTS}${COL_NC})"
|
log_write "${CROSS} ${COL_LIGHT_RED}${error_msg}${COL_NC} (${COL_CYAN}${FAQ_HARDWARE_REQUIREMENTS}${COL_NC})"
|
||||||
}
|
}
|
||||||
|
|
||||||
processor_check() {
|
processor_check() {
|
||||||
@ -351,10 +352,10 @@ processor_check() {
|
|||||||
# If it does not contain a value,
|
# If it does not contain a value,
|
||||||
if [[ -z "${PROCESSOR}" ]]; then
|
if [[ -z "${PROCESSOR}" ]]; then
|
||||||
# we couldn't detect it, so show an error
|
# we couldn't detect it, so show an error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Processor could not be identified.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}Processor could not be identified.${COL_NC}"
|
||||||
else
|
else
|
||||||
# Otherwise, show the processor type
|
# Otherwise, show the processor type
|
||||||
log_write " ${INFO} ${PROCESSOR}"
|
log_write "${INFO} ${PROCESSOR}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,15 +372,16 @@ detect_ip_addresses() {
|
|||||||
# Local iterator
|
# Local iterator
|
||||||
local i
|
local i
|
||||||
# Display the protocol and interface
|
# Display the protocol and interface
|
||||||
log_write " ${TICK} IPv${protocol} on ${PIHOLE_INTERFACE}"
|
log_write "${TICK} IPv${protocol} on ${PIHOLE_INTERFACE}"
|
||||||
# Since there may be more than one IP address, store them in an array
|
# Since there may be more than one IP address, store them in an array
|
||||||
for i in "${!ip_addr_list[@]}"; do
|
for i in "${!ip_addr_list[@]}"; do
|
||||||
# For each one in the list, print it out using the iterator as a numbered list
|
# For each one in the list, print it out
|
||||||
log_write " [$i] ${ip_addr_list[$i]}"
|
log_write "${ip_addr_list[$i]}"
|
||||||
done
|
done
|
||||||
|
log_write ""
|
||||||
else
|
else
|
||||||
# If there are no IPs detected, explain that the protocol is not configured
|
# If there are no IPs detected, explain that the protocol is not configured
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}No IPv${protocol} found on ${PIHOLE_INTERFACE}${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}No IPv${protocol} found on ${PIHOLE_INTERFACE}${COL_NC}\n"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -408,19 +410,19 @@ ping_gateway() {
|
|||||||
# If the gateway variable has a value (meaning a gateway was found),
|
# If the gateway variable has a value (meaning a gateway was found),
|
||||||
if [[ -n "${gateway}" ]]; then
|
if [[ -n "${gateway}" ]]; then
|
||||||
# Let the user know we will ping the gateway for a response
|
# Let the user know we will ping the gateway for a response
|
||||||
log_write " * Trying three pings on IPv${protocol} gateway at ${gateway}..."
|
log_write "* Trying three pings on IPv${protocol} gateway at ${gateway}..."
|
||||||
# Try to quietly ping the gateway 3 times, with a timeout of 3 seconds, using numeric output only,
|
# Try to quietly ping the gateway 3 times, with a timeout of 3 seconds, using numeric output only,
|
||||||
# on the pihole interface, and tail the last three lines of the output
|
# on the pihole interface, and tail the last three lines of the output
|
||||||
# If pinging the gateway is not successful,
|
# If pinging the gateway is not successful,
|
||||||
if ! ping_cmd="$(${cmd} -q -c 3 -W 3 -n ${gateway} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
if ! ping_cmd="$(${cmd} -q -c 3 -W 3 -n ${gateway} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
||||||
# let the user know
|
# let the user know
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Gateway did not respond.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}Gateway did not respond.${COL_NC}\n"
|
||||||
# and return an error code
|
# and return an error code
|
||||||
return 1
|
return 1
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# show a success
|
# show a success
|
||||||
log_write " ${TICK} ${COL_LIGHT_GREEN}Gateway responded.${COL_NC}"
|
log_write "${TICK} ${COL_LIGHT_GREEN}Gateway responded.${COL_NC}\n"
|
||||||
# and return a success code
|
# and return a success code
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -442,15 +444,15 @@ ping_internet() {
|
|||||||
# and Google's public IPv4 address
|
# and Google's public IPv4 address
|
||||||
local public_address="8.8.8.8"
|
local public_address="8.8.8.8"
|
||||||
fi
|
fi
|
||||||
echo -n " ${INFO} Trying three pings on IPv${protocol} to reach the Internet..."
|
echo -n "${INFO} Trying three pings on IPv${protocol} to reach the Internet..."
|
||||||
# Try to ping the address 3 times
|
# Try to ping the address 3 times
|
||||||
if ! ping_inet="$(${cmd} -q -W 3 -c 3 -n ${public_address} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
if ! ping_inet="$(${cmd} -q -W 3 -c 3 -n ${public_address} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
||||||
# if it's unsuccessful, show an error
|
# if it's unsuccessful, show an error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Cannot reach the Internet.${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}Cannot reach the Internet.${COL_NC}\n"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
# Otherwise, show success
|
# Otherwise, show success
|
||||||
log_write " ${TICK} ${COL_LIGHT_GREEN}Query responded.${COL_NC}"
|
log_write "${TICK} ${COL_LIGHT_GREEN}Query responded.${COL_NC}\n"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -458,7 +460,7 @@ ping_internet() {
|
|||||||
check_required_ports() {
|
check_required_ports() {
|
||||||
# Since Pi-hole needs 53, 80, and 4711, check what they are being used by
|
# Since Pi-hole needs 53, 80, and 4711, check what they are being used by
|
||||||
# so we can detect any issues
|
# so we can detect any issues
|
||||||
log_write " ${INFO} Ports in use:"
|
log_write "${INFO} Ports in use:"
|
||||||
# Create an array for these ports in use
|
# Create an array for these ports in use
|
||||||
ports_in_use=()
|
ports_in_use=()
|
||||||
# Sort the addresses and remove duplicates
|
# Sort the addresses and remove duplicates
|
||||||
@ -475,35 +477,35 @@ check_required_ports() {
|
|||||||
case "${port_number}" in
|
case "${port_number}" in
|
||||||
53) if [[ "${service_name}" == "dnsmasq" ]]; then
|
53) if [[ "${service_name}" == "dnsmasq" ]]; then
|
||||||
# if port 53 is dnsmasq, show it in green as it's standard
|
# if port 53 is dnsmasq, show it in green as it's standard
|
||||||
log_write " [${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
log_write "[${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# Show the service name in red since it's non-standard
|
# Show the service name in red since it's non-standard
|
||||||
log_write " [${COL_LIGHT_RED}${port_number}${COL_NC}] is in use by ${COL_LIGHT_RED}${service_name}${COL_NC}
|
log_write "[${COL_LIGHT_RED}${port_number}${COL_NC}] is in use by ${COL_LIGHT_RED}${service_name}${COL_NC}
|
||||||
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
80) if [[ "${service_name}" == "lighttpd" ]]; then
|
80) if [[ "${service_name}" == "lighttpd" ]]; then
|
||||||
# if port 53 is dnsmasq, show it in green as it's standard
|
# if port 53 is dnsmasq, show it in green as it's standard
|
||||||
log_write " [${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
log_write "[${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# Show the service name in red since it's non-standard
|
# Show the service name in red since it's non-standard
|
||||||
log_write " [${COL_LIGHT_RED}${port_number}${COL_NC}] is in use by ${COL_LIGHT_RED}${service_name}${COL_NC}
|
log_write "[${COL_LIGHT_RED}${port_number}${COL_NC}] is in use by ${COL_LIGHT_RED}${service_name}${COL_NC}
|
||||||
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
4711) if [[ "${service_name}" == "pihole-FT" ]]; then
|
4711) if [[ "${service_name}" == "pihole-FT" ]]; then
|
||||||
# if port 4711 is pihole-FTL, show it in green as it's standard
|
# if port 4711 is pihole-FTL, show it in green as it's standard
|
||||||
log_write " [${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
log_write "[${COL_LIGHT_GREEN}${port_number}${COL_NC}] is in use by ${COL_LIGHT_GREEN}${service_name}${COL_NC}"
|
||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# Show the service name in yellow since it's non-standard, but should still work
|
# Show the service name in yellow since it's non-standard, but should still work
|
||||||
log_write " [${COL_YELLOW}${port_number}${COL_NC}] is in use by ${COL_YELLOW}${service_name}${COL_NC}
|
log_write "[${COL_YELLOW}${port_number}${COL_NC}] is in use by ${COL_YELLOW}${service_name}${COL_NC}
|
||||||
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
Please see: ${COL_CYAN}https://discourse.pi-hole.net/t/hardware-software-requirements/273#ports${COL_NC}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) log_write " [${port_number}] is in use by ${service_name}";
|
*) log_write "[${port_number}] is in use by ${service_name}";
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -533,19 +535,19 @@ check_x_headers() {
|
|||||||
# If the X-header found by curl matches what is should be,
|
# If the X-header found by curl matches what is should be,
|
||||||
if [[ $block_page == $block_page_working ]]; then
|
if [[ $block_page == $block_page_working ]]; then
|
||||||
# display a success message
|
# display a success message
|
||||||
log_write " $TICK ${COL_LIGHT_GREEN}${block_page}${COL_NC}"
|
log_write "$TICK ${COL_LIGHT_GREEN}${block_page}${COL_NC}"
|
||||||
else
|
else
|
||||||
# Otherwise, show an error
|
# Otherwise, show an error
|
||||||
log_write " $CROSS ${COL_LIGHT_RED}X-Header does not match or could not be retrieved.${COL_NC}"
|
log_write "$CROSS ${COL_LIGHT_RED}X-Header does not match or could not be retrieved.${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Same logic applies to the dashbord as above, if the X-Header matches what a working system shoud have,
|
# Same logic applies to the dashbord as above, if the X-Header matches what a working system shoud have,
|
||||||
if [[ $dashboard == $dashboard_working ]]; then
|
if [[ $dashboard == $dashboard_working ]]; then
|
||||||
# then we can show a success
|
# then we can show a success
|
||||||
log_write " $TICK ${COL_LIGHT_GREEN}${dashboard}${COL_NC}"
|
log_write "$TICK ${COL_LIGHT_GREEN}${dashboard}${COL_NC}"
|
||||||
else
|
else
|
||||||
# Othewise, it's a failure since the X-Headers either don't exist or have been modified in some way
|
# Othewise, it's a failure since the X-Headers either don't exist or have been modified in some way
|
||||||
log_write " $CROSS ${COL_LIGHT_RED}X-Header does not match or could not be retrieved.${COL_NC}"
|
log_write "$CROSS ${COL_LIGHT_RED}X-Header does not match or could not be retrieved.${COL_NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,10 +592,10 @@ dig_at() {
|
|||||||
# First, do a dig on localhost to see if Pi-hole can use itself to block a domain
|
# 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 local_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @${local_address} +short "${record_type}"); then
|
||||||
# If it can, show sucess
|
# If it can, show sucess
|
||||||
log_write " ${TICK} ${COL_LIGHT_GREEN}${random_url} is ${local_dig}${COL_NC} via localhost (${local_address})"
|
log_write "${TICK} ${random_url} ${COL_LIGHT_GREEN}is ${local_dig}${COL_NC} via localhost (${local_address})"
|
||||||
else
|
else
|
||||||
# Otherwise, show a failure
|
# Otherwise, show a failure
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${random_url} ${COL_LIGHT_RED}via localhost${COL_NC} (${local_address})"
|
log_write "${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${random_url} ${COL_LIGHT_RED}via localhost${COL_NC} (${local_address})"
|
||||||
fi
|
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
|
||||||
@ -604,20 +606,20 @@ dig_at() {
|
|||||||
# If Pi-hole can dig itself from it's IP (not the loopback address)
|
# If Pi-hole can dig itself from it's IP (not the loopback address)
|
||||||
if pihole_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @${pihole_address} +short "${record_type}"); then
|
if pihole_dig=$(dig +tries=1 +time=2 -"${protocol}" "${random_url}" @${pihole_address} +short "${record_type}"); then
|
||||||
# show a success
|
# show a success
|
||||||
log_write " ${TICK} ${COL_LIGHT_GREEN}${random_url} is ${pihole_dig}${COL_NC} via Pi-hole (${pihole_address})"
|
log_write "${TICK} ${random_url} ${COL_LIGHT_GREEN}is ${pihole_dig}${COL_NC} via Pi-hole (${pihole_address})"
|
||||||
else
|
else
|
||||||
# Othewise, show a failure
|
# Othewise, show a failure
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${random_url} ${COL_LIGHT_RED}via Pi-hole${COL_NC} (${pihole_address})"
|
log_write "${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${random_url} ${COL_LIGHT_RED}via Pi-hole${COL_NC} (${pihole_address})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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} ${COL_LIGHT_GREEN}${remote_url} is ${remote_dig}${COL_NC} via a remote, public DNS server (${remote_address})"
|
log_write "${TICK} ${remote_url} ${COL_LIGHT_GREEN}is ${remote_dig}${COL_NC} via a remote, public DNS server (${remote_address})"
|
||||||
else
|
else
|
||||||
# Otherwise, show an error
|
# Otherwise, show an error
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${remote_url} ${COL_LIGHT_RED}via a remote, public DNS server${COL_NC} (${remote_address})"
|
log_write "${CROSS} ${COL_LIGHT_RED}Failed to resolve${COL_NC} ${remote_url} ${COL_LIGHT_RED}via a remote, public DNS server${COL_NC} (${remote_address})"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,14 +637,25 @@ process_status(){
|
|||||||
# and print it out to the user
|
# and print it out to the user
|
||||||
if [[ "${status_of_process}" == "active" ]]; then
|
if [[ "${status_of_process}" == "active" ]]; then
|
||||||
# If it's active, show it in green
|
# If it's active, show it in green
|
||||||
log_write " ${TICK} ${COL_LIGHT_GREEN}${i}${COL_NC} daemon is ${COL_LIGHT_GREEN}${status_of_process}${COL_NC}"
|
log_write "${TICK} ${COL_LIGHT_GREEN}${i}${COL_NC} daemon is ${COL_LIGHT_GREEN}${status_of_process}${COL_NC}"
|
||||||
else
|
else
|
||||||
# If it's not, show it in red
|
# If it's not, show it in red
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}${i}${COL_NC} daemon is ${COL_LIGHT_RED}${status_of_process}${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}${i}${COL_NC} daemon is ${COL_LIGHT_RED}${status_of_process}${COL_NC}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_array_from_file() {
|
||||||
|
local filename="${1}"
|
||||||
|
if [[ -d "${filename}" ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
while IFS= read -r line;do
|
||||||
|
file_content+=("${line}")
|
||||||
|
done < "${filename}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
parse_file() {
|
parse_file() {
|
||||||
# Set the first argument passed to this function as a named variable for better readability
|
# Set the first argument passed to this function as a named variable for better readability
|
||||||
local filename="${1}"
|
local filename="${1}"
|
||||||
@ -655,8 +668,8 @@ 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
|
||||||
# display the information with the ${INFO} icon
|
# Display the file's content
|
||||||
log_write " ${INFO} ${file_lines}"
|
log_write " ${file_lines}" | grep -v "#" | sed '/^$/d'
|
||||||
done
|
done
|
||||||
# Set the IFS back to what it was
|
# Set the IFS back to what it was
|
||||||
IFS="$OLD_IFS"
|
IFS="$OLD_IFS"
|
||||||
@ -668,7 +681,7 @@ diagnose_setup_variables() {
|
|||||||
|
|
||||||
# If the variable file exists,
|
# If the variable file exists,
|
||||||
file_exists "${VARSFILE}" && \
|
file_exists "${VARSFILE}" && \
|
||||||
log_write " * Sourcing ${VARSFILE}...";
|
log_write "* Sourcing ${VARSFILE}...";
|
||||||
# source it
|
# source it
|
||||||
source ${VARSFILE};
|
source ${VARSFILE};
|
||||||
# and display a green check mark with ${DONE}
|
# and display a green check mark with ${DONE}
|
||||||
@ -701,10 +714,10 @@ dir_check() {
|
|||||||
for filename in "${directory}"; do
|
for filename in "${directory}"; do
|
||||||
# check if exists first; if it does,
|
# check if exists first; if it does,
|
||||||
file_exists "${filename}" && \
|
file_exists "${filename}" && \
|
||||||
# show a success message
|
# do nothing
|
||||||
echo_succes_or_fail "Files detected" || \
|
: || \
|
||||||
# Otherwise, show an error
|
# Otherwise, show an error
|
||||||
echo_succes_or_fail "${COL_LIGHT_RED}irectory does not exist.${COL_NC}"
|
echo_succes_or_fail "${COL_LIGHT_RED}directory does not exist.${COL_NC}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,9 +728,19 @@ list_files_in_dir() {
|
|||||||
files_found=( $(ls "${dir_to_parse}") )
|
files_found=( $(ls "${dir_to_parse}") )
|
||||||
# For each file in the arry,
|
# For each file in the arry,
|
||||||
for each_file in "${files_found[@]}"; do
|
for each_file in "${files_found[@]}"; do
|
||||||
|
if [[ -d "${each_file}" ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
# display the information with the ${INFO} icon
|
# display the information with the ${INFO} icon
|
||||||
# Also print the permissions and the user/group
|
# Also print the permissions and the user/group
|
||||||
log_write " ${INFO} $(ls -ld ${dir_to_parse}/${each_file})"
|
log_write "\n${COL_LIGHT_GREEN}$(ls -ld ${dir_to_parse}/${each_file})${COL_NC}"
|
||||||
|
# Otherwise, parse the file's content
|
||||||
|
make_array_from_file "${dir_to_parse}/${each_file}"
|
||||||
|
for each_line in "${file_content[@]}"; do
|
||||||
|
log_write " ${each_line}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
file_content=()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,10 +784,9 @@ analyze_gravity_list() {
|
|||||||
echo_current_diagnostic "Gravity list"
|
echo_current_diagnostic "Gravity list"
|
||||||
# It's helpful to know how big a user's gravity file is
|
# It's helpful to know how big a user's gravity file is
|
||||||
gravity_length=$(grep -c ^ "${GRAVITYFILE}") && \
|
gravity_length=$(grep -c ^ "${GRAVITYFILE}") && \
|
||||||
log_write " ${INFO} ${GRAVITYFILE} is ${gravity_length} lines long.";
|
log_write "${INFO} ${GRAVITYFILE} is ${gravity_length} lines long." || \
|
||||||
parse_file ${GRAVITYFILE} || \
|
|
||||||
# If the previous command failed, something is wrong with the file
|
# If the previous command failed, something is wrong with the file
|
||||||
log_write " ${CROSS} ${COL_LIGHT_RED}${GRAVITYFILE} not found!${COL_NC}"
|
log_write "${CROSS} ${COL_LIGHT_RED}${GRAVITYFILE} not found!${COL_NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
tricorder_use_nc_or_ssl() {
|
tricorder_use_nc_or_ssl() {
|
||||||
@ -778,7 +800,7 @@ tricorder_use_nc_or_ssl() {
|
|||||||
# Otherwise,
|
# Otherwise,
|
||||||
else
|
else
|
||||||
# use net cat
|
# use net cat
|
||||||
log_write " ${INFO} Using ${COL_YELLOW}netcat${COL_NC} for transmission."
|
log_write "${INFO} Using ${COL_YELLOW}netcat${COL_NC} for transmission."
|
||||||
tricorder_token=$(cat ${DEBUG_LOG} | nc tricorder.pi-hole.net 9999)
|
tricorder_token=$(cat ${DEBUG_LOG} | nc tricorder.pi-hole.net 9999)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -791,23 +813,22 @@ upload_to_tricorder() {
|
|||||||
|
|
||||||
# Let the user know debugging is complete
|
# Let the user know debugging is complete
|
||||||
echo ""
|
echo ""
|
||||||
log_write "${TICK} Finished debugging!"
|
log_write "${TICK} ${COL_LIGHT_GREEN}** Finished debugging! **${COL_NC}\n"
|
||||||
|
|
||||||
# Provide information on what they should do with their token
|
# Provide information on what they should do with their token
|
||||||
log_write " * The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only."
|
log_write " * The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only."
|
||||||
log_write " * For more information, see: ${COL_CYAN}https://pi-hole.net/2016/11/07/crack-our-medical-tricorder-win-a-raspberry-pi-3/${COL_NC}"
|
log_write " * For more information, see: ${COL_CYAN}https://pi-hole.net/2016/11/07/crack-our-medical-tricorder-win-a-raspberry-pi-3/${COL_NC}"
|
||||||
log_write ""
|
|
||||||
log_write " * If available, we'll use openssl to upload the log, otherwise it will fall back to netcat."
|
log_write " * If available, we'll use openssl to upload the log, otherwise it will fall back to netcat."
|
||||||
# If pihole -d is running automatically (usually throught the dashboard)
|
# If pihole -d is running automatically (usually throught the dashboard)
|
||||||
if [[ "${AUTOMATED}" ]]; then
|
if [[ "${AUTOMATED}" ]]; then
|
||||||
# let the user know
|
# let the user know
|
||||||
log_write " ${INFO} Debug script running in automated mode"
|
log_write "${INFO} Debug script running in automated mode"
|
||||||
# and then decide again which tool to use to submit it
|
# and then decide again which tool to use to submit it
|
||||||
if command -v openssl &> /dev/null; then
|
if command -v openssl &> /dev/null; then
|
||||||
log_write " ${INFO} Using ${COL_LIGHT_GREEN}openssl${COL_NC} for transmission."
|
log_write "${INFO} Using ${COL_LIGHT_GREEN}openssl${COL_NC} for transmission."
|
||||||
tricorder_token=$(openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin)
|
tricorder_token=$(openssl s_client -quiet -connect tricorder.pi-hole.net:9998 2> /dev/null < /dev/stdin)
|
||||||
else
|
else
|
||||||
log_write " ${INFO} Using ${COL_YELLOW}netcat${COL_NC} for transmission."
|
log_write "${INFO} Using ${COL_YELLOW}netcat${COL_NC} for transmission."
|
||||||
tricorder_token=$(nc tricorder.pi-hole.net 9999 < /dev/stdin)
|
tricorder_token=$(nc tricorder.pi-hole.net 9999 < /dev/stdin)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -819,7 +840,7 @@ upload_to_tricorder() {
|
|||||||
# If they say yes, run our function for uploading the log
|
# If they say yes, run our function for uploading the log
|
||||||
[yY][eE][sS]|[yY]) tricorder_use_nc_or_ssl;;
|
[yY][eE][sS]|[yY]) tricorder_use_nc_or_ssl;;
|
||||||
# If they choose no, just exit out of the script
|
# If they choose no, just exit out of the script
|
||||||
*) log_write " * Log will ${COL_LIGHT_GREE}NOT${COL_NC} be uploaded to tricorder.";exit;
|
*) log_write " * Log will ${COL_LIGHT_GREEN}NOT${COL_NC} be uploaded to tricorder.";exit;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
# Check if tricorder.pi-hole.net is reachable and provide token
|
# Check if tricorder.pi-hole.net is reachable and provide token
|
||||||
@ -829,19 +850,15 @@ upload_to_tricorder() {
|
|||||||
log_write "${COL_LIGHT_PURPLE}***********************************${COL_NC}"
|
log_write "${COL_LIGHT_PURPLE}***********************************${COL_NC}"
|
||||||
log_write "${TICK} Your debug token is: ${COL_LIGHT_GREEN}${tricorder_token}${COL_NC}"
|
log_write "${TICK} Your debug token is: ${COL_LIGHT_GREEN}${tricorder_token}${COL_NC}"
|
||||||
log_write "${COL_LIGHT_PURPLE}***********************************${COL_NC}"
|
log_write "${COL_LIGHT_PURPLE}***********************************${COL_NC}"
|
||||||
log_write ""
|
|
||||||
log_write " Provide this token to the Pi-hole team for assistance:"
|
log_write " * Provide this token to the Pi-hole team for assistance:"
|
||||||
echo ""
|
log_write " * ${COL_CYAN}https://discourse.pi-hole.net${COL_NC}"
|
||||||
log_write " https://discourse.pi-hole.net"
|
log_write " * Your log will self-destruct after ${COL_LIGHT_RED}48 hours${COL_NC}."
|
||||||
echo ""
|
|
||||||
log_write " Your log will self-destruct after 48 hours."
|
|
||||||
else
|
else
|
||||||
log_write " ${CROSS} There was an error uploading your debug log."
|
log_write "${CROSS} ${COL_LIGHT_RED}There was an error uploading your debug log.${COL_NC}"
|
||||||
log_write " Please try again or contact the Pi-hole team for assistance."
|
log_write " * Please try again or contact the Pi-hole team for assistance."
|
||||||
fi
|
fi
|
||||||
echo ""
|
log_write " * A local copy of the debug log can be found at : ${COL_CYAN}${DEBUG_LOG}${COL_NC}\n"
|
||||||
log_write " A local copy of the debug log can be found at : /var/log/pihole_debug.log"
|
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run through all the functions we made
|
# Run through all the functions we made
|
||||||
|
Loading…
Reference in New Issue
Block a user