Imporving the output from os_check() function

- add red color to dig errors
- reorder some output lines
- add "Distro and version supported" on success

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign 2022-12-06 17:38:38 -03:00
parent b4349b41ce
commit 8c2f56b0e6
No known key found for this signature in database
GPG key ID: AE3C7FC910687F33

View file

@ -394,11 +394,10 @@ os_check() {
# Extract dig response # Extract dig response
response="${cmdResult%%$'\n'*}" response="${cmdResult%%$'\n'*}"
log_write "${INFO} dig return code: ${digReturnCode}"
log_write "${INFO} dig response: ${response}"
if [ "${digReturnCode}" -ne 0 ]; then if [ "${digReturnCode}" -ne 0 ]; then
log_write "${INFO} Distro: ${COL_RED}${detected_os^}${COL_NC}" log_write "${INFO} Distro: ${detected_os^}"
log_write "${CROSS} dig 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}" log_write "${CROSS} Error: ${COL_RED}dig command failed - Unable to check OS${COL_NC}"
else else
IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"') IFS=" " read -r -a supportedOS < <(echo "${response}" | tr -d '"')
@ -421,19 +420,26 @@ os_check() {
fi fi
done done
local finalmsg
if [ "$valid_os" = true ]; then if [ "$valid_os" = true ]; then
log_write "${TICK} Distro: ${COL_GREEN}${detected_os^}${COL_NC}" log_write "${TICK} Distro: ${COL_GREEN}${detected_os^}${COL_NC}"
if [ "$valid_version" = true ]; then if [ "$valid_version" = true ]; then
log_write "${TICK} Version: ${COL_GREEN}${detected_version}${COL_NC}" log_write "${TICK} Version: ${COL_GREEN}${detected_version}${COL_NC}"
finalmsg="${TICK} ${COL_GREEN}Distro and version supported${COL_NC}"
else else
log_write "${CROSS} Version: ${COL_RED}${detected_version}${COL_NC}" 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}" finalmsg="${CROSS} Error: ${COL_RED}${detected_os^} is supported but version ${detected_version} is currently unsupported (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
fi fi
else else
log_write "${CROSS} Distro: ${COL_RED}${detected_os^}${COL_NC}" 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}" finalmsg="${CROSS} Error: ${COL_RED}${detected_os^} is not a supported distro (${FAQ_HARDWARE_REQUIREMENTS})${COL_NC}"
fi fi
# Print dig response and the final check result
log_write "${INFO} dig return code: ${COL_RED}${digReturnCode}${COL_NC}"
log_write "${INFO} dig response: ${response}"
log_write "${finalmsg}"
fi fi
} }