Skip to content

Commit

Permalink
Remove oldest snaps when save_dir is full & run user motion scripts i…
Browse files Browse the repository at this point in the history
…n background (EliasKotlyar#647)

* Changed removal logic of saved snaps & run custom motion script in background

Oldest files are removed if save_snap directory is full

* Update detectionOn.sh
  • Loading branch information
saipsa authored and jmtatsch committed Aug 27, 2018
1 parent 0a99204 commit 88414b7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions firmware_mod/scripts/detectionOn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ if [ "$save_snapshot" = true ] ; then
if [ ! -d "$save_dir" ]; then
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}')"
fi
{
# Limit the number of snapshots
if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then
rm -f "$save_dir/$(ls -ltr "$save_dir" | awk 'NR==2{print $9}')"
fi
} &
/system/sdcard/bin/getimage > "$save_dir/$filename" &
fi

Expand Down Expand Up @@ -52,6 +54,6 @@ fi
for i in /system/sdcard/config/userscripts/motiondetection/*; do
if [ -x "$i" ]; then
echo "Running: $i on"
$i on
$i on &
fi
done

0 comments on commit 88414b7

Please sign in to comment.