Last active
January 24, 2020 13:06
-
-
Save Dmitry-Kucher/4d200329ca5db01dc7aa172cfff0c17f to your computer and use it in GitHub Desktop.
Mongodb auth string generation via bash based on env variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MONGODB_SERVER=${MONGODB_SERVER:-127.0.0.1} | |
MONOGDB_PORT=${MONGODB_PORT:-27017} | |
MONGODB_USER=${MONGODB_USER:-""} | |
MONGODB_PWD=${MONGODB_PWD:-""} | |
MONGODB_AUTH=$([ $MONGODB_USER ] && printf "%s" "$MONGODB_USER" && [ $MONGODB_PWD ] && printf "%s" ":$MONGODB_PWD") | |
MONGODB_URI="mongodb://${MONGODB_AUTH}@${MONGODB_SERVER}" | |
echo ${MONGODB_URI} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment