From 7da0e6d6520607c99d40cf71a2e4b0a2da0beca9 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 27 Jan 2016 09:41:21 -0800 Subject: [PATCH] Allow arbitrary --user values --- 2.2/docker-entrypoint.sh | 8 +++++--- 2.4/docker-entrypoint.sh | 8 +++++--- 2.6/docker-entrypoint.sh | 8 +++++--- 3.0/docker-entrypoint.sh | 8 +++++--- 3.1/docker-entrypoint.sh | 8 +++++--- 3.2/docker-entrypoint.sh | 8 +++++--- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/2.2/docker-entrypoint.sh b/2.2/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/2.2/docker-entrypoint.sh +++ b/2.2/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@" diff --git a/2.4/docker-entrypoint.sh b/2.4/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/2.4/docker-entrypoint.sh +++ b/2.4/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@" diff --git a/2.6/docker-entrypoint.sh b/2.6/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/2.6/docker-entrypoint.sh +++ b/2.6/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@" diff --git a/3.0/docker-entrypoint.sh b/3.0/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/3.0/docker-entrypoint.sh +++ b/3.0/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@" diff --git a/3.1/docker-entrypoint.sh b/3.1/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/3.1/docker-entrypoint.sh +++ b/3.1/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@" diff --git a/3.2/docker-entrypoint.sh b/3.2/docker-entrypoint.sh index a0eacda24f..caf982b5d6 100755 --- a/3.2/docker-entrypoint.sh +++ b/3.2/docker-entrypoint.sh @@ -5,15 +5,17 @@ if [ "${1:0:1}" = '-' ]; then set -- mongod "$@" fi -if [ "$1" = 'mongod' ]; then +# allow the container to be started with `--user` +if [ "$1" = 'mongod' -a "$(id -u)" = '0' ]; then chown -R mongodb /data/configdb /data/db + exec gosu mongodb "$BASH_SOURCE" "$@" +fi +if [ "$1" = 'mongod' ]; then numa='numactl --interleave=all' if $numa true &> /dev/null; then set -- $numa "$@" fi - - exec gosu mongodb "$@" fi exec "$@"