mirror of
https://github.com/Haxxnet/Compose-Examples.git
synced 2026-04-01 05:15:38 +02:00
Create init-mongo.sh
This commit is contained in:
20
examples/unify-network-application/init-mongo.sh
Normal file
20
examples/unify-network-application/init-mongo.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if which mongosh > /dev/null 2>&1; then
|
||||||
|
mongo_init_bin='mongosh'
|
||||||
|
else
|
||||||
|
mongo_init_bin='mongo'
|
||||||
|
fi
|
||||||
|
"${mongo_init_bin}" <<EOF
|
||||||
|
use ${MONGO_AUTHSOURCE}
|
||||||
|
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
|
||||||
|
db.createUser({
|
||||||
|
user: "${MONGO_USER}",
|
||||||
|
pwd: "${MONGO_PASS}",
|
||||||
|
roles: [
|
||||||
|
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
|
||||||
|
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" },
|
||||||
|
{ db: "${MONGO_DBNAME}_audit", role: "dbOwner" }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
EOF
|
||||||
Reference in New Issue
Block a user