Add option to remove pictures
This commit is contained in:
parent
d3a4e70db0
commit
00284c88ea
1 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
||||||
#shellcheck disable=SC1091
|
#shellcheck disable=SC1091
|
||||||
test -e /var/lib/from_repos/scripts/shared_functions.sh && source /var/lib/from_repos/scripts/shared_functions.sh
|
test -e /var/lib/from_repos/scripts/shared_functions.sh && source /var/lib/from_repos/scripts/shared_functions.sh
|
||||||
|
|
||||||
|
remove_picture=false
|
||||||
|
|
||||||
data="\"date\": \"$(date +%s)\""
|
data="\"date\": \"$(date +%s)\""
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
|
@ -147,6 +149,10 @@ do
|
||||||
email_destination="${1}"
|
email_destination="${1}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
"--remove-picture"|"-r")
|
||||||
|
shift
|
||||||
|
remove_picture=true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -171,3 +177,9 @@ message "Sending Home Assistant event ..."
|
||||||
result=$(curl -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}")
|
result=$(curl -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}"
|
message "Return code: ${return_code}. Result: ${result}"
|
||||||
|
|
||||||
|
if ${remove_picture}; then
|
||||||
|
file_dirname=$(dirname "${file}")
|
||||||
|
file_dirname_parent=$(dirname "${file_dirname}")
|
||||||
|
find "${file_dirname_parent}" -type f -name \*.jpg -delete
|
||||||
|
fi
|
Loading…
Reference in a new issue