mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #3596 from pi-hole/tweak/wherecheck
Wrap entire function in the check for the ENVVAR, add `ns1.pi-hole.net` to `dig` check.
This commit is contained in:
commit
dffb58ae8f
1 changed files with 49 additions and 43 deletions
|
@ -175,58 +175,64 @@ is_command() {
|
||||||
}
|
}
|
||||||
|
|
||||||
os_check() {
|
os_check() {
|
||||||
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
|
||||||
# and determines whether or not the script is running on one of those systems
|
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
||||||
local remote_os_domain valid_os valid_version detected_os_pretty detected_os detected_version display_warning
|
# and determines whether or not the script is running on one of those systems
|
||||||
remote_os_domain="versions.pi-hole.net"
|
local remote_os_domain valid_os valid_version detected_os_pretty detected_os detected_version display_warning
|
||||||
valid_os=false
|
remote_os_domain="versions.pi-hole.net"
|
||||||
valid_version=false
|
valid_os=false
|
||||||
display_warning=true
|
valid_version=false
|
||||||
|
display_warning=true
|
||||||
|
|
||||||
detected_os_pretty=$(cat /etc/*release | grep PRETTY_NAME | 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_os="${detected_os_pretty%% *}"
|
||||||
detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"')
|
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[@]}"
|
for i in "${supportedOS[@]}"
|
||||||
do
|
do
|
||||||
os_part=$(echo "$i" | cut -d '=' -f1)
|
os_part=$(echo "$i" | cut -d '=' -f1)
|
||||||
versions_part=$(echo "$i" | cut -d '=' -f2-)
|
versions_part=$(echo "$i" | cut -d '=' -f2-)
|
||||||
|
|
||||||
if [[ "${detected_os}" =~ ${os_part} ]]; then
|
if [[ "${detected_os}" =~ ${os_part} ]]; then
|
||||||
valid_os=true
|
valid_os=true
|
||||||
IFS="," read -r -a supportedVer <<<"${versions_part}"
|
IFS="," read -r -a supportedVer <<<"${versions_part}"
|
||||||
for x in "${supportedVer[@]}"
|
for x in "${supportedVer[@]}"
|
||||||
do
|
do
|
||||||
if [[ "${detected_version}" =~ $x ]];then
|
if [[ "${detected_version}" =~ $x ]];then
|
||||||
valid_version=true
|
valid_version=true
|
||||||
break
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
break
|
|
||||||
|
if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then
|
||||||
|
display_warning=false
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then
|
if [ "$display_warning" = true ]; then
|
||||||
display_warning=false
|
printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
fi
|
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 " '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"
|
||||||
|
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
|
||||||
|
|
||||||
if [ "$display_warning" = true ] && [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
|
else
|
||||||
printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
|
printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}"
|
||||||
printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n"
|
fi
|
||||||
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
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue