Run shellcheck on all shellscripts

This commit is contained in:
Erik Westrup
2022-02-01 17:15:47 +01:00
parent 79d13a1e64
commit 9b7db6d999
4 changed files with 30 additions and 30 deletions
+7 -7
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# Send email notification from systemd.
# Source: https://serverfault.com/questions/876233/how-to-send-an-email-if-a-systemd-service-is-restarted
# Source: https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO
@@ -15,19 +15,19 @@
# (24 * 60 * 60) / 100 = 864 second
# One option that I used with my old Axis cameras it to use my gmx.com accunt for sending emails instead, as there are (no?) higher limits there.
MIN_WAIT_TIME_S=900
SCRIPT_NAME=$(basename $0)
SCRIPT_NAME=$(basename "$0")
LAST_RUN_FILE="/tmp/${SCRIPT_NAME}_last_run.txt"
last_touch() {
stat -c %Y $1
stat -c %Y "$1"
}
waited_long_enough() {
retval=1
if [ -e $LAST_RUN_FILE ]; then
if [ -e "$LAST_RUN_FILE" ]; then
now=$(date +%s)
last=$(last_touch $LAST_RUN_FILE)
wait_s=$(expr $now - $last)
last=$(last_touch "$LAST_RUN_FILE")
wait_s=$((now - last))
if [ "$wait_s" -gt "$MIN_WAIT_TIME_S" ]; then
retval=0
fi
@@ -35,7 +35,7 @@ waited_long_enough() {
retval=0
fi
[ $retval -eq 0 ] && touch $LAST_RUN_FILE
[ $retval -eq 0 ] && touch "$LAST_RUN_FILE"
return $retval
}