From fbb724b12ebfab0dbf89544cd2453a28f6ae29ce Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 20 Mar 2023 23:00:15 +0200 Subject: [PATCH] attach files --- files/process_motion_event.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/files/process_motion_event.sh b/files/process_motion_event.sh index 63c620d..76aa337 100644 --- a/files/process_motion_event.sh +++ b/files/process_motion_event.sh @@ -230,12 +230,21 @@ if [ "${mail_alert}" == "true" ]; then fi if [ -n "${ntfy_server}" ]; then - ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}" # , \"email\": \"${email_destination}\" }" + if [ -n "${file}" ]; then + ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\", \"filename\": \"${file}\" }" + else + ntfy_data="{ \"topic\": \"motion_detection\", \"message\": \"Event ${event_type} on host ${motion_host} camera ${camera_name}\"}" + fi ntfy_password="$(cat "${ntfy_password_file}")" message "Sending event to ntfy server '${ntfy_server}/motion_detection' ..." message "Data: ${ntfy_data}" - curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" - return_code=$? + if [ -n "${file}" ]; then + curl -s "${ntfy_server}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" + return_code=$? + else + curl -s "${ntfy_server}" -T "${file}" -u "${ntfy_user}:${ntfy_password}" -d "${ntfy_data}" + return_code=$? + fi if [ $return_code != 0 ]; then message "Error ${return_code} publishing in ntfy server '${ntfy}'" fi