server-up/apps/unifi-network/files/init-mongo.sh
Ramon 1575db42c2
All checks were successful
Deploy server-up (dev) / deploy (push) Successful in 5m5s
v0.8.14-beta - Raspberry Pi compatibiliteit en UniFi Mongo herstellen
2026-08-04 16:49:24 +02:00

24 lines
579 B
Bash
Executable file

<% raw %>
#!/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: [
"clusterMonitor",
{ db: "${MONGO_DBNAME}", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_stat", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_audit", role: "dbOwner" },
{ db: "${MONGO_DBNAME}_restore", role: "dbOwner" }
]
})
EOF
<% endraw %>