From 111883e0d54f36105cc1353deb60ec9b4bdec91c Mon Sep 17 00:00:00 2001 From: Everett Toews Date: Sat, 28 Nov 2015 22:11:01 -0600 Subject: [PATCH] Whitelist players --- minecraft-server/README.md | 10 +++++++++- minecraft-server/start-minecraft.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 15537a1c..3e57f472 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -170,6 +170,14 @@ Valid values are: `peaceful`, `easy`, `normal`, and `hard`, and an error message will be output in the logs if it's not one of these values. +### Whitelist Players + +To whitelist players for your Minecraft server, pass the Minecraft usernames separated by commas via the `WHITELIST` environment variable, such as + + docker run -d -e WHITELIST=user1,user2 ... + +If the `WHITELIST` environment variable is not used, any user can join your Minecraft server if it's publicly accessible. + ### Op/Administrator Players 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 @@ -233,7 +241,7 @@ be configured by setting `LEVEL_TYPE` to Descriptions are available at the [gamepedia](http://minecraft.gamepedia.com/Server.properties). When using a level type of `FLAT` and `CUSTOMIZED`, you can further configure the world generator -by passing [custom generator settings](http://minecraft.gamepedia.com/Superflat). +by passing [custom generator settings](http://minecraft.gamepedia.com/Superflat). **Since generator settings usually have ;'s in them, surround the -e value with a single quote, like below.** For example (just the `-e` bits): diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 9dc50489..243fb38a 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -58,7 +58,7 @@ case $TYPE in RECOMMENDED) FORGE_VERSION=`wget -O - http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json | jsawk -n "out(this.promos['$norm-recommended'])"` ;; - + *) FORGE_VERSION=$FORGEVERSION ;; @@ -89,6 +89,10 @@ esac if [ ! -e server.properties ]; then cp /tmp/server.properties . + if [ -n "$WHITELIST" ]; then + sed -i "/whitelist\s*=/ c whitelist=true" /data/server.properties + fi + if [ -n "$MOTD" ]; then sed -i "/motd\s*=/ c motd=$MOTD" /data/server.properties fi @@ -171,6 +175,10 @@ if [ -n "$OPS" -a ! -e ops.txt.converted ]; then echo $OPS | awk -v RS=, '{print}' >> ops.txt fi +if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then + echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt +fi + if [ -n "$ICON" -a ! -e server-icon.png ]; then echo "Using server icon from $ICON..." # Not sure what it is yet...call it "img"