vigil

Security camera system built on motion and yolov7.
git clone git://code.dwrz.net/vigil
Log | Files | Refs

alert (608B)


      1 #!/usr/bin/env bash
      2 
      3 # Devices to check -- if populated and up, no notifications are sent.
      4 readonly DEVICES=()
      5 readonly RECIPIENT="${NOTIFICATION_RECIPIENT}"
      6 
      7 check_devices() {
      8   for device in "${DEVICES[@]}"; do
      9     if ping -c 1 -w 1 "${device}" &> "/dev/null"; then
     10       return 0
     11     fi
     12   done
     13 
     14   return 255
     15 }
     16 
     17 main() {
     18   # If devices are present, don't notify.
     19   if (( "${#DEVICES[@]}" )); then
     20     if check_devices; then
     21       exit 0
     22     fi
     23   fi
     24 
     25   echo "${HOSTNAME}: motion detected at $(date '+%Y-%m-%dT%H:%M:%S%:z')." | \
     26     mutt -s "${HOSTNAME}: Motion Detected" \
     27 	 -- "${RECIPIENT}"
     28 }
     29 
     30 main "$@"