Skip to content

Commit

Permalink
rename username variable to user
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Apr 21, 2015
1 parent 6d4fd89 commit 4dc8b19
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 2.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MAINTAINER Jakub Hadvig <jhadvig@redhat.com>
# Volumes:
# * /var/lib/mongodb/data - Datastore for MongoDB
# Environment:
# * $MONGODB_USERNAME - Database user name
# * $MONGODB_USER - Database user name
# * $MONGODB_PASSWORD - User's password
# * $MONGODB_DATABASE - Name of the database to create
# * $MONGODB_ADMIN_PASSWORD - Password of the MongoDB Admin
Expand Down
2 changes: 1 addition & 1 deletion 2.4/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MAINTAINER Jakub Hadvig <jhadvig@redhat.com>
# Volumes:
# * /var/lib/mongodb/data - Datastore for MongoDB
# Environment:
# * $MONGODB_USERNAME - Database user name
# * $MONGODB_USER - Database user name
# * $MONGODB_PASSWORD - User's password
# * $MONGODB_DATABASE - Name of the database to create
# * $MONGODB_ADMIN_PASSWORD - Password of the MongoDB Admin
Expand Down
4 changes: 2 additions & 2 deletions 2.4/contrib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ function run_mongod_supervisor() {
}

# mongo_create_users creates the MongoDB admin user and the database user
# configured by MONGO_USERNAME
# configured by MONGO_USER
function mongo_create_users() {
local admin_pwd=${MONGODB_ADMIN_PASSWORD:-$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16)}
mongo admin --eval "db.addUser({user: 'admin', pwd: '$admin_pwd', roles: ['dbAdminAnyDatabase', 'userAdminAnyDatabase' , 'readWriteAnyDatabase','clusterAdmin' ]});"
local mongo_cmd="mongo ${MONGODB_DATABASE}"
if [ ! -z "${MONGODB_REPLICA_NAME-}" ]; then
mongo_cmd+=" -u admin -p ${admin_pwd}"
fi
$mongo_cmd --eval "db.addUser({user: '${MONGODB_USERNAME}', pwd: '${MONGODB_PASSWORD}', roles: [ 'readWrite' ]});"
$mongo_cmd --eval "db.addUser({user: '${MONGODB_USER}', pwd: '${MONGODB_PASSWORD}', roles: [ 'readWrite' ]});"
touch /var/lib/mongodb/data/.mongodb_users_created
}

Expand Down
4 changes: 2 additions & 2 deletions 2.4/examples/replica/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ For the 'mongo-service' Pod, you have to set following variables:
* `MONGODB_REPLICA_NAME` - the name of the replSet (`rs0`).
* `MONGODB_SERVICE_NAME` - the name of the MongoDB Service (used to DNS lookup, default: 'mongodb')
* `MONGODB_ADMIN_PASSWORD` - the password for the 'admin' user.
* `MONGODB_USERNAME` - the name of the regular MongoDB user
* `MONGODB_USER` - the name of the regular MongoDB user
* `MONGODB_PASSWORD` - the regular MongoDB user password

For the 'mongo' PodTemplate, you have to set following variables (they have to
Expand All @@ -84,4 +84,4 @@ match the variables above):
* `MONGODB_SERVICE_NAME`
* `MONGODB_ADMIN_PASSWORD`

Optionally you can set `MONGODB_DATABASE` (it defaults to `MONGODB_USERNAME`).
Optionally you can set `MONGODB_DATABASE` (it defaults to `MONGODB_USER`).
2 changes: 1 addition & 1 deletion 2.4/examples/replica/mongo_controller.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
],
"env": [
{ "name": "MONGODB_USERNAME", "value": "testuser" },
{ "name": "MONGODB_USER", "value": "testuser" },
{ "name": "MONGODB_PASSWORD", "value": "test" },
{ "name": "MONGODB_ADMIN_PASSWORD", "value": "admin" },
{ "name": "MONGODB_REPLICA_NAME", "value": "rs0" },
Expand Down
12 changes: 6 additions & 6 deletions 2.4/run-mongod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export MONGODB_KEYFILE_PATH="/var/lib/mongodb/keyfile"

function usage() {
echo "You must specify following environment variables:"
echo " MONGODB_USERNAME"
echo " MONGODB_USER"
echo " MONGODB_PASSWORD"
echo "Optional variables:"
echo " MONGODB_DATABASE (default: \$MONGODB_USERNAME)"
echo " MONGODB_DATABASE (default: \$MONGODB_USER)"
echo " MONGODB_ADMIN_PASSWORD"
echo " MONGODB_REPLICA_NAME"
echo "MongoDB settings:"
Expand All @@ -37,7 +37,7 @@ function usage() {

# Make sure env variables don't propagate to mongod process.
function unset_env_vars() {
unset MONGODB_USERNAME MONGODB_PASSWORD MONGODB_DATABASE MONGODB_ADMIN_PASSWORD
unset MONGODB_USER MONGODB_PASSWORD MONGODB_DATABASE MONGODB_ADMIN_PASSWORD
}

function cleanup() {
Expand All @@ -55,7 +55,7 @@ function cleanup() {
}

if [ "$1" == "initiate" ]; then
if ! [[ -v MONGODB_USERNAME && -v MONGODB_PASSWORD ]]; then
if ! [[ -v MONGODB_USER && -v MONGODB_PASSWORD ]]; then
usage
fi
setup_keyfile
Expand All @@ -70,10 +70,10 @@ if [ "$1" = "mongod" ]; then
cache_container_addr
mongo_common_args="-f $MONGODB_CONFIG_PATH --oplogSize 64"
if [ -z "${MONGODB_REPLICA_NAME-}" ]; then
if ! [[ -v MONGODB_USERNAME && -v MONGODB_PASSWORD ]]; then
if ! [[ -v MONGODB_USER && -v MONGODB_PASSWORD ]]; then
usage
fi
export MONGODB_DATABASE=${MONGODB_DATABASE:-"${MONGODB_USERNAME}"}
export MONGODB_DATABASE=${MONGODB_DATABASE:-"${MONGODB_USER}"}
# Run the MongoDB in 'standalone' mode
if [ ! -f /var/lib/mongodb/data/.mongodb_users_created ]; then
# Create MongoDB users and restart MongoDB with authentication enabled
Expand Down
6 changes: 3 additions & 3 deletions 2.4/test/run
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function test_mongo() {
mongo_cmd "db.addUser({user: 'test_user2', pwd: 'test_password2', roles: ['readWrite']});"
fi
echo " Testing user privileges"
mongo_cmd "db.testData.insert({ y : 1 });"
mongo_cmd "db.testData.insert({ z : 2 });"
mongo_cmd "db.testData.insert({y:1});"
mongo_cmd "db.testData.insert({z:2});"
mongo_cmd "db.testData.find().forEach(printjson);"
mongo_cmd "db.testData.count();"
mongo_cmd "db.testData.drop();"
Expand Down Expand Up @@ -115,7 +115,7 @@ function create_container() {

function run_tests() {
local name=$1 ; shift
envs="-e MONGODB_USERNAME=$USER -e MONGODB_PASSWORD=$PASS -e MONGODB_DATABASE=$DB"
envs="-e MONGODB_USER=$USER -e MONGODB_PASSWORD=$PASS -e MONGODB_DATABASE=$DB"
if [ -v ADMIN_PASS ]; then
envs="$envs -e MONGODB_ADMIN_PASSWORD=$ADMIN_PASS"
fi
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ initialization, by passing `-e VAR=VALUE` to the Docker run command.

| Variable name | Description |
| :------------------------ | ----------------------------------------- |
| `MONGODB_USERNAME` | User name for MONGODB account to be created |
| `MONGODB_USER` | User name for MONGODB account to be created |
| `MONGODB_PASSWORD` | Password for the user account |
| `MONGODB_DATABASE` | Database name |
| `MONGODB_ADMIN_PASSWORD` | Password for the admin user (optional) |
Expand Down Expand Up @@ -91,7 +91,7 @@ in the `/home/user/database` directory on the host filesystem, you need to
execute the following command:

```
$ docker run -d -e MONGODB_USERNAME=<user> -e MONGODB_PASSWORD=<password> -e MONGODB_DATABASE=<database> -v /home/user/database:/var/lib/mongodb/data openshift/mongodb-24-centos7
$ docker run -d -e MONGODB_USER=<user> -e MONGODB_PASSWORD=<password> -e MONGODB_DATABASE=<database> -v /home/user/database:/var/lib/mongodb/data openshift/mongodb-24-centos7
```

If you are initializing the database and it's the first time you are using the
Expand Down

0 comments on commit 4dc8b19

Please sign in to comment.