From 40da3a40ec649cc8d0c0edb614755eb1a60c2a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 28 Apr 2025 21:03:08 +0200 Subject: [PATCH 1/4] Remove os_check from install script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 172 ----------------------------- 1 file changed, 172 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index af03d93d..fda294b4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -227,176 +227,6 @@ is_command() { 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 package_manager_detect() { @@ -2369,8 +2199,6 @@ main() { # Install Pi-hole dependencies 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 # this early on as FTL is a hard dependency for Pi-hole From d9f4ee7aaa4094536fee7b29b497814638395f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 28 Apr 2025 21:04:08 +0200 Subject: [PATCH 2/4] Remove os_check from update script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/update.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 08a50be1..51c1b1a1 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -112,8 +112,6 @@ main() { web_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) package_manager_detect From 54c8dd3d77b8460adea76e72999509eca3ac2374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 28 Apr 2025 21:06:05 +0200 Subject: [PATCH 3/4] Remove os_check from tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- test/_centos_10.Dockerfile | 1 - test/_centos_9.Dockerfile | 1 - test/_debian_11.Dockerfile | 1 - test/_debian_12.Dockerfile | 1 - test/_fedora_40.Dockerfile | 1 - test/_fedora_41.Dockerfile | 1 - test/_ubuntu_20.Dockerfile | 1 - test/_ubuntu_22.Dockerfile | 1 - test/_ubuntu_24.Dockerfile | 1 - test/test_any_automated_install.py | 44 ------------------------------ 10 files changed, 53 deletions(-) diff --git a/test/_centos_10.Dockerfile b/test/_centos_10.Dockerfile index ca439e1b..78a89789 100644 --- a/test/_centos_10.Dockerfile +++ b/test/_centos_10.Dockerfile @@ -15,6 +15,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_centos_9.Dockerfile b/test/_centos_9.Dockerfile index a5e7cf0b..73f53fa5 100644 --- a/test/_centos_9.Dockerfile +++ b/test/_centos_9.Dockerfile @@ -15,6 +15,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_debian_11.Dockerfile b/test/_debian_11.Dockerfile index b8107244..2389063c 100644 --- a/test/_debian_11.Dockerfile +++ b/test/_debian_11.Dockerfile @@ -12,6 +12,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_debian_12.Dockerfile b/test/_debian_12.Dockerfile index 7446711a..a6c5f1ed 100644 --- a/test/_debian_12.Dockerfile +++ b/test/_debian_12.Dockerfile @@ -12,6 +12,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_fedora_40.Dockerfile b/test/_fedora_40.Dockerfile index 20102a10..43913895 100644 --- a/test/_fedora_40.Dockerfile +++ b/test/_fedora_40.Dockerfile @@ -13,6 +13,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_fedora_41.Dockerfile b/test/_fedora_41.Dockerfile index bf5fe5d5..c03371a5 100644 --- a/test/_fedora_41.Dockerfile +++ b/test/_fedora_41.Dockerfile @@ -13,6 +13,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_ubuntu_20.Dockerfile b/test/_ubuntu_20.Dockerfile index 75c12673..5b8deb5d 100644 --- a/test/_ubuntu_20.Dockerfile +++ b/test/_ubuntu_20.Dockerfile @@ -12,6 +12,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_ubuntu_22.Dockerfile b/test/_ubuntu_22.Dockerfile index 9206a46a..c3be89e1 100644 --- a/test/_ubuntu_22.Dockerfile +++ b/test/_ubuntu_22.Dockerfile @@ -13,6 +13,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/_ubuntu_24.Dockerfile b/test/_ubuntu_24.Dockerfile index 4cab43de..cf57c2aa 100644 --- a/test/_ubuntu_24.Dockerfile +++ b/test/_ubuntu_24.Dockerfile @@ -13,6 +13,5 @@ RUN true && \ chmod +x $SCRIPTDIR/* 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 && \ diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index 5fa0f065..e72b4779 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -465,50 +465,6 @@ def test_validate_ip(host): 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 < /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): """Confirms OS is able to install the required packages for Pi-hole""" mock_command("dialog", {"*": ("", "0")}, host) From 5355e9e08491e6167ecdb40b172780527b340a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 28 Apr 2025 21:10:36 +0200 Subject: [PATCH 4/4] Remove os_check from debug script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/piholeDebug.sh | 94 ++++----------------------------- 1 file changed, 10 insertions(+), 84 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 70c0ffe2..741ff2f4 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -296,91 +296,12 @@ check_component_versions() { 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() { # 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 detected_os + local detected_version + # Display the current test that is running 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 ls /etc/*release 1> /dev/null 2>&1; then - # display the attributes to the user from the function made earlier - os_check + # display the attributes to the user + + 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 # 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})"