aboutsummaryrefslogtreecommitdiff
path: root/tools/ipcam_motion_worker_multiple.sh
blob: 5da697470ed5462f0d4f7387528f9cc38db32ff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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