summaryrefslogtreecommitdiff
path: root/tools/ipcam_motion_worker_multiple.sh
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-08 22:01:22 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-11 19:05:51 +0300
commiteb502ab9c94cc8a89a29f9310e2f56404b432053 (patch)
tree70ec81d40a9fc406960d85773436d3b33a014c7a /tools/ipcam_motion_worker_multiple.sh
parent1ed87f69878b85daf94cde4c7b187939d9e15778 (diff)
ipcam: rewrite motion detection system
Diffstat (limited to 'tools/ipcam_motion_worker_multiple.sh')
-rwxr-xr-xtools/ipcam_motion_worker_multiple.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/ipcam_motion_worker_multiple.sh b/tools/ipcam_motion_worker_multiple.sh
new file mode 100755
index 0000000..5da6974
--- /dev/null
+++ b/tools/ipcam_motion_worker_multiple.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -e
+
+DIR="$( cd "$( dirname "$(realpath "${BASH_SOURCE[0]}")" )" &>/dev/null && pwd )"
+PROGNAME="$0"
+
+. "$DIR/lib.bash"
+
+configs=()
+
+usage() {
+ cat <<EOF
+usage: $PROGNAME [OPTIONS] CONFIG_NAME ...
+
+Options:
+ -v be verbose
+EOF
+ exit 1
+}
+
+[[ $# -lt 1 ]] && usage
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -v)
+ VERBOSE=1
+ shift
+ ;;
+
+ *)
+ configs+=("$1")
+ shift
+ ;;
+ esac
+done
+
+[ -z "$configs" ] && die "no config files supplied"
+
+if pidof -o %PPID -x "$(basename "${BASH_SOURCE[0]}")" >/dev/null; then
+ die "process already running"
+fi
+
+worker_args=
+[ "$VERBOSE" = "1" ] && worker_args="-v"
+for name in "${configs[@]}"; do
+ echoinfo "starting worker $name..."
+ $DIR/ipcam_motion_worker.sh $worker_args -c "$HOME/.config/ipcam_motion_worker/$name.txt" --allow-multiple
+done