From 1c5e4b17bf53ea840a8703a14b51b7a5b97235e9 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 18 Aug 2018 16:56:45 -0500 Subject: [PATCH] mc: chown /data when it doesn't match $UID Fixes #239 --- minecraft-server/Dockerfile | 3 ++- minecraft-server/start | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 372fc499..ec909451 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -52,7 +52,8 @@ WORKDIR /data ENTRYPOINT [ "/start" ] -ENV JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \ +ENV UID=1000 GID=1000 \ + JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \ TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= LEVEL=world \ PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \ LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= SERVER_PORT=25565 ONLINE_MODE=TRUE CONSOLE=true diff --git a/minecraft-server/start b/minecraft-server/start index 9e4c5f12..6a8c6b8f 100755 --- a/minecraft-server/start +++ b/minecraft-server/start @@ -7,6 +7,12 @@ if [ $(id -u) = 0 ]; then if [[ -v GID ]]; then groupmod -g $GID minecraft fi + + if [[ $(stat -c "%u" /data) != $UID ]]; then + echo "Changing ownership of /data to $UID ..." + chown -R minecraft:minecraft /data + fi + su-exec minecraft:minecraft /start-configuration else exec /start-configuration