-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·72 lines (60 loc) · 1.89 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·72 lines (60 loc) · 1.89 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# Configure git to use the GitHub token for HTTPS if provided
if [ -n "$GITHUB_TOKEN" ]; then
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
# if INFLUX_TOKEN is set, then run thorflux
if [ -n "$INFLUX_TOKEN" ]; then
/app/thorflux
else
# if INFLUX_URL is not set, then throw an error
if [ -z "$INFLUX_URL" ]; then
echo "INFLUX_URL is not set. Exiting..."
exit 1
fi
# if INFLUX_USERNAME is not set, then throw an error
if [ -z "$INFLUX_USERNAME" ]; then
echo "INFLUX_USERNAME is not set. Exiting..."
exit 1
fi
# if INFLUX_PASSWORD is not set, then throw an error
if [ -z "$INFLUX_PASSWORD" ]; then
echo "INFLUX_PASSWORD is not set. Exiting..."
exit 1
fi
# if INFLUX_ORG is not set, then throw an error
if [ -z "$INFLUX_ORG" ]; then
echo "INFLUX_ORG is not set. Exiting..."
exit 1
fi
# if INFLUX_BUCKET is not set, then throw an error
if [ -z "$INFLUX_BUCKET" ]; then
echo "INFLUX_BUCKET is not set. Exiting..."
exit 1
fi
influx config create \
-n token-config \
-u "$INFLUX_URL" \
-p "$INFLUX_USERNAME:$INFLUX_PASSWORD" \
-o "$INFLUX_ORG"
echo "Checking for existing thorflux-api-token..."
EXISTING_TOKEN=$(influx auth list \
--org "$INFLUX_ORG" \
--json | jq -r '.[] | select(.description == "thorflux-api-token") | .token' | head -1)
if [[ -n "$EXISTING_TOKEN" && "$EXISTING_TOKEN" != "null" ]]; then
echo "Found existing thorflux-api-token, reusing it..."
ALL_ACCESS_TOKEN="$EXISTING_TOKEN"
else
echo "No existing thorflux-api-token found, creating new one..."
ALL_ACCESS_TOKEN=$(influx auth create \
--org "$INFLUX_ORG" \
--read-buckets \
--write-buckets \
--description "thorflux-api-token" | awk 'NR==2 {print $3}')
if [[ -z "$ALL_ACCESS_TOKEN" ]]; then
echo "Error: All Access token not generated."
exit 1
fi
fi
INFLUX_TOKEN=$ALL_ACCESS_TOKEN /app/thorflux
fi