This is all whitespace changes - the result of pressing alt+shift+f on all bash scripts. Utilising the vscode extension shell-format

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner 2025-02-28 21:56:32 +00:00
parent 821c953216
commit c1936a52b8
No known key found for this signature in database
11 changed files with 468 additions and 419 deletions

View file

@ -10,14 +10,12 @@
# This file is copyright under the latest version of the EUPL. # This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license. # Please see LICENSE file for your rights under this license.
# The basic usage steps are # The basic usage steps are
# 1) Test Availability of the API # 1) Test Availability of the API
# 2) Try to authenticate (read password if needed) # 2) Try to authenticate (read password if needed)
# 3) Get the data from the API endpoint # 3) Get the data from the API endpoint
# 4) Delete the session # 4) Delete the session
TestAPIAvailability() { TestAPIAvailability() {
# as we are running locally, we can get the port value from FTL directly # as we are running locally, we can get the port value from FTL directly
@ -115,14 +113,13 @@ LoginAPI() {
echo "API Authentication: CLI password not available" echo "API Authentication: CLI password not available"
fi fi
# If this did not work, ask the user for the password # If this did not work, ask the user for the password
while [ "${validSession}" = false ] || [ -z "${validSession}" ]; do while [ "${validSession}" = false ] || [ -z "${validSession}" ]; do
echo "Authentication failed. Please enter your Pi-hole password" echo "Authentication failed. Please enter your Pi-hole password"
# secretly read the password # secretly read the password
secretRead; printf '\n' secretRead
printf '\n'
# Try to authenticate again # Try to authenticate again
Authentication "${1}" Authentication "${1}"
@ -160,7 +157,7 @@ LogoutAPI() {
case "${deleteResponse}" in case "${deleteResponse}" in
"401") echo "Logout attempt without a valid session. Unauthorized!" ;; "401") echo "Logout attempt without a valid session. Unauthorized!" ;;
"204") if [ "${1}" = "verbose" ]; then echo "API Logout: ${COL_GREEN}Success${COL_NC} (session deleted)"; fi ;; "204") if [ "${1}" = "verbose" ]; then echo "API Logout: ${COL_GREEN}Success${COL_NC} (session deleted)"; fi ;;
esac; esac
elif [ "${1}" = "verbose" ]; then elif [ "${1}" = "verbose" ]; then
echo "API Logout: ${COL_GREEN}Success${COL_NC} (no valid session)" echo "API Logout: ${COL_GREEN}Success${COL_NC} (no valid session)"
fi fi
@ -216,14 +213,12 @@ secretRead() {
# `-s` option (suppressing the input) or # `-s` option (suppressing the input) or
# `-n` option (reading n chars) # `-n` option (reading n chars)
# This workaround changes the terminal characteristics to not echo input and later resets this option # This workaround changes the terminal characteristics to not echo input and later resets this option
# credits https://stackoverflow.com/a/4316765 # credits https://stackoverflow.com/a/4316765
# showing asterisk instead of password # showing asterisk instead of password
# https://stackoverflow.com/a/24600839 # https://stackoverflow.com/a/24600839
# https://unix.stackexchange.com/a/464963 # https://unix.stackexchange.com/a/464963
# Save current terminal settings (needed for later restore after password prompt) # Save current terminal settings (needed for later restore after password prompt)
stty_orig=$(stty -g) stty_orig=$(stty -g)

View file

@ -137,7 +137,7 @@ RemoveDomain() {
# If there is an .error object in the returned data, display it # If there is an .error object in the returned data, display it
local error local error
error=$(jq --compact-output <<< "${data}" '.error') error=$(jq --compact-output '.error' <<<"${data}")
if [[ $error != "null" && $error != "" ]]; then if [[ $error != "null" && $error != "" ]]; then
echo -e " ${CROSS} Failed to remove domain(s):" echo -e " ${CROSS} Failed to remove domain(s):"
echo -e " $(jq <<<"${data}" '.error')" echo -e " $(jq <<<"${data}" '.error')"
@ -198,17 +198,46 @@ GetComment() {
while (("$#")); do while (("$#")); do
case "${1}" in case "${1}" in
"allow" | "allowlist" ) kindId="exact"; typeId="allow"; abbrv="allow";; "allow" | "allowlist")
"deny" | "denylist" ) kindId="exact"; typeId="deny"; abbrv="deny";; kindId="exact"
"--allow-regex" | "allow-regex" ) kindId="regex"; typeId="allow"; abbrv="--allow-regex";; typeId="allow"
"--allow-wild" | "allow-wild" ) kindId="regex"; typeId="allow"; wildcard=true; abbrv="--allow-wild";; abbrv="allow"
"--regex" | "regex" ) kindId="regex"; typeId="deny"; abbrv="--regex";; ;;
"--wild" | "wildcard" ) kindId="regex"; typeId="deny"; wildcard=true; abbrv="--wild";; "deny" | "denylist")
kindId="exact"
typeId="deny"
abbrv="deny"
;;
"--allow-regex" | "allow-regex")
kindId="regex"
typeId="allow"
abbrv="--allow-regex"
;;
"--allow-wild" | "allow-wild")
kindId="regex"
typeId="allow"
wildcard=true
abbrv="--allow-wild"
;;
"--regex" | "regex")
kindId="regex"
typeId="deny"
abbrv="--regex"
;;
"--wild" | "wildcard")
kindId="regex"
typeId="deny"
wildcard=true
abbrv="--wild"
;;
"-d" | "remove" | "delete") addmode=false ;; "-d" | "remove" | "delete") addmode=false ;;
"-q" | "--quiet") verbose=false ;; "-q" | "--quiet") verbose=false ;;
"-h" | "--help") helpFunc ;; "-h" | "--help") helpFunc ;;
"-l" | "--list") Displaylist ;; "-l" | "--list") Displaylist ;;
"--comment" ) GetComment "${2}"; shift;; "--comment")
GetComment "${2}"
shift
;;
*) CreateDomainList "${1}" ;; *) CreateDomainList "${1}" ;;
esac esac
shift shift

View file

@ -56,13 +56,13 @@ checkout() {
if ! is_repo "${PI_HOLE_FILES_DIR}"; then if ! is_repo "${PI_HOLE_FILES_DIR}"; then
echo -e " ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!" echo -e " ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}" echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
exit 1; exit 1
fi fi
if ! is_repo "${webInterfaceDir}"; then if ! is_repo "${webInterfaceDir}"; then
echo -e " ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!" echo -e " ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!"
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}" echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
exit 1; exit 1
fi fi
if [[ -z "${1}" ]]; then if [[ -z "${1}" ]]; then
@ -80,10 +80,16 @@ checkout() {
echo -e " ${INFO} Shortcut \"${COL_YELLOW}dev${COL_NC}\" detected - checking out development branches..." echo -e " ${INFO} Shortcut \"${COL_YELLOW}dev${COL_NC}\" detected - checking out development branches..."
echo "" echo ""
echo -e " ${INFO} Pi-hole Core" echo -e " ${INFO} Pi-hole Core"
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo " ${CROSS} Unable to pull Core development branch"; exit 1; } fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || {
echo " ${CROSS} Unable to pull Core development branch"
exit 1
}
echo "" echo ""
echo -e " ${INFO} Web interface" echo -e " ${INFO} Web interface"
fetch_checkout_pull_branch "${webInterfaceDir}" "development" || { echo " ${CROSS} Unable to pull Web development branch"; exit 1; } fetch_checkout_pull_branch "${webInterfaceDir}" "development" || {
echo " ${CROSS} Unable to pull Web development branch"
exit 1
}
#echo -e " ${TICK} Pi-hole Core" #echo -e " ${TICK} Pi-hole Core"
local path local path
@ -94,9 +100,15 @@ checkout() {
# Shortcut to check out master branches # Shortcut to check out master branches
echo -e " ${INFO} Shortcut \"${COL_YELLOW}master${COL_NC}\" detected - checking out master branches..." echo -e " ${INFO} Shortcut \"${COL_YELLOW}master${COL_NC}\" detected - checking out master branches..."
echo -e " ${INFO} Pi-hole core" echo -e " ${INFO} Pi-hole core"
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo " ${CROSS} Unable to pull Core master branch"; exit 1; } fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || {
echo " ${CROSS} Unable to pull Core master branch"
exit 1
}
echo -e " ${INFO} Web interface" echo -e " ${INFO} Web interface"
fetch_checkout_pull_branch "${webInterfaceDir}" "master" || { echo " ${CROSS} Unable to pull Web master branch"; exit 1; } fetch_checkout_pull_branch "${webInterfaceDir}" "master" || {
echo " ${CROSS} Unable to pull Web master branch"
exit 1
}
#echo -e " ${TICK} Web Interface" #echo -e " ${TICK} Web Interface"
local path local path
path="master/${binary}" path="master/${binary}"

View file

@ -196,16 +196,16 @@ compare_local_version_to_git_version() {
# If the pihole git directory exists, # If the pihole git directory exists,
if [[ -d "${git_dir}" ]]; then if [[ -d "${git_dir}" ]]; then
# move into it # move into it
cd "${git_dir}" || \ cd "${git_dir}" ||
# If not, show an error # If not, show an error
log_write "${COL_RED}Could not cd into ${git_dir}$COL_NC" log_write "${COL_RED}Could not cd into ${git_dir}$COL_NC"
if git status &>/dev/null; then if git status &>/dev/null; then
# The current version the user is on # The current version the user is on
local local_version local local_version
local_version=$(git describe --tags --abbrev=0 2> /dev/null); local_version=$(git describe --tags --abbrev=0 2>/dev/null)
# What branch they are on # What branch they are on
local local_branch local local_branch
local_branch=$(git rev-parse --abbrev-ref HEAD); local_branch=$(git rev-parse --abbrev-ref HEAD)
# The commit they are on # The commit they are on
local local_commit local local_commit
local_commit=$(git describe --long --dirty --tags --always) local_commit=$(git describe --long --dirty --tags --always)
@ -269,7 +269,6 @@ check_ftl_version() {
FTL_BRANCH=$(pihole-FTL branch) FTL_BRANCH=$(pihole-FTL branch)
FTL_COMMIT=$(pihole-FTL --hash) FTL_COMMIT=$(pihole-FTL --hash)
log_write "${TICK} Version: ${FTL_VERSION}" log_write "${TICK} Version: ${FTL_VERSION}"
# If they use the master branch, they are on the stable codebase # If they use the master branch, they are on the stable codebase
@ -305,7 +304,10 @@ os_check() {
detected_os=$(grep "\bID\b" /etc/os-release | cut -d '=' -f2 | tr -d '"') detected_os=$(grep "\bID\b" /etc/os-release | cut -d '=' -f2 | tr -d '"')
detected_version=$(grep VERSION_ID /etc/os-release | cut -d '=' -f2 | tr -d '"') detected_version=$(grep VERSION_ID /etc/os-release | cut -d '=' -f2 | tr -d '"')
cmdResult="$(dig -4 +short -t txt "${remote_os_domain}" @ns1.pi-hole.net 2>&1; echo $?)" cmdResult="$(
dig -4 +short -t txt "${remote_os_domain}" @ns1.pi-hole.net 2>&1
echo $?
)"
#Get the return code of the previous command (last line) #Get the return code of the previous command (last line)
digReturnCode="${cmdResult##*$'\n'}" digReturnCode="${cmdResult##*$'\n'}"
@ -319,7 +321,10 @@ os_check() {
log_write "${CROSS} dig response: ${response}" log_write "${CROSS} dig response: ${response}"
log_write "${INFO} Retrying via IPv6" log_write "${INFO} Retrying via IPv6"
cmdResult="$(dig -6 +short -t txt "${remote_os_domain}" @ns1.pi-hole.net 2>&1; echo $?)" cmdResult="$(
dig -6 +short -t txt "${remote_os_domain}" @ns1.pi-hole.net 2>&1
echo $?
)"
#Get the return code of the previous command (last line) #Get the return code of the previous command (last line)
digReturnCode="${cmdResult##*$'\n'}" digReturnCode="${cmdResult##*$'\n'}"
@ -333,16 +338,14 @@ os_check() {
log_write "${CROSS} Error: ${COL_RED}dig command failed - Unable to check OS${COL_NC}" log_write "${CROSS} Error: ${COL_RED}dig command failed - Unable to check OS${COL_NC}"
else else
IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"') IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"')
for distro_and_versions in "${supportedOS[@]}" for distro_and_versions in "${supportedOS[@]}"; do
do
distro_part="${distro_and_versions%%=*}" distro_part="${distro_and_versions%%=*}"
versions_part="${distro_and_versions##*=}" versions_part="${distro_and_versions##*=}"
if [[ "${detected_os^^}" =~ ${distro_part^^} ]]; then if [[ "${detected_os^^}" =~ ${distro_part^^} ]]; then
valid_os=true valid_os=true
IFS="," read -r -a supportedVer <<<"${versions_part}" IFS="," read -r -a supportedVer <<<"${versions_part}"
for version in "${supportedVer[@]}" for version in "${supportedVer[@]}"; do
do
if [[ "${detected_version}" =~ $version ]]; then if [[ "${detected_version}" =~ $version ]]; then
valid_version=true valid_version=true
break break
@ -409,7 +412,7 @@ check_selinux() {
log_write "${CROSS} ${COL_RED}Default SELinux: $DEFAULT_SELINUX${COL_NC}" log_write "${CROSS} ${COL_RED}Default SELinux: $DEFAULT_SELINUX${COL_NC}"
;; ;;
*) # 'permissive' and 'disabled' *) # 'permissive' and 'disabled'
log_write "${TICK} ${COL_GREEN}Default SELinux: $DEFAULT_SELINUX${COL_NC}"; log_write "${TICK} ${COL_GREEN}Default SELinux: $DEFAULT_SELINUX${COL_NC}"
;; ;;
esac esac
# Check the current state of SELinux # Check the current state of SELinux
@ -419,11 +422,11 @@ check_selinux() {
log_write "${CROSS} ${COL_RED}Current SELinux: $CURRENT_SELINUX${COL_NC}" log_write "${CROSS} ${COL_RED}Current SELinux: $CURRENT_SELINUX${COL_NC}"
;; ;;
*) # 'permissive' and 'disabled' *) # 'permissive' and 'disabled'
log_write "${TICK} ${COL_GREEN}Current SELinux: $CURRENT_SELINUX${COL_NC}"; log_write "${TICK} ${COL_GREEN}Current SELinux: $CURRENT_SELINUX${COL_NC}"
;; ;;
esac esac
else else
log_write "${INFO} ${COL_GREEN}SELinux not detected${COL_NC}"; log_write "${INFO} ${COL_GREEN}SELinux not detected${COL_NC}"
fi fi
} }
@ -436,7 +439,7 @@ check_firewalld() {
# get its status via systemctl # get its status via systemctl
local firewalld_status local firewalld_status
firewalld_status=$(systemctl is-active firewalld) firewalld_status=$(systemctl is-active firewalld)
log_write "${INFO} ${COL_GREEN}Firewalld service ${firewalld_status}${COL_NC}"; log_write "${INFO} ${COL_GREEN}Firewalld service ${firewalld_status}${COL_NC}"
if [ "${firewalld_status}" == "active" ]; then if [ "${firewalld_status}" == "active" ]; then
# test common required service ports # test common required service ports
local firewalld_enabled_services local firewalld_enabled_services
@ -444,7 +447,7 @@ check_firewalld() {
local firewalld_expected_services=("http" "dns" "dhcp" "dhcpv6") local firewalld_expected_services=("http" "dns" "dhcp" "dhcpv6")
for i in "${firewalld_expected_services[@]}"; do for i in "${firewalld_expected_services[@]}"; do
if [[ "${firewalld_enabled_services}" =~ ${i} ]]; then if [[ "${firewalld_enabled_services}" =~ ${i} ]]; then
log_write "${TICK} ${COL_GREEN} Allow Service: ${i}${COL_NC}"; log_write "${TICK} ${COL_GREEN} Allow Service: ${i}${COL_NC}"
else else
log_write "${CROSS} ${COL_RED} Allow Service: ${i}${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})" log_write "${CROSS} ${COL_RED} Allow Service: ${i}${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
fi fi
@ -453,12 +456,12 @@ check_firewalld() {
local firewalld_zones local firewalld_zones
firewalld_zones=$(firewall-cmd --get-zones) firewalld_zones=$(firewall-cmd --get-zones)
if [[ "${firewalld_zones}" =~ "ftl" ]]; then if [[ "${firewalld_zones}" =~ "ftl" ]]; then
log_write "${TICK} ${COL_GREEN}FTL Custom Zone Detected${COL_NC}"; log_write "${TICK} ${COL_GREEN}FTL Custom Zone Detected${COL_NC}"
# check FTL custom zone interface: lo # check FTL custom zone interface: lo
local firewalld_ftl_zone_interfaces local firewalld_ftl_zone_interfaces
firewalld_ftl_zone_interfaces=$(firewall-cmd --zone=ftl --list-interfaces) firewalld_ftl_zone_interfaces=$(firewall-cmd --zone=ftl --list-interfaces)
if [[ "${firewalld_ftl_zone_interfaces}" =~ "lo" ]]; then if [[ "${firewalld_ftl_zone_interfaces}" =~ "lo" ]]; then
log_write "${TICK} ${COL_GREEN} Local Interface Detected${COL_NC}"; log_write "${TICK} ${COL_GREEN} Local Interface Detected${COL_NC}"
else else
log_write "${CROSS} ${COL_RED} Local Interface Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})" log_write "${CROSS} ${COL_RED} Local Interface Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
fi fi
@ -466,7 +469,7 @@ check_firewalld() {
local firewalld_ftl_zone_ports local firewalld_ftl_zone_ports
firewalld_ftl_zone_ports=$(firewall-cmd --zone=ftl --list-ports) firewalld_ftl_zone_ports=$(firewall-cmd --zone=ftl --list-ports)
if [[ "${firewalld_ftl_zone_ports}" =~ "4711/tcp" ]]; then if [[ "${firewalld_ftl_zone_ports}" =~ "4711/tcp" ]]; then
log_write "${TICK} ${COL_GREEN} FTL Port 4711/tcp Detected${COL_NC}"; log_write "${TICK} ${COL_GREEN} FTL Port 4711/tcp Detected${COL_NC}"
else else
log_write "${CROSS} ${COL_RED} FTL Port 4711/tcp Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})" log_write "${CROSS} ${COL_RED} FTL Port 4711/tcp Not Detected${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS_FIREWALLD})"
fi fi
@ -475,7 +478,7 @@ check_firewalld() {
fi fi
fi fi
else else
log_write "${TICK} ${COL_GREEN}Firewalld service not detected${COL_NC}"; log_write "${TICK} ${COL_GREEN}Firewalld service not detected${COL_NC}"
fi fi
} }
@ -679,7 +682,7 @@ check_required_ports() {
compare_port_to_service_assigned "${ftl}" "${service_name}" "${protocol_type}:${port_number}" compare_port_to_service_assigned "${ftl}" "${service_name}" "${protocol_type}:${port_number}"
else else
# If it's not a default port that Pi-hole needs, just print it out for the user to see # If it's not a default port that Pi-hole needs, just print it out for the user to see
log_write " ${protocol_type}:${port_number} is in use by ${service_name:=<unknown>}"; log_write " ${protocol_type}:${port_number} is in use by ${service_name:=<unknown>}"
fi fi
done done
} }
@ -1002,10 +1005,10 @@ list_files_in_dir() {
if [[ -d "${dir_to_parse}/${each_file}" ]]; then if [[ -d "${dir_to_parse}/${each_file}" ]]; then
# If it's a directory, do nothing # If it's a directory, do nothing
: :
elif [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_DEBUG_LOG}" ]] || \ elif [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_DEBUG_LOG}" ]] ||
[[ "${dir_to_parse}/${each_file}" == "${PIHOLE_RAW_BLOCKLIST_FILES}" ]] || \ [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_RAW_BLOCKLIST_FILES}" ]] ||
[[ "${dir_to_parse}/${each_file}" == "${PIHOLE_INSTALL_LOG_FILE}" ]] || \ [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_INSTALL_LOG_FILE}" ]] ||
[[ "${dir_to_parse}/${each_file}" == "${PIHOLE_LOG}" ]] || \ [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_LOG}" ]] ||
[[ "${dir_to_parse}/${each_file}" == "${PIHOLE_LOG_GZIPS}" ]]; then [[ "${dir_to_parse}/${each_file}" == "${PIHOLE_LOG_GZIPS}" ]]; then
: :
elif [[ "${dir_to_parse}" == "${DNSMASQ_D_DIRECTORY}" ]]; then elif [[ "${dir_to_parse}" == "${DNSMASQ_D_DIRECTORY}" ]]; then
@ -1021,13 +1024,15 @@ list_files_in_dir() {
# Check if the file we want to view has a limit (because sometimes we just need a little bit of info from the file, not the entire thing) # Check if the file we want to view has a limit (because sometimes we just need a little bit of info from the file, not the entire thing)
case "${dir_to_parse}/${each_file}" in case "${dir_to_parse}/${each_file}" in
# If it's Web server log, give the first and last 25 lines # If it's Web server log, give the first and last 25 lines
"${PIHOLE_WEBSERVER_LOG}") head_tail_log "${dir_to_parse}/${each_file}" 25 "${PIHOLE_WEBSERVER_LOG}")
head_tail_log "${dir_to_parse}/${each_file}" 25
;; ;;
# Same for the FTL log # Same for the FTL log
"${PIHOLE_FTL_LOG}") head_tail_log "${dir_to_parse}/${each_file}" 35 "${PIHOLE_FTL_LOG}")
head_tail_log "${dir_to_parse}/${each_file}" 35
;; ;;
# parse the file into an array in case we ever need to analyze it line-by-line # parse the file into an array in case we ever need to analyze it line-by-line
*) make_array_from_file "${dir_to_parse}/${each_file}"; *) make_array_from_file "${dir_to_parse}/${each_file}" ;;
esac esac
else else
# Otherwise, do nothing since it's not a file needed for Pi-hole so we don't care about it # Otherwise, do nothing since it's not a file needed for Pi-hole so we don't care about it
@ -1096,12 +1101,12 @@ show_db_entries() {
OLD_IFS="$IFS" OLD_IFS="$IFS"
IFS=$'\r\n' IFS=$'\r\n'
local entries=() local entries=()
mapfile -t entries < <(\ mapfile -t entries < <(
pihole-FTL sqlite3 -ni "${PIHOLE_GRAVITY_DB_FILE}" \ pihole-FTL sqlite3 -ni "${PIHOLE_GRAVITY_DB_FILE}" \
-cmd ".headers on" \ -cmd ".headers on" \
-cmd ".mode column" \ -cmd ".mode column" \
-cmd ".width ${widths}" \ -cmd ".width ${widths}" \
"${query}"\ "${query}"
) )
for line in "${entries[@]}"; do for line in "${entries[@]}"; do
@ -1121,12 +1126,12 @@ show_FTL_db_entries() {
OLD_IFS="$IFS" OLD_IFS="$IFS"
IFS=$'\r\n' IFS=$'\r\n'
local entries=() local entries=()
mapfile -t entries < <(\ mapfile -t entries < <(
pihole-FTL sqlite3 -ni "${PIHOLE_FTL_DB_FILE}" \ pihole-FTL sqlite3 -ni "${PIHOLE_FTL_DB_FILE}" \
-cmd ".headers on" \ -cmd ".headers on" \
-cmd ".mode column" \ -cmd ".mode column" \
-cmd ".width ${widths}" \ -cmd ".width ${widths}" \
"${query}"\ "${query}"
) )
for line in "${entries[@]}"; do for line in "${entries[@]}"; do
@ -1142,7 +1147,10 @@ check_dhcp_servers() {
OLD_IFS="$IFS" OLD_IFS="$IFS"
IFS=$'\n' IFS=$'\n'
local entries=() local entries=()
mapfile -t entries < <(pihole-FTL dhcp-discover & spinner) mapfile -t entries < <(
pihole-FTL dhcp-discover &
spinner
)
for line in "${entries[@]}"; do for line in "${entries[@]}"; do
log_write " ${line}" log_write " ${line}"
@ -1221,14 +1229,19 @@ database_integrity_check(){
local database="${1}" local database="${1}"
log_write "${INFO} Checking integrity of ${database} ... (this can take several minutes)" log_write "${INFO} Checking integrity of ${database} ... (this can take several minutes)"
result="$(pihole-FTL sqlite3 -ni "${database}" "PRAGMA integrity_check" 2>&1 & spinner)" result="$(
pihole-FTL sqlite3 -ni "${database}" "PRAGMA integrity_check" 2>&1 &
spinner
)"
if [[ ${result} = "ok" ]]; then if [[ ${result} = "ok" ]]; then
log_write "${TICK} Integrity of ${database} intact" log_write "${TICK} Integrity of ${database} intact"
log_write "${INFO} Checking foreign key constraints of ${database} ... (this can take several minutes)" log_write "${INFO} Checking foreign key constraints of ${database} ... (this can take several minutes)"
unset result unset result
result="$(pihole-FTL sqlite3 -ni "${database}" -cmd ".headers on" -cmd ".mode column" "PRAGMA foreign_key_check" 2>&1 & spinner)" result="$(
pihole-FTL sqlite3 -ni "${database}" -cmd ".headers on" -cmd ".mode column" "PRAGMA foreign_key_check" 2>&1 &
spinner
)"
if [[ -z ${result} ]]; then if [[ -z ${result} ]]; then
log_write "${TICK} No foreign key errors in ${database}" log_write "${TICK} No foreign key errors in ${database}"
else else
@ -1318,7 +1331,6 @@ curl_to_tricorder() {
fi fi
} }
upload_to_tricorder() { upload_to_tricorder() {
local username="pihole" local username="pihole"
# Set the permissions and owner # Set the permissions and owner
@ -1350,7 +1362,10 @@ 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]) curl_to_tricorder ;; [yY][eE][sS] | [yY]) curl_to_tricorder ;;
# 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_GREEN}NOT${COL_NC} be uploaded to tricorder.\\n * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG}${COL_NC}\\n";exit; *)
log_write " * Log will ${COL_GREEN}NOT${COL_NC} be uploaded to tricorder.\\n * A local copy of the debug log can be found at: ${COL_CYAN}${PIHOLE_DEBUG_LOG}${COL_NC}\\n"
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

View file

@ -119,4 +119,3 @@ else
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database" echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database"
fi fi
fi fi

View file

@ -69,7 +69,6 @@ GitCheckUpdateAvail() {
REMOTE="$(git rev-parse "@{upstream}")" REMOTE="$(git rev-parse "@{upstream}")"
fi fi
if [[ "${#LOCAL}" == 0 ]]; then if [[ "${#LOCAL}" == 0 ]]; then
echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support" echo -e "\\n ${COL_LIGHT_RED}Error: Local revision could not be obtained, please contact Pi-hole Support"
echo -e " Additional debugging output:${COL_NC}" echo -e " Additional debugging output:${COL_NC}"
@ -119,7 +118,7 @@ main() {
if ! is_repo "${PI_HOLE_FILES_DIR}"; then if ! is_repo "${PI_HOLE_FILES_DIR}"; then
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!" echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}" echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
exit 1; exit 1
fi fi
echo -e " ${INFO} Checking for updates..." echo -e " ${INFO} Checking for updates..."
@ -135,7 +134,7 @@ main() {
if ! is_repo "${ADMIN_INTERFACE_DIR}"; then if ! is_repo "${ADMIN_INTERFACE_DIR}"; then
echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!" echo -e "\\n ${COL_LIGHT_RED}Error: Web Admin repo is missing from system!"
echo -e " Please re-run install script from https://pi-hole.net${COL_NC}" echo -e " Please re-run install script from https://pi-hole.net${COL_NC}"
exit 1; exit 1
fi fi
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}"; then if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}"; then
@ -169,6 +168,7 @@ main() {
*) *)
echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, contact support${COL_NC}" echo -e " ${INFO} FTL:\\t\\t${COL_LIGHT_RED}Something has gone wrong, contact support${COL_NC}"
exit 1 exit 1
;;
esac esac
FTL_update=false FTL_update=false
fi fi
@ -218,7 +218,7 @@ main() {
fi fi
if [[ "${FTL_update}" == true || "${core_update}" == true ]]; then if [[ "${FTL_update}" == true || "${core_update}" == true ]]; then
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --repair --unattended || \ ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --repair --unattended ||
echo -e "${basicError}" && exit 1 echo -e "${basicError}" && exit 1
fi fi

View file

@ -225,7 +225,8 @@ os_check_dig(){
local nameserver="$3" local nameserver="$3"
local response local response
response="$(dig -"${protocol}" +short -t txt "${domain}" "${nameserver}" 2>&1 response="$(
dig -"${protocol}" +short -t txt "${domain}" "${nameserver}" 2>&1
echo $? echo $?
)" )"
echo "${response}" echo "${response}"
@ -2419,7 +2420,6 @@ main() {
# Download or reset the appropriate git repos depending on the 'repair' flag # Download or reset the appropriate git repos depending on the 'repair' flag
clone_or_reset_repos clone_or_reset_repos
# Create the pihole user # Create the pihole user
create_pihole_user create_pihole_user
@ -2448,11 +2448,9 @@ main() {
# Copy the temp log file into final log location for storage # Copy the temp log file into final log location for storage
copy_to_install_log copy_to_install_log
# Migrate existing install to v6.0 # Migrate existing install to v6.0
migrate_dnsmasq_configs migrate_dnsmasq_configs
# Check for and disable systemd-resolved-DNSStubListener before reloading resolved # Check for and disable systemd-resolved-DNSStubListener before reloading resolved
# DNSStubListener needs to remain in place for installer to download needed files, # DNSStubListener needs to remain in place for installer to download needed files,
# so this change needs to be made after installation is complete, # so this change needs to be made after installation is complete,

View file

@ -14,7 +14,10 @@ while true; do
read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " answer read -rp " ${QST} Are you sure you would like to remove ${COL_WHITE}Pi-hole${COL_NC}? [y/N] " answer
case ${answer} in case ${answer} in
[Yy]*) break ;; [Yy]*) break ;;
* ) echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been canceled${COL_NC}"; exit 0;; *)
echo -e "${OVER} ${COL_LIGHT_GREEN}Uninstall has been canceled${COL_NC}"
exit 0
;;
esac esac
done done
@ -42,13 +45,12 @@ source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
# package_manager_detect() sourced from basic-install.sh # package_manager_detect() sourced from basic-install.sh
package_manager_detect package_manager_detect
removeMetaPackage() { removeMetaPackage() {
# Purge Pi-hole meta package # Purge Pi-hole meta package
echo "" echo ""
echo -ne " ${INFO} Removing Pi-hole meta package..."; echo -ne " ${INFO} Removing Pi-hole meta package..."
eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &> /dev/null; eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &>/dev/null
echo -e "${OVER} ${INFO} Removed Pi-hole meta package"; echo -e "${OVER} ${INFO} Removed Pi-hole meta package"
} }
@ -57,7 +59,6 @@ removePiholeFiles() {
echo -ne " ${INFO} Removing Web Interface..." echo -ne " ${INFO} Removing Web Interface..."
${SUDO} rm -rf /var/www/html/admin &>/dev/null ${SUDO} rm -rf /var/www/html/admin &>/dev/null
# If the web directory is empty after removing these files, then the parent html directory can be removed. # If the web directory is empty after removing these files, then the parent html directory can be removed.
if [ -d "/var/www/html" ]; then if [ -d "/var/www/html" ]; then
if [[ ! "$(ls -A /var/www/html)" ]]; then if [[ ! "$(ls -A /var/www/html)" ]]; then