Add parameter for signal and mail alerts
This commit is contained in:
parent
d145f87140
commit
6f9d633590
1 changed files with 14 additions and 2 deletions
|
@ -4,6 +4,8 @@
|
|||
test -e /var/lib/from_repos/scripts/shared_functions.sh && source /var/lib/from_repos/scripts/shared_functions.sh
|
||||
|
||||
remove_picture=false
|
||||
signal_alert=false
|
||||
mail_alert=false
|
||||
|
||||
data="\"date\": \"$(date +%s)\""
|
||||
while [ $# -gt 0 ]
|
||||
|
@ -153,6 +155,14 @@ do
|
|||
shift
|
||||
remove_picture=true
|
||||
;;
|
||||
"--signal-alert"|"-S")
|
||||
shift
|
||||
signal_alert=true
|
||||
;;
|
||||
"--mail-alert"|"-m")
|
||||
shift
|
||||
mail_alert=true
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
@ -164,11 +174,13 @@ if [ -n "${file}" ]; then
|
|||
fi
|
||||
|
||||
data="{${data}}"
|
||||
if [ "${event_type}" == "on_movie_end" ]; then
|
||||
if [ "${signal_alert}" ]; then
|
||||
message "Sending to Signal destination '${signal_destination}'..."
|
||||
/var/lib/from_repos/signal_scripts/send_msg.sh --destination "${signal_destination}" \
|
||||
--message "Clip termino en camara '${camera_name}' (${motion_host}). Evento: #${event}. File: ${file_uri}"
|
||||
fi
|
||||
|
||||
if [ "${mail_alert}" ]; then
|
||||
message "Sending email to '${email_destination}'..."
|
||||
echo "${data}" | jq '.' | mail -s "Motion event '${event_type}' on host '${motion_host}' camera '${camera_name}'" "${email_destination}"
|
||||
fi
|
||||
|
@ -182,4 +194,4 @@ if ${remove_picture}; then
|
|||
file_dirname=$(dirname "${file}")
|
||||
file_dirname_parent=$(dirname "${file_dirname}")
|
||||
find "${file_dirname_parent}" -type f -name \*.jpg -delete
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue