-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·37 lines (29 loc) · 957 Bytes
/
setup.sh
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
#! /bin/bash
echo "Checking enviroment variables..."
function check {
[ -z "$2" ] && echo "Need to set $1" && exit 1;
}
check INFLUX_HOSTNAME $INFLUX_HOSTNAME
check INFLUX_PORT $INFLUX_PORT
check INFLUX_USERNAME $INFLUX_USERNAME
check INFLUX_PASSWORD $INFLUX_PASSWORD
check INFLUX_TOKEN $INFLUX_TOKEN
check INFLUX_ORGANIZATION $INFLUX_ORGANIZATION
check INFLUX_BUCKET $INFLUX_BUCKET
check INFLUX_RETENTION_PERIOD $INFLUX_RETENTION_PERIOD
echo "Done!"
set -e
./wait-for.sh "$INFLUX_HOSTNAME:$INFLUX_PORT" --timeout=600
echo "Broker ready"
echo "http://$INFLUX_HOSTNAME:$INFLUX_PORT/api/v2/setup"
curl -X POST \
"http://$INFLUX_HOSTNAME:$INFLUX_PORT/api/v2/setup" \
-H 'Content-Type: application/json' \
-d "{
\"username\": \"$INFLUX_USERNAME\",
\"password\": \"$INFLUX_PASSWORD\",
\"org\": \"$INFLUX_ORGANIZATION\",
\"bucket\": \"$INFLUX_BUCKET\",
\"token\": \"$INFLUX_TOKEN\",
\"retentionPeriodHrs\": $INFLUX_RETENTION_PERIOD
}"