mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 04:30:55 +00:00
Only compare OS versions if dig
was successful
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
parent
1ee922d16c
commit
67f04787d6
@ -394,41 +394,46 @@ os_check() {
|
|||||||
# Extract dig response
|
# Extract dig response
|
||||||
response="${cmdResult%%$'\n'*}"
|
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 [[ "${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
|
|
||||||
|
|
||||||
log_write "${INFO} dig return code: ${digReturnCode}"
|
log_write "${INFO} dig return code: ${digReturnCode}"
|
||||||
log_write "${INFO} dig response: ${response}"
|
log_write "${INFO} dig response: ${response}"
|
||||||
|
|
||||||
if [ "$valid_os" = true ]; then
|
if [ "${response}" -ne 0 ]; then
|
||||||
log_write "${TICK} Distro: ${COL_GREEN}${detected_os^}${COL_NC}"
|
log_write "${CROSS} Distro: ${COL_RED}${detected_os^}${COL_NC}"
|
||||||
|
log_write "${CROSS} Error: ${COL_RED}dig command failed - Unable to check OS${COL_NC}"
|
||||||
if [ "$valid_version" = true ]; then
|
|
||||||
log_write "${TICK} Version: ${COL_GREEN}${detected_version}${COL_NC}"
|
|
||||||
else
|
|
||||||
log_write "${CROSS} Version: ${COL_RED}${detected_version}${COL_NC}"
|
|
||||||
log_write "${CROSS} Error: ${COL_RED}${detected_os^} is supported but version ${detected_version} is currently unsupported (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
log_write "${CROSS} Distro: ${COL_RED}${detected_os^}${COL_NC}"
|
IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"')
|
||||||
log_write "${CROSS} Error: ${COL_RED}${detected_os^} is not a supported distro (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
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 [ "$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}"
|
||||||
|
else
|
||||||
|
log_write "${CROSS} Version: ${COL_RED}${detected_version}${COL_NC}"
|
||||||
|
log_write "${CROSS} Error: ${COL_RED}${detected_os^} is supported but version ${detected_version} is currently unsupported (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_write "${CROSS} Distro: ${COL_RED}${detected_os^}${COL_NC}"
|
||||||
|
log_write "${CROSS} Error: ${COL_RED}${detected_os^} is not a supported distro (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user