@@ -12,7 +12,7 @@ export MONGODB_ROOT_PASSWORD=...
12
12
13
13
COMMENT
14
14
15
- # set -eou pipefail
15
+ set -x
16
16
17
17
ASSETS_PATH=${ASSETS_PATH:-/ usr/ share/ extras/ }
18
18
@@ -34,7 +34,7 @@ MONGODB_DATABASES=(
34
34
)
35
35
36
36
disableMongoTelemetry () {
37
- mongosh --nodb --eval " disableTelemetry()"
37
+ mongosh --nodb --eval " disableTelemetry()" || true
38
38
}
39
39
40
40
waitForMongoDB () {
@@ -82,6 +82,12 @@ setPacks() {
82
82
83
83
parseMongoURI $MONGO_URI
84
84
85
+ if [[ -s /etc/ssl/mongodb/ca.pem ]]; then
86
+ MONGO_URI_EXTRA_PARAMS=" --tls --tlsCertificateKeyFile /etc/ssl/mongodb/ca.pem --tlsAllowInvalidHostnames --tlsAllowInvalidCertificates"
87
+ else
88
+ MONGO_URI_EXTRA_PARAMS=" "
89
+ fi
90
+
85
91
disableMongoTelemetry
86
92
87
93
waitForMongoDB
@@ -90,20 +96,20 @@ getMongoVersion
90
96
91
97
for MONGODB_DATABASE in ${MONGODB_DATABASES[@]} ; do
92
98
waitForMongoDB
93
- mongosh ${MONGODB_ROOT_URI} --eval " db.getSiblingDB(\" ${MONGODB_DATABASE} \" ).createUser({user: \" ${MONGODB_USER} \" , pwd: \" ${MONGODB_PASSWORD} \" , roles: [\" readWrite\" ]})" 2>&1 || true
99
+ mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval " db.getSiblingDB(\" ${MONGODB_DATABASE} \" ).createUser({user: \" ${MONGODB_USER} \" , pwd: \" ${MONGODB_PASSWORD} \" , roles: [\" readWrite\" ]})" 2>&1 || true
94
100
waitForMongoDB
95
- mongosh ${MONGODB_ROOT_URI} --eval " db.getSiblingDB(\" ${MONGODB_DATABASE} \" ).changeUserPassword(\" ${MONGODB_USER} \" ,\" ${MONGODB_PASSWORD} \" )" 2>&1 || true
101
+ mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval " db.getSiblingDB(\" ${MONGODB_DATABASE} \" ).changeUserPassword(\" ${MONGODB_USER} \" ,\" ${MONGODB_PASSWORD} \" )" 2>&1 || true
96
102
done
97
103
98
- mongosh ${MONGODB_ROOT_URI} --eval " db.getSiblingDB(\" codefresh\" ).grantRolesToUser( \" ${MONGODB_USER} \" , [ { role: \" readWrite\" , db: \" pipeline-manager\" } ] )" 2>&1 || true
99
- mongosh ${MONGODB_ROOT_URI} --eval " db.getSiblingDB(\" codefresh\" ).grantRolesToUser( \" ${MONGODB_USER} \" , [ { role: \" readWrite\" , db: \" platform-analytics-postgres\" } ] )" 2>&1 || true
100
- mongosh ${MONGODB_ROOT_URI} --eval " db.getSiblingDB(\" codefresh\" ).changeUserPassword(\" ${MONGODB_USER} \" ,\" ${MONGODB_PASSWORD} \" )" 2>&1 || true
104
+ mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval " db.getSiblingDB(\" codefresh\" ).grantRolesToUser( \" ${MONGODB_USER} \" , [ { role: \" readWrite\" , db: \" pipeline-manager\" } ] )" 2>&1 || true
105
+ mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval " db.getSiblingDB(\" codefresh\" ).grantRolesToUser( \" ${MONGODB_USER} \" , [ { role: \" readWrite\" , db: \" platform-analytics-postgres\" } ] )" 2>&1 || true
106
+ mongosh ${MONGODB_ROOT_URI} ${MONGO_URI_EXTRA_PARAMS} --eval " db.getSiblingDB(\" codefresh\" ).changeUserPassword(\" ${MONGODB_USER} \" ,\" ${MONGODB_PASSWORD} \" )" 2>&1 || true
101
107
102
108
if [[ $DEVELOPMENT_CHART == " true" ]]; then
103
109
setSystemAdmin
104
110
setPacks
105
111
fi
106
112
107
- mongoimport --uri ${MONGO_URI} --collection idps --type json --legacy --file ${ASSETS_PATH} idps.json
108
- mongoimport --uri ${MONGO_URI} --collection accounts --type json --legacy --file ${ASSETS_PATH} accounts.json
109
- mongoimport --uri ${MONGO_URI} --collection users --type json --legacy --file ${ASSETS_PATH} users.json
113
+ mongoimport --uri ${MONGO_URI} ${MONGO_URI_EXTRA_PARAMS} --collection idps --type json --legacy --file ${ASSETS_PATH} idps.json
114
+ mongoimport --uri ${MONGO_URI} ${MONGO_URI_EXTRA_PARAMS} --collection accounts --type json --legacy --file ${ASSETS_PATH} accounts.json
115
+ mongoimport --uri ${MONGO_URI} ${MONGO_URI_EXTRA_PARAMS} --collection users --type json --legacy --file ${ASSETS_PATH} users.json
0 commit comments