mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-08 15:10:45 +02:00
Fix Telegram action deleting the snap, improved string quoting
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Source your custom motion configurations
|
||||
. /system/sdcard/config/motion.conf
|
||||
. /system/sdcard/scripts/common_functions.sh
|
||||
. ../config/motion.conf
|
||||
. common_functions.sh
|
||||
|
||||
# Turn on the amber led
|
||||
if [ "$motion_trigger_led" = true ] ; then
|
||||
@@ -13,21 +13,21 @@ fi
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
filename=$(date +%d-%m-%Y_%H.%M.%S).jpg
|
||||
if [ ! -d "$save_dir" ]; then
|
||||
mkdir -p $save_dir
|
||||
mkdir -p "$save_dir"
|
||||
fi
|
||||
# Limit the number of snapshots
|
||||
if [[ $(ls $save_dir | wc -l) -ge $max_snapshots ]]; then
|
||||
rm -f "$save_dir/$(ls -l $save_dir | awk 'NR==2{print $9}')"
|
||||
if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then
|
||||
rm -f "$save_dir/$(ls -l "$save_dir" | awk 'NR==2{print $9}')"
|
||||
fi
|
||||
/system/sdcard/bin/getimage > $save_dir/$filename &
|
||||
/system/sdcard/bin/getimage > "$save_dir/$filename" &
|
||||
fi
|
||||
|
||||
# Publish a mqtt message
|
||||
if [ "$publish_mqtt_message" = true ] ; then
|
||||
. /system/sdcard/config/mqtt.conf
|
||||
. ../config/mqtt.conf
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "ON"
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f $save_dir/$filename
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f "$save_dir/$filename"
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -39,14 +39,18 @@ fi
|
||||
|
||||
# Send a telegram message
|
||||
if [ "$send_telegram" = true ]; then
|
||||
/system/sdcard/bin/getimage > $save_dir/$filename
|
||||
/system/sdcard/bin/telegram p $save_dir/$filename
|
||||
rm $save_dir/$filename
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
/system/sdcard/bin/telegram p "$save_dir/$filename"
|
||||
else
|
||||
/system/sdcard/bin/getimage > "telegram_image.jpg"
|
||||
+ /system/sdcard/bin/telegram p "telegram_image.jpg"
|
||||
+ rm "telegram_image.jpg"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run any user scripts.
|
||||
for i in /system/sdcard/config/userscripts/motiondetection/*; do
|
||||
if [ -x $i ]; then
|
||||
if [ -x "$i" ]; then
|
||||
echo "Running: $i on"
|
||||
$i on
|
||||
fi
|
||||
|
Reference in New Issue
Block a user