improve return codes
This commit is contained in:
parent
bbe268059b
commit
0a69def281
1 changed files with 21 additions and 1 deletions
|
@ -200,6 +200,10 @@ if [ -n "${file}" ]; then
|
||||||
if [ -n "${move_to}" ]; then
|
if [ -n "${move_to}" ]; then
|
||||||
message "Moving file '${file}' to '${move_to}'..."
|
message "Moving file '${file}' to '${move_to}'..."
|
||||||
scp -P "${move_to_port}" "${file}" "${move_to}/" && rm -rf "${file}"
|
scp -P "${move_to_port}" "${file}" "${move_to}/" && rm -rf "${file}"
|
||||||
|
return_code=$?
|
||||||
|
if [ $return_code != 0 ]; then
|
||||||
|
message "Error ${return_code} moving file."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -208,23 +212,39 @@ if [ "${signal_alert}" == "true" ]; then
|
||||||
message "Sending to Signal destination '${signal_destination}'..."
|
message "Sending to Signal destination '${signal_destination}'..."
|
||||||
/var/lib/from_repos/signal_scripts/send_msg.sh --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}"
|
--message "Clip termino en camara '${camera_name}' (${motion_host}). Evento: #${event}. File: ${file_uri}"
|
||||||
|
return_code=$?
|
||||||
|
if [ $return_code != 0 ]; then
|
||||||
|
message "Error ${return_code} sending to signal."
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${mail_alert}" == "true" ]; then
|
if [ "${mail_alert}" == "true" ]; then
|
||||||
message "Sending email to '${email_destination}'..."
|
message "Sending email to '${email_destination}'..."
|
||||||
echo "${data}" | jq '.' | mail -s "Motion event '${event_type}' on host '${motion_host}' camera '${camera_name}'" "${email_destination}"
|
echo "${data}" | jq '.' | mail -s "Motion event '${event_type}' on host '${motion_host}' camera '${camera_name}'" "${email_destination}"
|
||||||
|
return_code=$?
|
||||||
|
if [ $return_code != 0 ]; then
|
||||||
|
message "Error ${return_code} sending email"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${ntfy_server}" ]; then
|
if [ -n "${ntfy_server}" ]; then
|
||||||
ntfy_password="$(cat "${ntfy_password_file}")"
|
ntfy_password="$(cat "${ntfy_password_file}")"
|
||||||
ntfy_data="${data}, \"topic\": \"motion_detection\""
|
ntfy_data="${data}, \"topic\": \"motion_detection\""
|
||||||
|
message "Seding to ntfy server '${ntfy_server}' ..."
|
||||||
curl -s "${ntfy_server}" -d "${ntfy_data}"
|
curl -s "${ntfy_server}" -d "${ntfy_data}"
|
||||||
|
return_code=$?
|
||||||
|
if [ $return_code != 0 ]; then
|
||||||
|
message "Error ${return_code} publishing in ntfy server '${ntfy}'"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
message "Sending Home Assistant event ..."
|
message "Sending Home Assistant event ..."
|
||||||
result=$(curl -s -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}")
|
result=$(curl -s -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}")
|
||||||
return_code=$?
|
return_code=$?
|
||||||
message "Return code: ${return_code}. Result: ${result}"
|
if [ $return_code != 0 ]; then
|
||||||
|
message "Error ${return_code} sending to Home Assistant '${ha_url}'"
|
||||||
|
fi
|
||||||
|
|
||||||
if ${remove_picture}; then
|
if ${remove_picture}; then
|
||||||
file_dirname=$(dirname "${file}")
|
file_dirname=$(dirname "${file}")
|
||||||
|
|
Loading…
Reference in a new issue