vigil

Security camera system built on motion and yolov7.
Log | Files | Refs

commit 7501d00d76df45911be409bd02aedff305c3bd2f
parent 0fa91246dad5bf0cf7d7e85768cae821a32132e4
Author: dwrz <dwrz@dwrz.net>
Date:   Thu,  2 Feb 2023 15:39:47 +0000

Refactor alert script

Diffstat:
Mscripts/alert | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/scripts/alert b/scripts/alert @@ -1,8 +1,27 @@ #!/usr/bin/env bash +# Devices to check -- if populated and up, no notifications are sent. +readonly DEVICES=() 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 +} + main() { + # If devices are present, don't notify. + if (( "${#DEVICES[@]}" )); then + if check_devices; then + exit 0 + fi + fi + echo "${HOSTNAME}: motion detected at $(date '+%Y-%m-%dT%H:%M:%S%:z')." | \ mutt -s "${HOSTNAME}: Motion Detected" \ -- "${RECIPIENT}"