From 77541a968945084d00fa6f348dd8d30b8490cb02 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 20 Sep 2014 14:10:48 +0000 Subject: [PATCH] Added support adding 'op' users * Non-destructive MOTD setting --- minecraft-server/.gitignore | 1 + minecraft-server/README.md | 73 ++++++++++++++++++------------ minecraft-server/server.properties | 2 +- minecraft-server/start.sh | 11 ++++- 4 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 minecraft-server/.gitignore diff --git a/minecraft-server/.gitignore b/minecraft-server/.gitignore new file mode 100644 index 00000000..82f0c3ac --- /dev/null +++ b/minecraft-server/.gitignore @@ -0,0 +1 @@ +/data/ diff --git a/minecraft-server/README.md b/minecraft-server/README.md index d65bfd27..8a25923b 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -1,42 +1,57 @@ -This docker image provides a Minecraft Server that will automatically download the latest stable, latest snapshot, or any specific server version. - +This docker image provides a Minecraft Server that will automatically download the latest stable, latest snapshot, or any specif + To simply use the latest stable version, run - + docker run -d -p 25565:25565 itzg/minecraft-server - + where the default server port, 25565, will be exposed on your host machine. - + +## EULA Support + Mojang now requires accepting the [Minecraft EULA](https://account.mojang.com/documents/minecraft_eula). To accept add - - -e EULA=TRUE - -such as - - docker run -e EULA=TRUE -d -p 25565:25565 itzg/minecraft-server - - -In order to persist the Minecraft data, which you *probably want to do for a real server setup*, use the `-v` argument to map a local path to the `/data' path in the container, + + -e EULA=TRUE + +such as + + docker run -e EULA=TRUE -d -p 25565:25565 itzg/minecraft-server + +## Attaching data directory to host filesystem + +In order to persist the Minecraft data, which you *probably want to do for a real server setup*, use the `-v` argument to map a - docker run -d -v /path/on/host:/data -p 25565:25565 itzg/minecraft-server + docker run -d -v /path/on/host:/data -p 25565:25565 itzg/minecraft-server + +When attached in this way you can stop the server, edit the configuration under your attached `/path/on/host` and start the server again with `docker start CONTAINERID` to pick up the new configuration. +## Versions + To use a different Minecraft version, pass the `VERSION` environment variable, which can have the value -* LATEST +* LATEST * SNAPSHOT -* (or a specific version, such as "1.7.9") - -For example, to use the latest snapshot: - - docker run -d -e VERSION=SNAPSHOT ... - -or a specific version: +* (or a specific version, such as "1.7.9") + +For example, to use the latest snapshot: + + docker run -d -e VERSION=SNAPSHOT ... - docker run -d -e VERSION=1.7.9 ... +or a specific version: + docker run -d -e VERSION=1.7.9 ... + +## Server configuration + The message of the day, shown below each server entry in the UI, can be changed with the `MOTD` environment variable, such as - - docker run -d -e 'MOTD=My Server' ... - -The Java memory limit can be adjusted using the `JVM_OPTS` environment variable, where the default is + + docker run -d -e 'MOTD=My Server' ... + +If you leave it off, the last used or default message will be used. + +To add more "op" (aka adminstrator) users to your Minecraft server, pass the Minecraft usernames separated by commas via the `OPS` environment variable, such as + + docker run -d -e OPS=user1,user2 ... + +The Java memory limit can be adjusted using the `JVM_OPTS` environment variable, where the default is the setting shown in the example (max and min at 1024 MB): - + docker run -e 'JVM_OPTS=-Xmx1024M -Xms1024M' ... diff --git a/minecraft-server/server.properties b/minecraft-server/server.properties index c81be72a..0d7f77da 100644 --- a/minecraft-server/server.properties +++ b/minecraft-server/server.properties @@ -29,5 +29,5 @@ spawn-monsters=true generate-structures=true view-distance=10 spawn-protection=16 -motd=A Minecraft Server +motd=A Minecraft Server powered by Docker diff --git a/minecraft-server/start.sh b/minecraft-server/start.sh index 1fe0f20b..e90fd202 100755 --- a/minecraft-server/start.sh +++ b/minecraft-server/start.sh @@ -21,8 +21,15 @@ if [ ! -e server.properties ]; then cp /tmp/server.properties . fi -sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties -sed -i "/level-name\s*=/ c level-name=$LEVEL" /data/server.properties +if [ -n "$MOTD" ]; then + sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties +fi +if [ -n "$LEVEL" ]; then + sed -i "/level-name\s*=/ c level-name=$LEVEL" /data/server.properties +fi +if [ -n "$OPS" ]; then + echo $OPS | awk -v RS=, '{print}' >> ops.txt +fi if [ ! -e /data/eula.txt ]; then if [ "$EULA" != "" ]; then