From 5c89ecbb523590474fdc75f7f479f476d40fac6c Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 24 Jun 2023 09:27:52 -0500 Subject: [PATCH 1/2] Added CUSTOM_JAR_EXEC --- scripts/start-finalExec | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 220bb6abc26..ea01be9c673 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -2,6 +2,7 @@ : "${DEBUG_EXEC:=false}" : "${SETUP_ONLY:=false}" +: "${CUSTOM_JAR_EXEC:=}" # shellcheck source=start-utils . "${SCRIPTS:-/}start-utils" @@ -295,12 +296,23 @@ else log "Starting the Minecraft server..." + # Specifically want the variables to expand to args, so... # shellcheck disable=SC2206 finalArgs=( $JVM_XX_OPTS $JVM_OPTS $expandedDOpts - -jar "$SERVER" + ) + + if [[ $CUSTOM_JAR_EXEC ]]; then + # shellcheck disable=SC2206 + finalArgs+=($CUSTOM_JAR_EXEC) + else + finalArgs+=(-jar "$SERVER") + fi + + # shellcheck disable=SC2206 + finalArgs+=( "$@" $EXTRA_ARGS ) From fae0c57859fa3a65eff1e5f1630558880a3e56ce Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 24 Jun 2023 10:30:37 -0500 Subject: [PATCH 2/2] Docs and option to not use CUSTOM_SERVER --- .../types-and-platforms/server-types/others.md | 18 ++++++++++++++++++ scripts/start-deployCustom | 15 +++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/types-and-platforms/server-types/others.md b/docs/types-and-platforms/server-types/others.md index bf3e48d0425..33e0a8723c0 100644 --- a/docs/types-and-platforms/server-types/others.md +++ b/docs/types-and-platforms/server-types/others.md @@ -48,3 +48,21 @@ Configuration options with defaults: - `CRUCIBLE_RELEASE`=latest Crucible is only available for 1.7.10, so be sure to set `VERSION=1.7.10`. + +## Custom + +To use a custom server jar or class files, set `TYPE` to "CUSTOM" and continue with one of the following options: + +The custom jar to be used can be set with `CUSTOM_SERVER` as either a URL to download or the path to a file within the container. + +Alternatively, the final `-jar` invocation can be replaced by setting `CUSTOM_JAR_EXEC` to "`-cp `" or "`-jar `" form, such as + +``` +-cp worldedit.jar:Carpet-Server.jar net.minecraft.server.MinecraftServer +``` + +!!! note + + When using `docker run` make sure to quote the entire value since it has spaces in it, such as + + -e CUSTOM_JAR_EXEC="-cp worldedit.jar:Carpet-Server.jar net.minecraft.server.MinecraftServer" \ No newline at end of file diff --git a/scripts/start-deployCustom b/scripts/start-deployCustom index 16dc7ecfe98..c2f9622190c 100755 --- a/scripts/start-deployCustom +++ b/scripts/start-deployCustom @@ -1,18 +1,22 @@ #!/bin/bash +: "${CUSTOM_SERVER:=}" +: "${GENERIC_PACK:=}" +: "${CUSTOM_JAR_EXEC:=}" + # shellcheck source=start-utils . "${SCRIPTS:-/}start-utils" isDebugging && set -x -if isURL ${CUSTOM_SERVER}; then - filename=$(basename ${CUSTOM_SERVER}) +if isURL "${CUSTOM_SERVER}"; then + filename=$(basename "${CUSTOM_SERVER}") export SERVER=/data/${filename} if [[ -f ${SERVER} ]] || [ -n "$FORCE_REDOWNLOAD" ]; then log "Using previously downloaded jar at ${SERVER}" else log "Downloading custom server jar from ${CUSTOM_SERVER} ..." - if ! curl -sSL -o ${SERVER} ${CUSTOM_SERVER}; then + if ! curl -sSL -o "${SERVER}" "${CUSTOM_SERVER}"; then log "Failed to download from ${CUSTOM_SERVER}" exit 2 fi @@ -25,6 +29,9 @@ elif [[ ${GENERIC_PACK} ]]; then log "Using custom server jar from generic pack at ${CUSTOM_SERVER} ..." export SERVER=${CUSTOM_SERVER} +elif [[ ${CUSTOM_JAR_EXEC} ]]; then + log "CUSTOM_JAR_EXEC is in use, so \$SERVER will not be set" + else log "CUSTOM_SERVER is not properly set to a URL or existing jar file" exit 2 @@ -34,4 +41,4 @@ fi # Allow for overriding Family on custom for testing. export FAMILY="${FAMILY:-HYBRID}" -exec ${SCRIPTS:-/}start-setupWorld $@ +exec "${SCRIPTS:-/}start-setupWorld" "$@"