Refactor temperature check and error handling

- Refactored code to improve readability and maintainability
- Added error handling for when Temper USB is not found
- Updated variable names for clarity
This commit is contained in:
Jeroen De Meerleer 2023-08-02 16:13:58 +02:00
parent 27313aec76
commit 2502f8c817
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -89,7 +89,13 @@ script_name=$(basename "${0}")
script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
GetOptions "$@"
val=$(temper --json | jq '.[0]."internal temperature"' | bc -l)
json=$(temper --json)
if [[ ${json} == '[]' ]]; then
echo "MEMORY UNKNOWN - Temper USB not found"
exit 3
fi
val=$(echo ${json} | jq '.[0]."internal temperature"' | bc -l)
if (( $(echo "$val < ${critmin}" | bc -l) )); then
rval=2