From 9fa27b9a3d49f789b78dc3062da7f288ba1f7ac4 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 1 Jan 2016 12:39:43 -0600 Subject: [PATCH] [mc] Adding MODPACK download option similar to WORLD --- minecraft-server/Dockerfile | 2 +- minecraft-server/README.md | 11 +++++++++++ minecraft-server/start-minecraft.sh | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 9d8c84b5..4120dd9b 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -36,4 +36,4 @@ ENV UID=1000 ENV MOTD A Minecraft Server Powered by Docker ENV JVM_OPTS -Xmx1024M -Xms1024M ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \ - LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= + LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= WORLD= MODPACK= diff --git a/minecraft-server/README.md b/minecraft-server/README.md index 88a41392..bc80e7f6 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -301,6 +301,17 @@ will be deleted when the container is deleted. you should use an IP address or a globally resolveable FQDN, or else the name of a linked container. +### Downloadable mod pack + +Like the `WORLD` option above, you can specify the URL of a "mod pack" +to download and install into the `mods` directory. To use this option +pass the environment variable `MODPACK`, such as + + docker run -d -e MODPACK=http://www.example.com/mods/modpack.zip ... + +**NOTE:** The referenced URL must be a zip file with one or more Forge jar files at the +top level of the zip archive. + ## JVM Configuration ### Memory Limit diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 92513ab0..d7738344 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -90,6 +90,7 @@ case "$TYPE" in esac # If supplied with a URL for a world, download it and unpack +if [[ "$WORLD" ]]; then case "X$WORLD" in X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) echo "Downloading world via HTTP" @@ -113,6 +114,24 @@ case "X$WORLD" in echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file" ;; esac +fi + +# If supplied with a URL for a modpack (simple zip of jars), download it and unpack +if [[ "$MODPACK" ]]; then +case "X$MODPACK" in + X[Hh][Tt][Tt][Pp]*[Zz][iI][pP]) + echo "Downloading mod pack via HTTP" + echo "$MODPACK" + mkdir -p /data/mods + wget -q -O /tmp/modpack.zip "$MODPACK" + unzip -d /data/mods /tmp/modpack.zip + rm -f /tmp/modpack.zip + ;; + *) + echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file" + ;; +esac +fi if [ ! -e server.properties ]; then cp /tmp/server.properties .