Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 3.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ _js_escape() {
jq --null-input --arg 'str' "$1" '$str'
}

jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json"
tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json"
_parse_config() {
if [ -s "$tempConfigFile" ]; then
Expand All @@ -132,9 +133,8 @@ _parse_config() {
if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then
# if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys)
# see https://docs.mongodb.com/manual/reference/configuration-options/
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" \
| jq 'del(.systemLog, .processManagement, .net, .security)' \
> "$tempConfigFile"
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile"
return 0
fi

Expand All @@ -149,7 +149,7 @@ _dbPath() {

if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then
if _parse_config "$@"; then
dbPath="$(jq '.storage.dbPath' "$tempConfigFile")"
dbPath="$(jq '.storage.dbPath' "$jsonConfigFile")"
fi
fi

Expand Down Expand Up @@ -302,6 +302,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
unset "${!MONGO_INITDB_@}"
fi

rm -f "$tempConfigFile"
rm -f "$jsonConfigFile" "$tempConfigFile"

exec "$@"
10 changes: 5 additions & 5 deletions 3.2/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ _js_escape() {
jq --null-input --arg 'str' "$1" '$str'
}

jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json"
tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json"
_parse_config() {
if [ -s "$tempConfigFile" ]; then
Expand All @@ -132,9 +133,8 @@ _parse_config() {
if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then
# if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys)
# see https://docs.mongodb.com/manual/reference/configuration-options/
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" \
| jq 'del(.systemLog, .processManagement, .net, .security)' \
> "$tempConfigFile"
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile"
return 0
fi

Expand All @@ -149,7 +149,7 @@ _dbPath() {

if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then
if _parse_config "$@"; then
dbPath="$(jq '.storage.dbPath' "$tempConfigFile")"
dbPath="$(jq '.storage.dbPath' "$jsonConfigFile")"
fi
fi

Expand Down Expand Up @@ -302,6 +302,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
unset "${!MONGO_INITDB_@}"
fi

rm -f "$tempConfigFile"
rm -f "$jsonConfigFile" "$tempConfigFile"

exec "$@"
10 changes: 5 additions & 5 deletions 3.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ _js_escape() {
jq --null-input --arg 'str' "$1" '$str'
}

jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json"
tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json"
_parse_config() {
if [ -s "$tempConfigFile" ]; then
Expand All @@ -132,9 +133,8 @@ _parse_config() {
if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then
# if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys)
# see https://docs.mongodb.com/manual/reference/configuration-options/
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" \
| jq 'del(.systemLog, .processManagement, .net, .security)' \
> "$tempConfigFile"
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile"
return 0
fi

Expand All @@ -149,7 +149,7 @@ _dbPath() {

if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then
if _parse_config "$@"; then
dbPath="$(jq '.storage.dbPath' "$tempConfigFile")"
dbPath="$(jq '.storage.dbPath' "$jsonConfigFile")"
fi
fi

Expand Down Expand Up @@ -302,6 +302,6 @@ if [ "$originalArgOne" = 'mongod' ]; then
unset "${!MONGO_INITDB_@}"
fi

rm -f "$tempConfigFile"
rm -f "$jsonConfigFile" "$tempConfigFile"

exec "$@"
2 changes: 1 addition & 1 deletion 3.6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 27017
CMD ["mongod", "--bind_ip_all"]
CMD ["mongod"]
22 changes: 17 additions & 5 deletions 3.6/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ _js_escape() {
jq --null-input --arg 'str' "$1" '$str'
}

jsonConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-config.json"
tempConfigFile="${TMPDIR:-/tmp}/docker-entrypoint-temp-config.json"
_parse_config() {
if [ -s "$tempConfigFile" ]; then
Expand All @@ -145,9 +146,8 @@ _parse_config() {
if configPath="$(_mongod_hack_get_arg_val --config "$@")"; then
# if --config is specified, parse it into a JSON file so we can remove a few problematic keys (especially SSL-related keys)
# see https://docs.mongodb.com/manual/reference/configuration-options/
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" \
| jq 'del(.systemLog, .processManagement, .net, .security)' \
> "$tempConfigFile"
mongo --norc --nodb --quiet --eval "load('/js-yaml.js'); printjson(jsyaml.load(cat($(_js_escape "$configPath"))))" > "$jsonConfigFile"
jq 'del(.systemLog, .processManagement, .net, .security)' "$jsonConfigFile" > "$tempConfigFile"
return 0
fi

Expand All @@ -162,7 +162,7 @@ _dbPath() {

if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then
if _parse_config "$@"; then
dbPath="$(jq '.storage.dbPath' "$tempConfigFile")"
dbPath="$(jq '.storage.dbPath' "$jsonConfigFile")"
fi
fi

Expand Down Expand Up @@ -313,9 +313,21 @@ if [ "$originalArgOne" = 'mongod' ]; then
echo
fi

# MongoDB 3.6+ defaults to localhost-only binding
haveBindIp=
if _mongod_hack_have_arg --bind_ip "$@" || _mongod_hack_have_arg --bind_ip_all "$@"; then
haveBindIp=1
elif _parse_config "$@" && jq --exit-status '.net.bindIp // .net.bindIpAll' "$jsonConfigFile" > /dev/null; then
haveBindIp=1
fi
if [ -z "$haveBindIp" ]; then
# so if no "--bind_ip" is specified, let's add "--bind_ip_all"
set -- "$@" --bind_ip_all
fi

unset "${!MONGO_INITDB_@}"
fi

rm -f "$tempConfigFile"
rm -f "$jsonConfigFile" "$tempConfigFile"

exec "$@"