Skip to content

Commit

Permalink
Update to MongoDB 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Jan 19, 2023
1 parent 4907093 commit 1cea2fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion faf-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
# NoSQL database specifically used for nodebb
#
mongodb:
image: mongo:4.2.17
image: mongo:6.0.3-focal
restart: unless-stopped
networks:
- faf-extra
Expand Down
9 changes: 6 additions & 3 deletions scripts/init-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# fail on errors
set -e

. config/extra/mongodb/mongodb.env

alias mongo-exec='docker-compose -f faf-extra.yml exec -T mongodb mongosh -u ${MONGO_INITDB_ROOT_USERNAME} -p "${MONGO_INITDB_ROOT_PASSWORD}" --quiet'

if [ ! -f faf-extra.yml ]; then
echo "You are not inside faf-stack. The working directory must be the root of faf-stack."
exit 1
Expand All @@ -16,7 +20,7 @@ log_process_id=$!

echo "Waiting for mongodb"
current_wait=0
while ! docker-compose -f faf-extra.yml exec -T mongodb mongo --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' >/dev/null 2>&1
while ! mongo-exec --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' >/dev/null 2>&1
do
if [ ${current_wait} -ge ${MAX_WAIT} ]; then
echo "Timeout on startup of mongodb"
Expand All @@ -30,8 +34,7 @@ done
kill ${log_process_id}

echo "Create mongodb database and user for nodebb"
. config/extra/mongodb/mongodb.env
docker-compose -f faf-extra.yml exec -T mongodb mongo -u "${MONGO_INITDB_ROOT_USERNAME}" -p "${MONGO_INITDB_ROOT_PASSWORD}" <<MONGODB_SCRIPT
mongo-exec <<MONGODB_SCRIPT
use ${MONGO_NODEBB_DATABASE};
db.createUser( { user: "${MONGO_NODEBB_USERNAME}", pwd: "${MONGO_NODEBB_PASSWORD}", roles: [ "readWrite" ] } );
db.grantRolesToUser("${MONGO_NODEBB_USERNAME}",[{ role: "clusterMonitor", db: "admin" }]);
Expand Down

0 comments on commit 1cea2fa

Please sign in to comment.