Files
shell-scripts/crons/thermal-alert.sh
T
andrew 0a21caf6c2 rebuilt thermal, now works with all zones available.
discord will now work without hook specified.
2023-09-27 14:45:57 -04:00

33 lines
963 B
Bash
Executable File

#!/bin/bash
# degrees in Celsius which we regard as too high, defaults to config
alertLevel="$1"
# load in defaults from config
scriptRoot="$(dirname "$0")/.."
configFile="$scriptRoot/config.sh"
if [[ -f "$configFile" ]]; then
source "$configFile"
if [[ -z "$alertLevel" ]]; then
alertLevel="$THERMAL_ALERT"
fi
fi
# get current status
thermal=$("$scriptRoot/thermal.sh" "$alertLevel")
alert="$?"
if [[ "0" -ne "$alert" ]]; then
# if currently in an alert status
alertLevelF=`echo "scale=1 ; $alertLevel * 9 / 5 + 32" | bc -l`
"$scriptRoot/discord.sh" "$thermal, above threshold $alertLevel C ($alertLevelF F)"
touch "$HOME/.thermal.alert"
elif [[ -f "$HOME/.thermal.alert" ]]; then
# if previously in an alert status
alertLevelF=`echo "scale=1 ; $alertLevel * 9 / 5 + 32" | bc -l`
"$scriptRoot/discord.sh" "$thermal, previously above threshold $alertLevel C ($alertLevelF F)"
rm "$HOME/.thermal.alert"
fi