From ea22774d163c1fbf235faa6ef1e911bc9e1ab167 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 21 Jul 2020 18:47:13 +0100 Subject: [PATCH 1/5] Wrap entire function in the check for the ENVVAR Signed-off-by: Adam Warner --- automated install/basic-install.sh | 89 +++++++++++++++--------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2bbd4d10..ea4326d5 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -175,58 +175,61 @@ is_command() { } 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_pretty detected_os detected_version display_warning - remote_os_domain="versions.pi-hole.net" - valid_os=false - valid_version=false - display_warning=true + 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 detected_os_pretty detected_os detected_version display_warning + remote_os_domain="versions.pi-hole.net" + valid_os=false + valid_version=false + display_warning=true - detected_os_pretty=$(cat /etc/*release | grep PRETTY_NAME | cut -d '=' -f2- | tr -d '"') - detected_os="${detected_os_pretty%% *}" - detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"') + detected_os_pretty=$(cat /etc/*release | grep PRETTY_NAME | cut -d '=' -f2- | tr -d '"') + detected_os="${detected_os_pretty%% *}" + detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"') - IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} | tr -d '"') + IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} | tr -d '"') - for i in "${supportedOS[@]}" - do - os_part=$(echo "$i" | cut -d '=' -f1) - versions_part=$(echo "$i" | cut -d '=' -f2-) + for i in "${supportedOS[@]}" + do + os_part=$(echo "$i" | cut -d '=' -f1) + versions_part=$(echo "$i" | cut -d '=' -f2-) - if [[ "${detected_os}" =~ ${os_part} ]]; then - valid_os=true - IFS="," read -r -a supportedVer <<<"${versions_part}" - for x in "${supportedVer[@]}" - do - if [[ "${detected_version}" =~ $x ]];then - valid_version=true - break + if [[ "${detected_os}" =~ ${os_part} ]]; then + valid_os=true + IFS="," read -r -a supportedVer <<<"${versions_part}" + for x in "${supportedVer[@]}" + do + if [[ "${detected_version}" =~ $x ]];then + valid_version=true + break + fi + done + break fi - done - break + done + + if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then + display_warning=false fi - done - if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then - display_warning=false - fi + if [ "$display_warning" = true ]; then + printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" + printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n" + printf "\\n" + printf " This check can be skipped by setting the environment variable %bPIHOLE_SKIP_OS_CHECK%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}" + printf " e.g: 'sudo PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | bash'\\n" + printf " or 'sudo PIHOLE_SKIP_OS_CHECK=true pihole -up'\\n" + printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\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 " https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/\\n" + exit 1 - if [ "$display_warning" = true ] && [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then - printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" - printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n" - printf "\\n" - printf " This check can be skipped by setting the environment variable %bPIHOLE_SKIP_OS_CHECK%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}" - printf " e.g: 'sudo PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | bash'\\n" - printf " or 'sudo PIHOLE_SKIP_OS_CHECK=true pihole -up'\\n" - printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\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 " https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/\\n" - exit 1 - elif [ "$display_warning" = true ] && [ "$PIHOLE_SKIP_OS_CHECK" = true ]; then - printf " %b %bUnsupported OS detected%b. PIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}" + else + printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}" + fi else - printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}" + printf " %b %bPIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}" fi } From 510b64673664f0e39abefb2a40b13f7a506c1dbe Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 22 Jul 2020 22:29:38 +0100 Subject: [PATCH 2/5] change up the verbiage with something that works (tested) Signed-off-by: Adam Warner --- automated install/basic-install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ea4326d5..660862bd 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -217,10 +217,13 @@ os_check() { printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n" printf "\\n" - printf " This check can be skipped by setting the environment variable %bPIHOLE_SKIP_OS_CHECK%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}" - printf " e.g: 'sudo PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | bash'\\n" - printf " or 'sudo PIHOLE_SKIP_OS_CHECK=true pihole -up'\\n" - printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\n" + printf " e.g: If you are seeing this message on a fresh install, you can run:" + printf " 'PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | sudo -E bash'\\n" + printf "\\n" + printf " If you are seeing this message after having run pihole -up:\\n" + printf " 'PIHOLE_SKIP_OS_CHECK=true sudo -E pihole -r'\\n" + printf " (In this case, your previous run of pihole -up will have already updated the local repository)\\n" + printf "\\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 " https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/\\n" exit 1 From 98dc51869e4acdd44053175a02a7ff25e4b90d51 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 22 Jul 2020 22:30:51 +0100 Subject: [PATCH 3/5] accidentally missed \\n Signed-off-by: Adam Warner --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 660862bd..2bf63882 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -217,7 +217,7 @@ os_check() { printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n" printf "\\n" - printf " e.g: If you are seeing this message on a fresh install, you can run:" + printf " e.g: If you are seeing this message on a fresh install, you can run:\\n" printf " 'PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | sudo -E bash'\\n" printf "\\n" printf " If you are seeing this message after having run pihole -up:\\n" From ddb36c013d82aafa28ad8c590fff9f1fd3e170e6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 22 Jul 2020 22:39:03 +0100 Subject: [PATCH 4/5] it helps if the echo goes variable set goes in the right place Signed-off-by: Adam Warner --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 2bf63882..188e889e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -218,7 +218,7 @@ os_check() { printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n" printf "\\n" printf " e.g: If you are seeing this message on a fresh install, you can run:\\n" - printf " 'PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | sudo -E bash'\\n" + printf " 'curl -sSL https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true sudo -E bash'\\n" printf "\\n" printf " If you are seeing this message after having run pihole -up:\\n" printf " 'PIHOLE_SKIP_OS_CHECK=true sudo -E pihole -r'\\n" From 0ff32c3629220f386a45c14d8982aaaf128aa47f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 27 Jul 2020 17:44:22 +0100 Subject: [PATCH 5/5] Use ns1.pi-hole.net to resolve versions.pi-hole.net so that we do not see DNS cookie issues Co-Authored-by: Dan Schaper Signed-off-by: Adam Warner --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 188e889e..1bbfd7c4 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -188,7 +188,7 @@ os_check() { detected_os="${detected_os_pretty%% *}" detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"') - IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} | tr -d '"') + IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net | tr -d '"') for i in "${supportedOS[@]}" do