mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-07-29 00:24:16 +02:00
Merge branch 'development' into tweak/gravity_options
Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
commit
95d27ac985
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -72,6 +72,7 @@ jobs:
|
|||||||
centos_10,
|
centos_10,
|
||||||
fedora_40,
|
fedora_40,
|
||||||
fedora_41,
|
fedora_41,
|
||||||
|
fedora_42,
|
||||||
]
|
]
|
||||||
env:
|
env:
|
||||||
DISTRO: ${{matrix.distro}}
|
DISTRO: ${{matrix.distro}}
|
||||||
@ -80,7 +81,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4.2.2
|
uses: actions/checkout@v4.2.2
|
||||||
|
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v5.5.0
|
uses: actions/setup-python@v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: "3.10"
|
||||||
|
|
||||||
|
@ -128,7 +128,10 @@ Some of the statistics you can integrate include:
|
|||||||
- Queries cached
|
- Queries cached
|
||||||
- Unique clients
|
- Unique clients
|
||||||
|
|
||||||
Access the API via [`telnet`](https://github.com/pi-hole/FTL), the Web (`admin/api.php`) and Command Line (`pihole -c -j`). You can find out [more details over here](https://discourse.pi-hole.net/t/pi-hole-api/1863).
|
Access the API using:
|
||||||
|
- your browser: http://pi.hole/api/docs
|
||||||
|
- `curl`: `curl --connect-timeout 2 -ks "https://pi.hole/api/stats/summary" -H "Accept: application/json"`;
|
||||||
|
- the command line - examples: `pihole api config/webserver/port` or `pihole api stats/summary`.
|
||||||
|
|
||||||
### The Command-Line Interface
|
### The Command-Line Interface
|
||||||
|
|
||||||
|
@ -296,91 +296,12 @@ check_component_versions() {
|
|||||||
check_ftl_version
|
check_ftl_version
|
||||||
}
|
}
|
||||||
|
|
||||||
os_check() {
|
|
||||||
# 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
|
|
||||||
local remote_os_domain valid_os valid_version detected_os detected_version cmdResult digReturnCode response
|
|
||||||
remote_os_domain=${OS_CHECK_DOMAIN_NAME:-"versions.pi-hole.net"}
|
|
||||||
|
|
||||||
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 '"')
|
|
||||||
|
|
||||||
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)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
# Extract dig response
|
|
||||||
response="${cmdResult%%$'\n'*}"
|
|
||||||
|
|
||||||
if [ "${digReturnCode}" -ne 0 ]; then
|
|
||||||
log_write "${INFO} Distro: ${detected_os^}"
|
|
||||||
log_write "${INFO} Version: ${detected_version}"
|
|
||||||
log_write "${CROSS} dig IPv4 return code: ${COL_RED}${digReturnCode}${COL_NC}"
|
|
||||||
log_write "${CROSS} dig response: ${response}"
|
|
||||||
log_write "${INFO} Retrying via IPv6"
|
|
||||||
|
|
||||||
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)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
# Extract dig response
|
|
||||||
response="${cmdResult%%$'\n'*}"
|
|
||||||
fi
|
|
||||||
# If also no success via IPv6
|
|
||||||
if [ "${digReturnCode}" -ne 0 ]; then
|
|
||||||
log_write "${CROSS} dig IPv6 return code: ${COL_RED}${digReturnCode}${COL_NC}"
|
|
||||||
log_write "${CROSS} dig response: ${response}"
|
|
||||||
log_write "${CROSS} Error: ${COL_RED}dig command failed - Unable to check OS${COL_NC}"
|
|
||||||
else
|
|
||||||
IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"')
|
|
||||||
for distro_and_versions in "${supportedOS[@]}"
|
|
||||||
do
|
|
||||||
distro_part="${distro_and_versions%%=*}"
|
|
||||||
versions_part="${distro_and_versions##*=}"
|
|
||||||
|
|
||||||
if [[ "${detected_os^^}" =~ ${distro_part^^} ]]; then
|
|
||||||
valid_os=true
|
|
||||||
IFS="," read -r -a supportedVer <<<"${versions_part}"
|
|
||||||
for version in "${supportedVer[@]}"
|
|
||||||
do
|
|
||||||
if [[ "${detected_version}" =~ $version ]]; then
|
|
||||||
valid_version=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# If it is a docker container, we can assume the OS is supported
|
|
||||||
[ -n "${DOCKER_VERSION}" ] && valid_os=true && valid_version=true
|
|
||||||
|
|
||||||
local finalmsg
|
|
||||||
if [ "$valid_os" = true ]; then
|
|
||||||
log_write "${TICK} Distro: ${COL_GREEN}${detected_os^}${COL_NC}"
|
|
||||||
|
|
||||||
if [ "$valid_version" = true ]; then
|
|
||||||
log_write "${TICK} Version: ${COL_GREEN}${detected_version}${COL_NC}"
|
|
||||||
finalmsg="${TICK} ${COL_GREEN}Distro and version supported${COL_NC}"
|
|
||||||
else
|
|
||||||
log_write "${CROSS} Version: ${COL_RED}${detected_version}${COL_NC}"
|
|
||||||
finalmsg="${CROSS} Error: ${COL_RED}${detected_os^} is supported but version ${detected_version} is currently unsupported ${COL_NC}(${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_write "${CROSS} Distro: ${COL_RED}${detected_os^}${COL_NC}"
|
|
||||||
finalmsg="${CROSS} Error: ${COL_RED}${detected_os^} is not a supported distro ${COL_NC}(${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print dig response and the final check result
|
|
||||||
log_write "${TICK} dig return code: ${COL_GREEN}${digReturnCode}${COL_NC}"
|
|
||||||
log_write "${INFO} dig response: ${response}"
|
|
||||||
log_write "${finalmsg}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
diagnose_operating_system() {
|
diagnose_operating_system() {
|
||||||
# error message in a variable so we can easily modify it later (or reuse it)
|
# error message in a variable so we can easily modify it later (or reuse it)
|
||||||
local error_msg="Distribution unknown -- most likely you are on an unsupported platform and may run into issues."
|
local error_msg="Distribution unknown -- most likely you are on an unsupported platform and may run into issues."
|
||||||
|
local detected_os
|
||||||
|
local detected_version
|
||||||
|
|
||||||
# Display the current test that is running
|
# Display the current test that is running
|
||||||
echo_current_diagnostic "Operating system"
|
echo_current_diagnostic "Operating system"
|
||||||
|
|
||||||
@ -389,8 +310,13 @@ diagnose_operating_system() {
|
|||||||
|
|
||||||
# If there is a /etc/*release file, it's probably a supported operating system, so we can
|
# If there is a /etc/*release file, it's probably a supported operating system, so we can
|
||||||
if ls /etc/*release 1> /dev/null 2>&1; then
|
if ls /etc/*release 1> /dev/null 2>&1; then
|
||||||
# display the attributes to the user from the function made earlier
|
# display the attributes to the user
|
||||||
os_check
|
|
||||||
|
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 '"')
|
||||||
|
|
||||||
|
log_write "${INFO} Distro: ${detected_os^}"
|
||||||
|
log_write "${INFO} Version: ${detected_version}"
|
||||||
else
|
else
|
||||||
# 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_RED}${error_msg}${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS})"
|
log_write "${CROSS} ${COL_RED}${error_msg}${COL_NC} (${FAQ_HARDWARE_REQUIREMENTS})"
|
||||||
|
@ -112,8 +112,6 @@ main() {
|
|||||||
web_update=false
|
web_update=false
|
||||||
FTL_update=false
|
FTL_update=false
|
||||||
|
|
||||||
# Perform an OS check to ensure we're on an appropriate operating system
|
|
||||||
os_check
|
|
||||||
|
|
||||||
# Install packages used by this installation script (necessary if users have removed e.g. git from their systems)
|
# Install packages used by this installation script (necessary if users have removed e.g. git from their systems)
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
|
@ -227,176 +227,6 @@ is_command() {
|
|||||||
command -v "${check_command}" >/dev/null 2>&1
|
command -v "${check_command}" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
os_check_dig(){
|
|
||||||
local protocol="$1"
|
|
||||||
local domain="$2"
|
|
||||||
local nameserver="$3"
|
|
||||||
local response
|
|
||||||
|
|
||||||
response="$(dig -"${protocol}" +short -t txt "${domain}" "${nameserver}" 2>&1
|
|
||||||
echo $?
|
|
||||||
)"
|
|
||||||
echo "${response}"
|
|
||||||
}
|
|
||||||
|
|
||||||
os_check_dig_response(){
|
|
||||||
# Checks the reply from the dig command to determine if it's a valid response
|
|
||||||
local digReply="$1"
|
|
||||||
local response
|
|
||||||
|
|
||||||
# Dig returned 0 (success), so get the actual response, and loop through it to determine if the detected variables above are valid
|
|
||||||
response="${digReply%%$'\n'*}"
|
|
||||||
# If the value of ${response} is a single 0, then this is the return code, not an actual response.
|
|
||||||
if [ "${response}" == 0 ]; then
|
|
||||||
echo false
|
|
||||||
else
|
|
||||||
echo true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
os_check() {
|
|
||||||
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
|
|
||||||
# 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
|
|
||||||
local remote_os_domain valid_os valid_version valid_response detected_os detected_version display_warning cmdResult digReturnCode response
|
|
||||||
local piholeNameserver="@ns1.pi-hole.net"
|
|
||||||
remote_os_domain=${OS_CHECK_DOMAIN_NAME:-"versions.pi-hole.net"}
|
|
||||||
|
|
||||||
detected_os=$(grep '^ID=' /etc/os-release | cut -d '=' -f2 | tr -d '"')
|
|
||||||
detected_version=$(grep VERSION_ID /etc/os-release | cut -d '=' -f2 | tr -d '"')
|
|
||||||
|
|
||||||
# Test via IPv4 and hardcoded nameserver ns1.pi-hole.net
|
|
||||||
cmdResult=$(os_check_dig 4 "${remote_os_domain}" "${piholeNameserver}")
|
|
||||||
|
|
||||||
# Gets the return code of the previous command (last line)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
if [ ! "${digReturnCode}" == "0" ]; then
|
|
||||||
valid_response=false
|
|
||||||
else
|
|
||||||
valid_response=$(os_check_dig_response cmdResult)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try again via IPv6 and hardcoded nameserver ns1.pi-hole.net
|
|
||||||
if [ "$valid_response" = false ]; then
|
|
||||||
unset valid_response
|
|
||||||
unset cmdResult
|
|
||||||
unset digReturnCode
|
|
||||||
|
|
||||||
cmdResult=$(os_check_dig 6 "${remote_os_domain}" "${piholeNameserver}")
|
|
||||||
# Gets the return code of the previous command (last line)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
if [ ! "${digReturnCode}" == "0" ]; then
|
|
||||||
valid_response=false
|
|
||||||
else
|
|
||||||
valid_response=$(os_check_dig_response cmdResult)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try again without hardcoded nameserver
|
|
||||||
if [ "$valid_response" = false ]; then
|
|
||||||
unset valid_response
|
|
||||||
unset cmdResult
|
|
||||||
unset digReturnCode
|
|
||||||
|
|
||||||
cmdResult=$(os_check_dig 4 "${remote_os_domain}")
|
|
||||||
# Gets the return code of the previous command (last line)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
if [ ! "${digReturnCode}" == "0" ]; then
|
|
||||||
valid_response=false
|
|
||||||
else
|
|
||||||
valid_response=$(os_check_dig_response cmdResult)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$valid_response" = false ]; then
|
|
||||||
unset valid_response
|
|
||||||
unset cmdResult
|
|
||||||
unset digReturnCode
|
|
||||||
|
|
||||||
cmdResult=$(os_check_dig 6 "${remote_os_domain}")
|
|
||||||
# Gets the return code of the previous command (last line)
|
|
||||||
digReturnCode="${cmdResult##*$'\n'}"
|
|
||||||
|
|
||||||
if [ ! "${digReturnCode}" == "0" ]; then
|
|
||||||
valid_response=false
|
|
||||||
else
|
|
||||||
valid_response=$(os_check_dig_response cmdResult)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$valid_response" = true ]; then
|
|
||||||
response="${cmdResult%%$'\n'*}"
|
|
||||||
IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"')
|
|
||||||
for distro_and_versions in "${supportedOS[@]}"; do
|
|
||||||
distro_part="${distro_and_versions%%=*}"
|
|
||||||
versions_part="${distro_and_versions##*=}"
|
|
||||||
|
|
||||||
# If the distro part is a (case-insensitive) substring of the computer OS
|
|
||||||
if [[ "${detected_os^^}" =~ ${distro_part^^} ]]; then
|
|
||||||
valid_os=true
|
|
||||||
IFS="," read -r -a supportedVer <<<"${versions_part}"
|
|
||||||
for version in "${supportedVer[@]}"; do
|
|
||||||
if [[ "${detected_version}" =~ $version ]]; then
|
|
||||||
valid_version=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$valid_os" = true ] && [ "$valid_version" = true ] && [ "$valid_response" = true ]; then
|
|
||||||
display_warning=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$display_warning" != false ]; then
|
|
||||||
if [ "$valid_response" = false ]; then
|
|
||||||
|
|
||||||
if [ "${digReturnCode}" -eq 0 ]; then
|
|
||||||
errStr="dig succeeded, but response was blank. Please contact support"
|
|
||||||
else
|
|
||||||
errStr="dig failed with return code ${digReturnCode}"
|
|
||||||
fi
|
|
||||||
printf " %b %bRetrieval of supported OS list failed. %s. %b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${errStr}" "${COL_NC}"
|
|
||||||
printf " %bUnable to determine if the detected OS (%s %s) is supported%b\\n" "${COL_LIGHT_RED}" "${detected_os^}" "${detected_version}" "${COL_NC}"
|
|
||||||
printf " Possible causes for this include:\\n"
|
|
||||||
printf " - Firewall blocking DNS lookups from Pi-hole device to ns1.pi-hole.net\\n"
|
|
||||||
printf " - DNS resolution issues of the host system\\n"
|
|
||||||
printf " - Other internet connectivity issues\\n"
|
|
||||||
else
|
|
||||||
printf " %b %bUnsupported OS detected: %s %s%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${detected_os^}" "${detected_version}" "${COL_NC}"
|
|
||||||
printf " If you are seeing this message and you do have a supported OS, please contact support.\\n"
|
|
||||||
fi
|
|
||||||
printf "\\n"
|
|
||||||
printf " %bhttps://docs.pi-hole.net/main/prerequisites/#supported-operating-systems%b\\n" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
printf "\\n"
|
|
||||||
printf " If you wish to attempt to continue anyway, you can try one of the following commands to skip this check:\\n"
|
|
||||||
printf "\\n"
|
|
||||||
printf " e.g: If you are seeing this message on a fresh install, you can run:\\n"
|
|
||||||
printf " %bcurl -sSL https://install.pi-hole.net | sudo PIHOLE_SKIP_OS_CHECK=true bash%b\\n" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
printf "\\n"
|
|
||||||
printf " If you are seeing this message after having run pihole -up:\\n"
|
|
||||||
printf " %bsudo PIHOLE_SKIP_OS_CHECK=true pihole -r%b\\n" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
printf " (In this case, your previous run of pihole -up will have already updated the local repository)\\n"
|
|
||||||
printf "\\n"
|
|
||||||
printf " It is possible that the installation will still fail at this stage due to an unsupported configuration.\\n"
|
|
||||||
printf " If that is the case, you can feel free to ask the community on Discourse with the %bCommunity Help%b category:\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
|
||||||
printf " %bhttps://discourse.pi-hole.net/c/bugs-problems-issues/community-help/%b\\n" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
printf "\\n"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
else
|
|
||||||
printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
printf " %b %bPIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
package_manager_detect() {
|
package_manager_detect() {
|
||||||
|
|
||||||
@ -2369,8 +2199,6 @@ main() {
|
|||||||
# Install Pi-hole dependencies
|
# Install Pi-hole dependencies
|
||||||
install_dependent_packages
|
install_dependent_packages
|
||||||
|
|
||||||
# Check that the installed OS is officially supported - display warning if not
|
|
||||||
os_check
|
|
||||||
|
|
||||||
# Check if there is a usable FTL binary available on this architecture - do
|
# Check if there is a usable FTL binary available on this architecture - do
|
||||||
# this early on as FTL is a hard dependency for Pi-hole
|
# this early on as FTL is a hard dependency for Pi-hole
|
||||||
|
40
gravity.sh
40
gravity.sh
@ -348,17 +348,24 @@ gravity_CheckDNSResolutionAvailable() {
|
|||||||
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
str="Waiting until DNS resolution is available..."
|
str="Waiting up to 120 seconds for DNS resolution..."
|
||||||
echo -ne " ${INFO} ${str}"
|
echo -ne " ${INFO} ${str}"
|
||||||
until getent hosts github.com &> /dev/null; do
|
|
||||||
# Append one dot for each second waiting
|
# Default DNS timeout is two seconds, plus 1 second for each dot > 120 seconds
|
||||||
str="${str}."
|
for ((i = 0; i < 40; i++)); do
|
||||||
echo -ne " ${OVER} ${INFO} ${str}"
|
if getent hosts github.com &> /dev/null; then
|
||||||
sleep 1
|
# If we reach this point, DNS resolution is available
|
||||||
|
echo -e "${OVER} ${TICK} DNS resolution is available"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# Append one dot for each second waiting
|
||||||
|
echo -ne "."
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# If we reach this point, DNS resolution is available
|
# DNS resolution is still unavailable after 120 seconds
|
||||||
echo -e "${OVER} ${TICK} DNS resolution is available"
|
return 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function: try_restore_backup
|
# Function: try_restore_backup
|
||||||
@ -417,7 +424,7 @@ gravity_DownloadBlocklists() {
|
|||||||
echo -e " ${INFO} Storing gravity database in ${COL_BOLD}${gravityDBfile}${COL_NC}"
|
echo -e " ${INFO} Storing gravity database in ${COL_BOLD}${gravityDBfile}${COL_NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local url domain str target compression adlist_type directory success
|
local url domain str compression adlist_type directory success
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Prepare new gravity database
|
# Prepare new gravity database
|
||||||
@ -566,7 +573,7 @@ gravity_DownloadBlocklists() {
|
|||||||
if [[ "${check_url}" =~ ${regex} ]]; then
|
if [[ "${check_url}" =~ ${regex} ]]; then
|
||||||
echo -e " ${CROSS} Invalid Target"
|
echo -e " ${CROSS} Invalid Target"
|
||||||
else
|
else
|
||||||
timeit gravity_DownloadBlocklistFromUrl "${url}" "${sourceIDs[$i]}" "${saveLocation}" "${target}" "${compression}" "${adlist_type}" "${domain}"
|
timeit gravity_DownloadBlocklistFromUrl "${url}" "${sourceIDs[$i]}" "${saveLocation}" "${compression}" "${adlist_type}" "${domain}"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
@ -600,7 +607,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}" adlistID="${2}" saveLocation="${3}" target="${4}" compression="${5}" gravity_type="${6}" domain="${7}"
|
local url="${1}" adlistID="${2}" saveLocation="${3}" compression="${4}" gravity_type="${5}" domain="${6}"
|
||||||
local listCurlBuffer str httpCode success="" ip customUpstreamResolver=""
|
local listCurlBuffer str httpCode success="" ip customUpstreamResolver=""
|
||||||
local file_path permissions ip_addr port blocked=false download=true
|
local file_path permissions ip_addr port blocked=false download=true
|
||||||
# modifiedOptions is an array to store all the options used to check if the adlist has been changed upstream
|
# modifiedOptions is an array to store all the options used to check if the adlist has been changed upstream
|
||||||
@ -1081,6 +1088,12 @@ for var in "$@"; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Check if DNS is available, no need to do any database manipulation if we're not able to download adlists
|
||||||
|
if ! timeit gravity_CheckDNSResolutionAvailable; then
|
||||||
|
echo -e " ${CROSS} No DNS resolution available. Please contact support."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove OLD (backup) gravity file, if it exists
|
# Remove OLD (backup) gravity file, if it exists
|
||||||
if [[ -f "${gravityOLDfile}" ]]; then
|
if [[ -f "${gravityOLDfile}" ]]; then
|
||||||
rm "${gravityOLDfile}"
|
rm "${gravityOLDfile}"
|
||||||
@ -1121,11 +1134,6 @@ if [[ "${forceDelete:-}" == true ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Gravity downloads blocklists next
|
# Gravity downloads blocklists next
|
||||||
if ! timeit gravity_CheckDNSResolutionAvailable; then
|
|
||||||
echo -e " ${CROSS} Can not complete gravity update, no DNS is available. Please contact support."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! gravity_DownloadBlocklists; then
|
if ! gravity_DownloadBlocklists; then
|
||||||
echo -e " ${CROSS} Unable to create gravity database. Please try again later. If the problem persists, please contact support."
|
echo -e " ${CROSS} Unable to create gravity database. Please try again later. If the problem persists, please contact support."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -15,6 +15,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -15,6 +15,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -12,6 +12,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -12,6 +12,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -13,6 +13,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -13,6 +13,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
17
test/_fedora_42.Dockerfile
Normal file
17
test/_fedora_42.Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM fedora:42
|
||||||
|
RUN dnf install -y git initscripts
|
||||||
|
|
||||||
|
ENV GITDIR=/etc/.pihole
|
||||||
|
ENV SCRIPTDIR=/opt/pihole
|
||||||
|
|
||||||
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
|
ADD . $GITDIR
|
||||||
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
|
RUN true && \
|
||||||
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
|
ENV SKIP_INSTALL=true
|
||||||
|
|
||||||
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
@ -12,6 +12,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -13,6 +13,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -13,6 +13,5 @@ RUN true && \
|
|||||||
chmod +x $SCRIPTDIR/*
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
ENV SKIP_INSTALL=true
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
||||||
|
@ -245,6 +245,7 @@ def test_FTL_detect_no_errors(host, arch, detected_string, supported):
|
|||||||
{
|
{
|
||||||
"-A /bin/sh": ("Tag_CPU_arch: " + arch, "0"),
|
"-A /bin/sh": ("Tag_CPU_arch: " + arch, "0"),
|
||||||
"-A /usr/bin/sh": ("Tag_CPU_arch: " + arch, "0"),
|
"-A /usr/bin/sh": ("Tag_CPU_arch: " + arch, "0"),
|
||||||
|
"-A /usr/sbin/sh": ("Tag_CPU_arch: " + arch, "0"),
|
||||||
},
|
},
|
||||||
host,
|
host,
|
||||||
)
|
)
|
||||||
@ -465,50 +466,6 @@ def test_validate_ip(host):
|
|||||||
test_address("0.0.0.0#00001", False)
|
test_address("0.0.0.0#00001", False)
|
||||||
|
|
||||||
|
|
||||||
def test_os_check_fails(host):
|
|
||||||
"""Confirms install fails on unsupported OS"""
|
|
||||||
host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
package_manager_detect
|
|
||||||
build_dependency_package
|
|
||||||
install_dependent_packages
|
|
||||||
cat <<EOT > /etc/os-release
|
|
||||||
ID=UnsupportedOS
|
|
||||||
VERSION_ID="2"
|
|
||||||
EOT
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
detectOS = host.run(
|
|
||||||
"""t
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
os_check
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "Unsupported OS detected: UnsupportedOS"
|
|
||||||
assert expected_stdout in detectOS.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_os_check_passes(host):
|
|
||||||
"""Confirms OS meets the requirements"""
|
|
||||||
host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
package_manager_detect
|
|
||||||
build_dependency_package
|
|
||||||
install_dependent_packages
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
detectOS = host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
os_check
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "Supported OS detected"
|
|
||||||
assert expected_stdout in detectOS.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_package_manager_has_pihole_deps(host):
|
def test_package_manager_has_pihole_deps(host):
|
||||||
"""Confirms OS is able to install the required packages for Pi-hole"""
|
"""Confirms OS is able to install the required packages for Pi-hole"""
|
||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
mock_command("dialog", {"*": ("", "0")}, host)
|
||||||
|
10
test/tox.fedora_42.ini
Normal file
10
test/tox.fedora_42.ini
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[tox]
|
||||||
|
envlist = py3
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
allowlist_externals = docker
|
||||||
|
deps = -rrequirements.txt
|
||||||
|
setenv =
|
||||||
|
COLUMNS=120
|
||||||
|
commands = docker buildx build --load --progress plain -f _fedora_42.Dockerfile -t pytest_pihole:test_container ../
|
||||||
|
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py ./test_centos_fedora_common_support.py
|
Loading…
x
Reference in New Issue
Block a user