Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pfzim committed Sep 15, 2024
1 parent f4f2de5 commit 1a80419
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 40 deletions.
8 changes: 4 additions & 4 deletions motion/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

. /opt/motion/config.conf

if [ ! -e /opt/motion/flags/flag_check_zigbee.disabled ] ; then
if [ ! -e /opt/motion/flags/flag_check_zigbee.disable ] ; then
if [ ! -e /dev/ttyACM0 ] ; then
wget -q -O /dev/null "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${BOT_CHAT_ID}&text=${SYS_NAME} Zigbee coordinator device failed!"
fi
fi

if [ ! -e /opt/motion/flags/flag_check_internet.disabled ] ; then
if [ ! -e /opt/motion/flags/flag_check_internet.disable ] ; then
cnt=`cat /tmp/no_internet.count` || cnt=0

if ! ping -c 1 8.8.8.8 >/dev/null 2>&1 ; then
Expand All @@ -23,7 +23,7 @@ if [ ! -e /opt/motion/flags/flag_check_internet.disabled ] ; then
fi
fi

if [ ! -e /opt/motion/flags/flag_check_hdd.disabled ] ; then
if [ ! -e /opt/motion/flags/flag_check_hdd.disable ] ; then
filecontent=`cat /mnt/data/mounted`

if [ "$filecontent" != "mounted" ] ; then
Expand All @@ -33,7 +33,7 @@ if [ ! -e /opt/motion/flags/flag_check_hdd.disabled ] ; then
fi
fi

if [ ! -e /opt/motion/flags/flag_check_motion_service.disabled ] ; then
if [ ! -e /opt/motion/flags/flag_check_motion_service.disable ] ; then
motion_state=`systemctl show motion.service -p ActiveState`
if [ "$motion_state" != "ActiveState=active" ] ; then
wget -q -O /dev/null "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${BOT_CHAT_ID}&text=${SYS_NAME} Motion service is stopped"
Expand Down
8 changes: 4 additions & 4 deletions motion/on_cam_events_disable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#touch /opt/motion/flags/cam_${1}_events.disable || exit 1

touch /opt/motion/flags/flag_cam_${1}_event_motion.disabled
touch /opt/motion/flags/flag_cam_${1}_event_start.disabled
touch /opt/motion/flags/flag_cam_${1}_event_stop.disabled
touch /opt/motion/flags/flag_cam_${1}_event_save.disabled
touch /opt/motion/flags/flag_cam_${1}_event_motion.disable
touch /opt/motion/flags/flag_cam_${1}_event_start.disable
touch /opt/motion/flags/flag_cam_${1}_event_stop.disable
touch /opt/motion/flags/flag_cam_${1}_event_save.disable

exit 0
12 changes: 6 additions & 6 deletions motion/on_cam_events_enable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#rm -f /opt/motion/flags/cam_${1}_events.disable || exit 1

rm -f /opt/motion/flags/flag_cam_${1}_event_motion.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_start.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_stop.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_lost.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_found.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_save.disabled
rm -f /opt/motion/flags/flag_cam_${1}_event_motion.disable
rm -f /opt/motion/flags/flag_cam_${1}_event_start.disable
rm -f /opt/motion/flags/flag_cam_${1}_event_stop.disable
rm -f /opt/motion/flags/flag_cam_${1}_event_lost.disable
rm -f /opt/motion/flags/flag_cam_${1}_event_found.disable
rm -f /opt/motion/flags/flag_cam_${1}_event_save.disable

exit 0
20 changes: 0 additions & 20 deletions motion/on_motion.sh

This file was deleted.

10 changes: 5 additions & 5 deletions motion/on_save.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trap "rm -f '${snapshot_file}'" 1 2 3 8 9 15
exit 0
fi

if [ -e /opt/motion/flags/flag_cam_${cam_id}_event_save.disabled -a ! \( -e /tmp/on_snapshot_camera${cam_id}.conf -o -e /opt/motion/flags/flag_cam_${cam_id}_event_save.once \) ] ; then
if [ -e /opt/motion/flags/flag_cam_${cam_id}_event_save.disable -a ! \( -e /tmp/on_snapshot_camera${cam_id}.conf -o -e /opt/motion/flags/flag_cam_${cam_id}_event_save.once \) ] ; then
rm -f "${snapshot_file}"
exit 0
fi
Expand All @@ -38,13 +38,13 @@ trap "rm -f '${snapshot_file}'" 1 2 3 8 9 15
if [ -e /tmp/on_snapshot_camera${cam_id}.conf ] ; then
rm -f /tmp/on_snapshot_camera${cam_id}.conf
# First 10 shots required
elif [ -e /opt/motion/flags/cam_${cam_id}_event_save.once ] ; then
shots=`cat /opt/motion/flags/cam_${cam_id}_event_save.once` || shots=10
elif [ -e /opt/motion/flags/flag_cam_${cam_id}_event_save.once ] ; then
shots=`cat /opt/motion/flags/flag_cam_${cam_id}_event_save.once` || shots=10
shots=$((shots - 1))
if [ $shots -gt 0 ] ; then
echo $shots > /opt/motion/flags/cam_${cam_id}_event_save.once
echo $shots > /opt/motion/flags/flag_cam_${cam_id}_event_save.once
else
rm -f /opt/motion/flags/cam_${cam_id}_event_save.once
rm -f /opt/motion/flags/flag_cam_${cam_id}_event_save.once
fi
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion motion/send_event.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ done
exit 0
fi

[ -e "/opt/motion/flags/flag_${event_id}.disabled" -a ! -e "/opt/motion/flags/flag_${event_id}.once" ] && exit 0
[ -e "/opt/motion/flags/flag_${event_id}.disable" -a ! -e "/opt/motion/flags/flag_${event_id}.once" ] && exit 0

. /opt/motion/config.conf

Expand Down

0 comments on commit 1a80419

Please sign in to comment.