[mc] Add SKIP_OWNERSHIP_FIX option

For #104
This commit is contained in:
Geoff Bourne
2016-09-10 08:22:30 -05:00
parent 76d4fd1bbc
commit b5bcea7d61
2 changed files with 17 additions and 11 deletions

View File

@@ -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`.

View File

@@ -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 "$@"