commit 3cf8dafda778342a5a614d2e292703af8a4cd0d8
parent 355d69a653d55101b51c31179070643ebfc08125
Author: dwrz <dwrz@dwrz.net>
Date: Fri, 28 Oct 2022 13:27:32 +0000
Add device check to notify script
Diffstat:
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/scripts/notify b/scripts/notify
@@ -3,6 +3,9 @@
# Backblaze B2 Bucket
readonly BUCKET=""
+# Devices to check -- if populated and up, no notifications are sent.
+readonly DEVICES=()
+
# COCO Labels
readonly LABEL_PERSON=0
readonly LABEL_CAT=15
@@ -13,6 +16,16 @@ readonly PROJECT="/tmp/yolov7"
# Notification recipient.
readonly RECIPIENT="${NOTIFICATION_RECIPIENT}"
+check_devices() {
+ for device in "${DEVICES[@]}"; do
+ if ping -c 1 -w 1 "${device}" &> "/dev/null"; then
+ return 0
+ fi
+ done
+
+ return 255
+}
+
detect_objects() {
local filepath="$1"
@@ -57,8 +70,17 @@ delete_outdated() {
}
main() {
- local filepath
+ local filepath="$1"
local name
+ name="$(basename "${filepath}" .jpg)"
+
+ # If devices are present, don't notify.
+ if (( "${#DEVICES[@]}" )); then
+ if check_devices; then
+ delete_outdated "${filepath}" "${name}"
+ exit 0
+ fi
+ fi
detect_objects "${filepath}"