-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate-token.sh
More file actions
executable file
·42 lines (31 loc) · 959 Bytes
/
generate-token.sh
File metadata and controls
executable file
·42 lines (31 loc) · 959 Bytes
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
#!/bin/bash
FORCE=0
if [ "$1" = "--force" ]; then
FORCE=1
fi
if [ -f .env ]; then
source .env
fi
if [ -n "$INFLUXDB_TOKEN" ] && [ $FORCE -eq 0 ]; then
echo "influxdb token already set"
exit 0
fi
if ! command -v openssl &> /dev/null; then
echo "Error: openssl command not found.. Exiting!"
exit 1
fi
TOKEN=$(openssl rand -base64 64 | tr -d '\n')
echo INFLUXDB_TOKEN="$TOKEN" > .env
echo "Generated .env with token"
if ! command -v envsubst &> /dev/null; then
echo "Error: envsubst command not found.. Exiting!"
fi
source .env
export INFLUXDB_TOKEN
envsubst < config/config.template.yaml > config/config.yaml
echo "Generated config/config.yaml"
envsubst < config/influxdb.template.yml > provisioning/datasources/influxdb.yml
echo "Generated provisioning/datasources/influxdb.yml"
if [ $FORCE -eq 1 ]; then
echo "Token regenerated. Now run 'make reset' to remove volumes and reinitialize InfluxDB, then 'make run'."
fi