-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·54 lines (39 loc) · 1.3 KB
/
init.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Setting environment variables
TIMEZONE=${TIMEZONE:-"Europe/Paris"}
INFLUXDB_USERNAME=${INFLUXDB_USERNAME:-"admin"}
INFLUXDB_PASSWORD=${INFLUXDB_PASSWORD:-"password"}
INFLUXDB_ORG=${INFLUXDB_ORG:-"home-lab"}
INFLUXDB_BUCKET=${INFLUXDB_BUCKET:-"telegraf"}
INFLUXDB_RETENTION=${INFLUXDB_RETENTION:-"1w"}
#-------------------------------
# Function to generate a secure InfluxDB admin token
function generate_influxdb_admin_token() {
gpg --gen-random -a 0 25
}
# Generation of the administration token
INFLUXDB_ADMIN_TOKEN=$(generate_influxdb_admin_token)
# Creating the .env file
cat << EOF > .env
TIMEZONE=$TIMEZONE
INFLUXDB_INIT_MODE=setup
# InfluxDB credentialsi
INFLUXDB_USERNAME=$INFLUXDB_USERNAME
INFLUXDB_PASSWORD=$INFLUXDB_PASSWORD
# InfluxDB organization and bucket
INFLUXDB_ORG=$INFLUXDB_ORG
INFLUXDB_BUCKET=$INFLUXDB_BUCKET
# InfluxDB retention period
INFLUXDB_RETENTION=$INFLUXDB_RETENTION
# InfluxDB admin token (highly sensitive, keep secret!)
INFLUXDB_ADMIN_TOKEN=$INFLUXDB_ADMIN_TOKEN
EOF
# Initializing the TICK stack
docker compose up -d
# Removal of setup mode
if [ "$(uname)" == "Darwin" ]; then
sed -i "" "/INFLUXDB_INIT_MODE/d" .env
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
sed -i "/INFLUXDB_INIT_MODE/d" .env
fi
echo "The TICK stack is initialized !"