From 6ecaeef08eb7bc8eb3922dae68c8f474bb7896e1 Mon Sep 17 00:00:00 2001 From: Dopeyr Date: Fri, 8 Jun 2018 01:36:03 +0100 Subject: [PATCH] Allow custom scripts to run on motion detection on/off (#432) * Allow custom scripts to run on motion detection on/off * Custom user scripts should be ignored --- .gitignore | 1 + firmware_mod/config/userscripts/motiondetection/.gitkeep | 0 firmware_mod/scripts/detectionOff.sh | 8 ++++++++ firmware_mod/scripts/detectionOn.sh | 8 ++++++++ 4 files changed, 17 insertions(+) create mode 100644 firmware_mod/config/userscripts/motiondetection/.gitkeep diff --git a/.gitignore b/.gitignore index 64a585a..feda6cd 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,5 @@ firmware_mod/config/rtspserver.conf firmware_mod/config/ntp_srv.conf firmware_mod/config/lighttpd.user firmware_mod/config/lighttpd.pem +firmware_mod/config/userscripts/*/* firmware_mod/root/.ssh/* diff --git a/firmware_mod/config/userscripts/motiondetection/.gitkeep b/firmware_mod/config/userscripts/motiondetection/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/firmware_mod/scripts/detectionOff.sh b/firmware_mod/scripts/detectionOff.sh index 0cae4bc..46d6007 100755 --- a/firmware_mod/scripts/detectionOff.sh +++ b/firmware_mod/scripts/detectionOff.sh @@ -14,3 +14,11 @@ if [ "$publish_mqtt_message" = true ] ; then . /system/sdcard/config/mqtt.conf /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "OFF" fi + +# Run any user scripts. +if [ -f /system/sdcard/config/userscripts/motiondetection/* ]; then + for i in /system/sdcard/config/userscripts/motiondetection/*; do + echo "Running: $i off" + $i off + done +fi diff --git a/firmware_mod/scripts/detectionOn.sh b/firmware_mod/scripts/detectionOn.sh index 27cef10..cdd2b83 100755 --- a/firmware_mod/scripts/detectionOn.sh +++ b/firmware_mod/scripts/detectionOn.sh @@ -37,3 +37,11 @@ fi if [ "$sendemail" = true ] ; then /system/sdcard/scripts/sendPictureMail.sh& fi + +# Run any user scripts. +if [ -f /system/sdcard/config/userscripts/motiondetection/* ]; then + for i in /system/sdcard/config/userscripts/motiondetection/*; do + echo "Running: $i on" + $i on + done +fi