Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CUSTOM_JAR_EXEC #2253

Merged
merged 2 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/types-and-platforms/server-types/others.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 11 additions & 4 deletions scripts/start-deployCustom
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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" "$@"
14 changes: 13 additions & 1 deletion scripts/start-finalExec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

: "${DEBUG_EXEC:=false}"
: "${SETUP_ONLY:=false}"
: "${CUSTOM_JAR_EXEC:=}"

# shellcheck source=start-utils
. "${SCRIPTS:-/}start-utils"
Expand Down Expand Up @@ -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
)

Expand Down
Loading