-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·48 lines (37 loc) · 1.04 KB
/
Copy pathinit.sh
File metadata and controls
executable file
·48 lines (37 loc) · 1.04 KB
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
#! /bin/bash
set -euo pipefail
dir="$(dirname $0)"
ctx=""
help() { cat <<EOF
usage: $(basename $0) [FLAGS]
Initializes NATS for nalpaca. You'll need the NATS cli.
Editing any of the JSON files this script uses in $dir to fit your
needs can be okay if you are editing things that don't bother nalpaca.
Settings that should not be touched are the stream names and the subjects
Editing subjects is not supported and will break your installation
-h Display help
-c Set the NATS context to use
EOF
exit $1
}
while getopts "hc:" flag; do
case $flag in
h) help 0;;
c) ctx="$OPTARG";;
\?) echo "Option not defined: $flag"; help 1;;
esac
done
if [[ $(which nats) == "" ]]; then
echo "Missing nats cli"
help 1
fi
n="nats"
if [[ "$ctx" != "" ]]; then
n+=" --context=$ctx"
fi
for i in $(find $dir -mindepth 1 -type d); do
stream=nalpaca-$(basename $i)-stream
$n stream add $stream --config $i/stream.json # has to be ran first
find $i -iname "*-consumer.json" -exec $n consumer add $stream --config {} \;
done
$n kv add nalpaca