@@ -17,8 +17,9 @@ debug_msg () {
1717send_snapshot () {
1818
1919 # Publish a mqtt message
20- if [ " $publish_mqtt_message " = true -o " $publish_mqtt_snapshot " = true ] ; then
20+ if [ " $publish_mqtt_message " = true ] || [ " $publish_mqtt_snapshot " = true ] ; then
2121 (
22+ # shellcheck source=config/mqtt.conf.dist
2223 . /system/sdcard/config/mqtt.conf
2324
2425 if [ " $publish_mqtt_message " = true ] ; then
@@ -41,12 +42,13 @@ send_snapshot() {
4142 # Send a telegram message
4243 if [ " $send_telegram " = true ]; then
4344 (
45+ # shellcheck source=config/telegram.conf.dist
4446 include /system/sdcard/config/telegram.conf
4547
4648 if [ " $telegram_alert_type " = " text" ] ; then
4749 debug_msg " Send telegram text"
4850 /system/sdcard/bin/telegram m " Motion detected"
49- elif [ " $telegram_alert_type " = " image" -o " $telegram_alert_type " = " video+image" ] ; then
51+ elif [ " $telegram_alert_type " = " image" ] || [ " $telegram_alert_type " = " video+image" ] ; then
5052 debug_msg " Send telegram image"
5153 /system/sdcard/bin/telegram p " $snapshot_tempfile "
5254 fi
@@ -61,7 +63,7 @@ send_snapshot() {
6163 if [ " $matrix_alert_type " = " text" ] ; then
6264 debug_msg " Send matrix text"
6365 /system/sdcard/bin/matrix m " Motion detected"
64- elif [ " $matrix_alert_type " = " image" -o " $matrix_alert_type " = " video+image" ] ; then
66+ elif [ " $matrix_alert_type " = " image" ] || [ " $matrix_alert_type " = " video+image" ] ; then
6567 debug_msg " Send matrix image"
6668 /system/sdcard/bin/matrix p " $filename " " $snapshot_tempfile "
6769 fi
@@ -113,7 +115,7 @@ send_snapshot() {
113115
114116 # Limit the number of snapshots
115117 if [ " $( ls " $save_snapshot_dir " | wc -l) " -ge " $max_snapshot_days " ]; then
116- rm -rf " ${save_snapshot_dir} /$( ls -ltr " $save_snapshot_dir " | awk ' NR==2{print $9}' ) "
118+ rm -rf " ${save_snapshot_dir:? } /$( ls -ltr " $save_snapshot_dir " | awk ' NR==2{print $9}' ) "
117119 fi
118120
119121 chmod " $save_files_attr " " $snapshot_tempfile "
@@ -225,8 +227,8 @@ send_snapshot &
225227if [ " $save_video " = true ] ||
226228 [ " $smb_video " = true ] ||
227229 [ " $dropbox_video " = true ] ||
228- ( [ " $send_telegram " = true ] && ( [ " $telegram_alert_type " = video+image ] || [ " $telegram_alert_type " = video ])) ||
229- ( [ " $send_matrix " = true ] && ( [ " $matrix_alert_type " = video+image ] || [ " $matrix_alert_type " = video ])) ||
230+ { [ " $send_telegram " = true ] && { [ " $telegram_alert_type " = video+image ] || [ " $telegram_alert_type " = video ]; } ; } ||
231+ { [ " $send_matrix " = true ] && { [ " $matrix_alert_type " = video+image ] || [ " $matrix_alert_type " = video ]; } ; } ||
230232 [ " $publish_mqtt_video " = true ]
231233then
232234 record_video
@@ -246,7 +248,7 @@ if [ "$save_video" = true ] ; then
246248
247249 # Limit the number of videos
248250 if [ " $( ls " $save_video_dir " | wc -l) " -ge " $max_video_days " ]; then
249- rm -rf " $save_video_dir /$( ls -ltr " $save_video_dir " | awk ' NR==2{print $9}' ) "
251+ rm -rf " ${ save_video_dir:? } /$( ls -ltr " $save_video_dir " | awk ' NR==2{print $9}' ) "
250252 fi
251253
252254 chmod " $save_files_attr " " $video_tempfile "
@@ -356,7 +358,7 @@ if [ "$send_telegram" = true ]; then
356358 (
357359 include /system/sdcard/config/telegram.conf
358360
359- if [ " $telegram_alert_type " = " video" -o " $telegram_alert_type " = " video+image" ] ; then
361+ if [ " $telegram_alert_type " = " video" ] || [ " $telegram_alert_type " = " video+image" ] ; then
360362 if [ " $video_use_rtsp " = true ]; then
361363 if [ " $AUDIOFORMAT " = " PCMU" ] || [ " $AUDIOFORMAT " = " OFF" ] ; then
362364 # Convert file to mp4 and remove audio stream so video plays in telegram app
@@ -383,7 +385,7 @@ if [ "$send_matrix" = true ]; then
383385 (
384386 include /system/sdcard/config/matrix.conf
385387
386- if [ " $matrix_alert_type " = " video" -o " $matrix_alert_type " = " video+image" ] ; then
388+ if [ " $matrix_alert_type " = " video" ] || [ " $matrix_alert_type " = " video+image" ] ; then
387389 debug_msg " Send matrix video"
388390 if [ " $video_use_rtsp " = true ]; then
389391 /system/sdcard/bin/matrix v " $filename " " $video_tempfile "
0 commit comments