setup-mongo.sh 785 B

123456789101112131415161718
  1. #!/bin/bash
  2. MONGO_VERSION_INT=${MONGO_VERSION:0:1}
  3. if [[ $MONGO_VERSION_INT -ge 5 ]]; then
  4. mongosh musare \
  5. --port 27017 \
  6. -u "admin" \
  7. --authenticationDatabase "admin" \
  8. -p ${MONGO_ROOT_PASSWORD} \
  9. --eval "disableTelemetry(); db.createUser({ user: '${MONGO_USER_USERNAME}', pwd: '${MONGO_USER_PASSWORD}', roles:[ { role:'readWrite', db: 'musare' } ] } );"
  10. else
  11. mongo musare \
  12. --port 27017 \
  13. -u "admin" \
  14. --authenticationDatabase "admin" \
  15. -p ${MONGO_ROOT_PASSWORD} \
  16. --eval "db.createUser({ user: '${MONGO_USER_USERNAME}', pwd: '${MONGO_USER_PASSWORD}', roles:[ { role:'readWrite', db: 'musare' } ] } );"
  17. fi