generated from me/template-mit
Fix alert not popping up, SUNSET_TIME is not used in API route.
This commit is contained in:
1 parent
949e1baacd
commit
28c0f61696
1 file changed
+4
-5
+4
-5
@@ -165,8 +165,7 @@ while true; do
|
||||
CURRENT_TIME=$(date +%s)
|
||||
|
||||
# Check if we need to fetch new sunset time for a new day.
|
||||
if [[ "$LAST_DATE" != "$TODAY" \
|
||||
|| "$SUNSET_EPOCH" == 0 || -z "$SUNSET_TIME" ]]
|
||||
if [[ "$LAST_DATE" != "$TODAY" || "$SUNSET_EPOCH" == 0 ]]
|
||||
then
|
||||
LAST_DATE="$TODAY"
|
||||
|
||||
@@ -184,7 +183,7 @@ while true; do
|
||||
continue
|
||||
}
|
||||
|
||||
if [[ -z "$SUNSET_TIME" ]]; then
|
||||
if [[ "$SUNSET_EPOCH" == 0 ]]; then
|
||||
echo "ERROR: Sunset time is still null. Retrying in 5 minutes." >&2
|
||||
sleep 300
|
||||
continue
|
||||
@@ -208,11 +207,11 @@ while true; do
|
||||
MIDNIGHT=$(date -d "${TODAY} +1 day" +%s)
|
||||
|
||||
# Alert while current time is within the window (from window start until midnight).
|
||||
if [[ -n "$SUNSET_TIME" && "$SUNSET_EPOCH" -ge 0 \
|
||||
if [[ "$SUNSET_EPOCH" -ge 0 \
|
||||
&& "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" \
|
||||
&& "$CURRENT_TIME" -lt "$MIDNIGHT" ]]
|
||||
then
|
||||
echo "Alert time has been reached for $SUNSET_TIME, show message."
|
||||
echo "Alert time has been reached, show message."
|
||||
show_alert
|
||||
echo "Alert has been dismissed, sleeping for 5 minutes."
|
||||
sleep 290
|
||||
|
||||
Reference in new issue
Block a user