From b5bcea7d6184d76ee37227d464a2649563438a9d Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 10 Sep 2016 08:22:30 -0500 Subject: [PATCH] [mc] Add SKIP_OWNERSHIP_FIX option For #104 --- minecraft-server/README.md | 6 +++++- minecraft-server/start.sh | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 16a20329..ab2e0e26 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -543,7 +543,7 @@ By default, server checks connecting players against Minecraft's account databas docker run -d -e ONLINE_MODE=FALSE ... -## JVM Configuration +## Miscellaneous Options ### Memory Limit @@ -551,3 +551,7 @@ The Java memory limit can be adjusted using the `JVM_OPTS` environment variable, the setting shown in the example (max and min at 1024 MB): docker run -e 'JVM_OPTS=-Xmx1024M -Xms1024M' ... + +### /data ownership + +In order to adapt to differences in `UID` and `GID` settings the entry script will attempt to correct ownership and writability of the `/data` directory. This logic can be disabled by setting `-e SKIP_OWNERSHIP_FIX=TRUE`. diff --git a/minecraft-server/start.sh b/minecraft-server/start.sh index 65ba4275..c3d2e4c2 100755 --- a/minecraft-server/start.sh +++ b/minecraft-server/start.sh @@ -4,17 +4,19 @@ set -e usermod --uid $UID minecraft groupmod --gid $GID minecraft -fix_ownership() { - dir=$1 - if ! sudo -u minecraft test -w $dir; then - echo "Correcting writability of $dir ..." - chown -R minecraft:minecraft $dir - chmod -R u+w $dir - fi -} +if [ "$SKIP_OWNERSHIP_FIX" != "TRUE" ]; then + fix_ownership() { + dir=$1 + if ! sudo -u minecraft test -w $dir; then + echo "Correcting writability of $dir ..." + chown -R minecraft:minecraft $dir + chmod -R u+w $dir + fi + } -fix_ownership /data -fix_ownership /home/minecraft + fix_ownership /data + fix_ownership /home/minecraft +fi echo "Switching to user 'minecraft'" exec sudo -E -u minecraft /start-minecraft "$@"