Skip to content

Commit 86974ba

Browse files
authored
Merge pull request #341 from infosiftr/configsvr
Update _dbPath function to account for running as a config server
2 parents 6f010d8 + e0b3c10 commit 86974ba

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

3.4/docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ _dbPath() {
172172
fi
173173
fi
174174

175+
if [ -z "$dbPath" ]; then
176+
if _mongod_hack_have_arg --configsvr "$@" || {
177+
_parse_config "$@" \
178+
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
179+
&& [ "$clusterRole" = 'configsvr']
180+
}; then
181+
# if running as config server, then the default dbpath is /data/configdb
182+
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
183+
dbPath=/data/configdb
184+
fi
185+
fi
186+
175187
: "${dbPath:=/data/db}"
176188

177189
echo "$dbPath"

3.6/docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ _dbPath() {
172172
fi
173173
fi
174174

175+
if [ -z "$dbPath" ]; then
176+
if _mongod_hack_have_arg --configsvr "$@" || {
177+
_parse_config "$@" \
178+
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
179+
&& [ "$clusterRole" = 'configsvr']
180+
}; then
181+
# if running as config server, then the default dbpath is /data/configdb
182+
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
183+
dbPath=/data/configdb
184+
fi
185+
fi
186+
175187
: "${dbPath:=/data/db}"
176188

177189
echo "$dbPath"

4.0/docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ _dbPath() {
172172
fi
173173
fi
174174

175+
if [ -z "$dbPath" ]; then
176+
if _mongod_hack_have_arg --configsvr "$@" || {
177+
_parse_config "$@" \
178+
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
179+
&& [ "$clusterRole" = 'configsvr']
180+
}; then
181+
# if running as config server, then the default dbpath is /data/configdb
182+
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
183+
dbPath=/data/configdb
184+
fi
185+
fi
186+
175187
: "${dbPath:=/data/db}"
176188

177189
echo "$dbPath"

4.1/docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ _dbPath() {
172172
fi
173173
fi
174174

175+
if [ -z "$dbPath" ]; then
176+
if _mongod_hack_have_arg --configsvr "$@" || {
177+
_parse_config "$@" \
178+
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
179+
&& [ "$clusterRole" = 'configsvr']
180+
}; then
181+
# if running as config server, then the default dbpath is /data/configdb
182+
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
183+
dbPath=/data/configdb
184+
fi
185+
fi
186+
175187
: "${dbPath:=/data/db}"
176188

177189
echo "$dbPath"

docker-entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ _dbPath() {
172172
fi
173173
fi
174174

175+
if [ -z "$dbPath" ]; then
176+
if _mongod_hack_have_arg --configsvr "$@" || {
177+
_parse_config "$@" \
178+
&& clusterRole="$(jq -r '.sharding.clusterRole // empty' "$jsonConfigFile")" \
179+
&& [ "$clusterRole" = 'configsvr']
180+
}; then
181+
# if running as config server, then the default dbpath is /data/configdb
182+
# https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-configsvr
183+
dbPath=/data/configdb
184+
fi
185+
fi
186+
175187
: "${dbPath:=/data/db}"
176188

177189
echo "$dbPath"

0 commit comments

Comments
 (0)