File tree 4 files changed +36
-28
lines changed 4 files changed +36
-28
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ source check-minimum-requirements.sh
20
20
source turn-things-off.sh
21
21
source create-docker-volumes.sh
22
22
source ensure-files-from-examples.sh
23
+ source ensure-relay-credentials.sh
23
24
source generate-secret-key.sh
24
25
source replace-tsdb.sh
25
26
source update-docker-images.sh
@@ -31,6 +32,5 @@ source create-kafka-topics.sh
31
32
source upgrade-postgres.sh
32
33
source set-up-and-migrate-database.sh
33
34
source migrate-file-storage.sh
34
- source relay-credentials.sh
35
35
source geoip.sh
36
36
source wrap-up.sh
Original file line number Diff line number Diff line change @@ -9,15 +9,15 @@ test ! -f $cfg
9
9
test ! -f $creds
10
10
11
11
# Running the install script adds them.
12
- source relay-credentials.sh
12
+ source ensure- relay-credentials.sh
13
13
test -f $cfg
14
14
test -f $creds
15
15
test " $( jq -r ' keys[2]' $creds ) " = " secret_key"
16
16
17
17
# If the files exist we don't touch it.
18
18
echo GARBAGE > $cfg
19
19
echo MOAR GARBAGE > $creds
20
- source relay-credentials.sh
20
+ source ensure- relay-credentials.sh
21
21
test " $( cat $cfg ) " = " GARBAGE"
22
22
test " $( cat $creds ) " = " MOAR GARBAGE"
23
23
Original file line number Diff line number Diff line change
1
+ echo " ${_group} Ensuring Relay credentials ..."
2
+
3
+ RELAY_CONFIG_YML=" ../relay/config.yml"
4
+ RELAY_CREDENTIALS_JSON=" ../relay/credentials.json"
5
+
6
+ ensure_file_from_example $RELAY_CONFIG_YML
7
+
8
+ if [[ -f " $RELAY_CREDENTIALS_JSON " ]]; then
9
+ echo " $RELAY_CREDENTIALS_JSON already exists, skipped creation."
10
+ else
11
+
12
+ # There are a couple gotchas here:
13
+ #
14
+ # 1. We need to use a tmp file because if we redirect output directly to
15
+ # credentials.json, then the shell will create an empty file that relay
16
+ # will then try to read from (regardless of options such as --stdout or
17
+ # --overwrite) and fail because it is empty.
18
+ #
19
+ # 2. We need to use -T to avoid additional garbage output cluttering
20
+ # credentials.json under Docker Compose 1.x and 2.2.3+.
21
+
22
+ creds=" $dcr --no-deps -T relay credentials"
23
+ $creds generate --stdout > " $RELAY_CREDENTIALS_JSON " .tmp
24
+ mv " $RELAY_CREDENTIALS_JSON " .tmp " $RELAY_CREDENTIALS_JSON "
25
+ if ! grep -q Credentials <( $creds show) ; then
26
+ # Let's fail early if creds failed, to make debugging easier.
27
+ echo " Failed to create relay credentials in $RELAY_CREDENTIALS_JSON ."
28
+ exit 1
29
+ fi
30
+ echo " Relay credentials written to $RELAY_CREDENTIALS_JSON ."
31
+ fi
32
+
33
+ echo " ${_endgroup} "
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments