Added CUSTOM_JAR_EXEC (#2253)

This commit is contained in:
Geoff Bourne
2023-06-24 11:38:15 -05:00
committed by GitHub
parent 0bcd72cb0d
commit bb472eb8b7
3 changed files with 42 additions and 5 deletions
@@ -48,3 +48,21 @@ Configuration options with defaults:
- `CRUCIBLE_RELEASE`=latest - `CRUCIBLE_RELEASE`=latest
Crucible is only available for 1.7.10, so be sure to set `VERSION=1.7.10`. 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 <classpath> <classname>`" or "`-jar <jar file>`" 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"
+11 -4
View File
@@ -1,18 +1,22 @@
#!/bin/bash #!/bin/bash
: "${CUSTOM_SERVER:=}"
: "${GENERIC_PACK:=}"
: "${CUSTOM_JAR_EXEC:=}"
# shellcheck source=start-utils # shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils" . "${SCRIPTS:-/}start-utils"
isDebugging && set -x isDebugging && set -x
if isURL ${CUSTOM_SERVER}; then if isURL "${CUSTOM_SERVER}"; then
filename=$(basename ${CUSTOM_SERVER}) filename=$(basename "${CUSTOM_SERVER}")
export SERVER=/data/${filename} export SERVER=/data/${filename}
if [[ -f ${SERVER} ]] || [ -n "$FORCE_REDOWNLOAD" ]; then if [[ -f ${SERVER} ]] || [ -n "$FORCE_REDOWNLOAD" ]; then
log "Using previously downloaded jar at ${SERVER}" log "Using previously downloaded jar at ${SERVER}"
else else
log "Downloading custom server jar from ${CUSTOM_SERVER} ..." 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}" log "Failed to download from ${CUSTOM_SERVER}"
exit 2 exit 2
fi fi
@@ -25,6 +29,9 @@ elif [[ ${GENERIC_PACK} ]]; then
log "Using custom server jar from generic pack at ${CUSTOM_SERVER} ..." log "Using custom server jar from generic pack at ${CUSTOM_SERVER} ..."
export SERVER=${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 else
log "CUSTOM_SERVER is not properly set to a URL or existing jar file" log "CUSTOM_SERVER is not properly set to a URL or existing jar file"
exit 2 exit 2
@@ -34,4 +41,4 @@ fi
# Allow for overriding Family on custom for testing. # Allow for overriding Family on custom for testing.
export FAMILY="${FAMILY:-HYBRID}" export FAMILY="${FAMILY:-HYBRID}"
exec ${SCRIPTS:-/}start-setupWorld $@ exec "${SCRIPTS:-/}start-setupWorld" "$@"
+13 -1
View File
@@ -2,6 +2,7 @@
: "${DEBUG_EXEC:=false}" : "${DEBUG_EXEC:=false}"
: "${SETUP_ONLY:=false}" : "${SETUP_ONLY:=false}"
: "${CUSTOM_JAR_EXEC:=}"
# shellcheck source=start-utils # shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils" . "${SCRIPTS:-/}start-utils"
@@ -295,12 +296,23 @@ else
log "Starting the Minecraft server..." log "Starting the Minecraft server..."
# Specifically want the variables to expand to args, so...
# shellcheck disable=SC2206 # shellcheck disable=SC2206
finalArgs=( finalArgs=(
$JVM_XX_OPTS $JVM_XX_OPTS
$JVM_OPTS $JVM_OPTS
$expandedDOpts $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 "$@" $EXTRA_ARGS
) )