vigil

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

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

Refactor alert script

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

diff --git a/scripts/alert b/scripts/alert @@ -2,7 +2,24 @@ 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}"