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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 5 deletions

View File

@ -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 <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"

View File

@ -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" "$@"

View File

@ -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
)