@@ -12,7 +12,7 @@ export MONGODB_ROOT_PASSWORD=...
1212
1313COMMENT
1414
15- # set -eou pipefail
15+ set -x
1616
1717ASSETS_PATH=${ASSETS_PATH:-/ usr/ share/ extras/ }
1818
@@ -34,7 +34,7 @@ MONGODB_DATABASES=(
3434)
3535
3636disableMongoTelemetry () {
37- mongosh --nodb --eval " disableTelemetry()"
37+ mongosh --nodb --eval " disableTelemetry()" || true
3838}
3939
4040waitForMongoDB () {
@@ -82,6 +82,12 @@ setPacks() {
8282
8383parseMongoURI $MONGO_URI
8484
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+
8591disableMongoTelemetry
8692
8793waitForMongoDB
@@ -90,20 +96,20 @@ getMongoVersion
9096
9197for MONGODB_DATABASE in ${MONGODB_DATABASES[@]} ; do
9298 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
94100 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
96102done
97103
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
101107
102108if [[ $DEVELOPMENT_CHART == " true" ]]; then
103109 setSystemAdmin
104110 setPacks
105111fi
106112
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