diff --git a/minecraft-server/README.md b/minecraft-server/README.md index e9da676e..6f1fbf80 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -402,6 +402,15 @@ Just change it with `SPONGEBRANCH`, such as: $ docker run -d -v /path/on/host:/data ... \ -e TYPE=SPONGEVANILLA -e SPONGEBRANCH=EXPERIMENTAL ... +## Running with a custom server JAR + +If you would like to run a custom server JAR, set `-e TYPE=CUSTOM` and pass the custom server +JAR via `CUSTOM_SERVER`. It can either be a URL or a container path to an existing JAR file. + +If it is a URL, it will only be downloaded into the `/data` directory if it wasn't already. As +such, if you need to upgrade or re-download the JAR, then you will need to stop the container, +remove the file from the container's `/data` directory, and start again. + ## Using Docker Compose Rather than type the server options below, the port mappings above, etc diff --git a/minecraft-server/start-configuration b/minecraft-server/start-configuration index 348f1b3c..30cd289f 100755 --- a/minecraft-server/start-configuration +++ b/minecraft-server/start-configuration @@ -89,6 +89,10 @@ case "${TYPE^^}" in exec /start-deploySpongeVanilla $@ ;; + CUSTOM) + exec /start-deployCustom $@ + ;; + *) echo "Invalid type: '$TYPE'" echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA" diff --git a/minecraft-server/start-deployCustom b/minecraft-server/start-deployCustom new file mode 100644 index 00000000..bf9304e3 --- /dev/null +++ b/minecraft-server/start-deployCustom @@ -0,0 +1,29 @@ +#!/bin/bash + +. /start-utils + +if isURL ${CUSTOM_SERVER}; then + filename=$(basename ${CUSTOM_SERVER}) + export SERVER=/data/${filename} + + if [[ -f ${SERVER} ]]; then + echo "Using previously downloaded jar at ${SERVER}" + else + echo "Downloading custom server jar from ${CUSTOM_SERVER} ..." + if ! curl -sSL -o ${SERVER} ${CUSTOM_SERVER}; then + echo "Failed to download from ${CUSTOM_SERVER}" + exit 2 + fi + fi + +elif [[ -f ${CUSTOM_SERVER} ]]; then + echo "Using custom server jar at ${CUSTOM_SERVER} ..." + export SERVER=${CUSTOM_SERVER} + +else + echo "CUSTOM_SERVER is not properly set to a URL or existing jar file" + exit 2 +fi + +# Continue to Final Setup +exec /start-finalSetup01World $@