Merge pull request #3620 from yubiuser/tweak/dig_supportedOS

Report and exit if dig supportedOS returns nothing
This commit is contained in:
Adam Warner 2020-07-30 17:00:01 +01:00 committed by GitHub
commit 48820d181c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -190,24 +190,29 @@ os_check() {
IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net | tr -d '"') IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} @ns1.pi-hole.net | tr -d '"')
for i in "${supportedOS[@]}" if [ ${#supportedOS[@]} -eq 0 ]; then
do printf " %b %bRetrieval of supported OS failed. Please contact support. %b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
os_part=$(echo "$i" | cut -d '=' -f1) exit 1
versions_part=$(echo "$i" | cut -d '=' -f2-) else
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 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
fi
done
break break
fi fi
done done
break fi
fi
done
if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then
display_warning=false display_warning=false