mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-10-12 23:17:12 +00:00
1 parent
2d2d683ef5
commit
bb27fd9fef
9 files changed
+630
-7
No files matched your search
@@ -343,6 +343,10 @@ case "${TYPE^^}" in
|
||||
exec "$(dirname "$0")/start-deployNanoLimbo" "$@"
|
||||
;;
|
||||
|
||||
PUMPKIN)
|
||||
exec "$(dirname "$0")/start-deployPumpkin" "$@"
|
||||
;;
|
||||
|
||||
CRUCIBLE)
|
||||
exec "$(dirname "$0")/start-deployCrucible" "$@"
|
||||
;;
|
||||
@@ -363,7 +367,7 @@ case "${TYPE^^}" in
|
||||
logError "Invalid TYPE: '$TYPE'"
|
||||
logError "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FOLIA, PURPUR, FABRIC, QUILT,"
|
||||
logError " SPONGEVANILLA, CUSTOM, MAGMA, MOHIST, GTNH, AIRPLANE, PUFFERFISH,"
|
||||
logError " CANYON, LIMBO, NANOLIMBO, CRUCIBLE, LEAF, YOUER, BANNER, NEOFORGE"
|
||||
logError " CANYON, LIMBO, NANOLIMBO, PUMPKIN, CRUCIBLE, LEAF, YOUER, BANNER, NEOFORGE"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
|
||||
Executable
+159
@@ -0,0 +1,159 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck source=start-utils
|
||||
. "${SCRIPTS:-$(dirname "$0")}/start-utils"
|
||||
set -o pipefail
|
||||
set -e
|
||||
isDebugging && set -x
|
||||
|
||||
# Pumpkin is released as a native executable per platform
|
||||
case "$(uname -m)" in
|
||||
x86_64 | amd64)
|
||||
pumpkinArch=X64
|
||||
;;
|
||||
aarch64 | arm64)
|
||||
pumpkinArch=ARM64
|
||||
;;
|
||||
*)
|
||||
logError "Pumpkin does not provide a Linux build for $(uname -m)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
pumpkinAsset="pumpkin-${pumpkinArch}-Linux"
|
||||
# The Alpine based image needs the musl linked build
|
||||
if [[ $(getDistro) == alpine ]]; then
|
||||
pumpkinAsset+="-musl"
|
||||
fi
|
||||
|
||||
if isTrue "${FORCE_REDOWNLOAD:-false}"; then
|
||||
log "Forcing re-download of ${pumpkinAsset}"
|
||||
rm -f "/data/${pumpkinAsset}"
|
||||
fi
|
||||
|
||||
if ! SERVER=$(mc-image-helper github download-latest-asset \
|
||||
--output-directory=/data \
|
||||
--name-pattern="^${pumpkinAsset}$" \
|
||||
Pumpkin-MC/Pumpkin
|
||||
); then
|
||||
logError "Failed to download ${pumpkinAsset} from the latest Pumpkin release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Using Pumpkin server executable ${SERVER}"
|
||||
if [[ ! -x "${SERVER}" ]]; then
|
||||
chmod +x "${SERVER}"
|
||||
fi
|
||||
|
||||
export SERVER
|
||||
# Native executable, so the final exec skips the JVM handling
|
||||
export FAMILY=NATIVE
|
||||
|
||||
pumpkinConfig=/data/pumpkin.toml
|
||||
|
||||
# Narrow booleans to the values that the patch bool conversion accepts
|
||||
function exportBoolean() {
|
||||
local target=$1
|
||||
local source=$2
|
||||
if [[ -v $source ]]; then
|
||||
local value=false
|
||||
if isTrue "${!source}"; then
|
||||
value=true
|
||||
fi
|
||||
printf -v "$target" '%s' "$value"
|
||||
export "$target"
|
||||
fi
|
||||
}
|
||||
|
||||
function exportInteger() {
|
||||
local target=$1
|
||||
local source=$2
|
||||
if [[ -v $source ]] && isNumeric "${!source}"; then
|
||||
printf -v "$target" '%s' "${!source}"
|
||||
export "$target"
|
||||
fi
|
||||
}
|
||||
|
||||
function normalizeGamemode() {
|
||||
case "${1,,}" in
|
||||
0 | su*) echo Survival ;;
|
||||
1 | c*) echo Creative ;;
|
||||
2 | a*) echo Adventure ;;
|
||||
3 | sp*) echo Spectator ;;
|
||||
*) echo "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function normalizeDifficulty() {
|
||||
case "${1,,}" in
|
||||
0 | p*) echo Peaceful ;;
|
||||
1 | e*) echo Easy ;;
|
||||
2 | n*) echo Normal ;;
|
||||
3 | h*) echo Hard ;;
|
||||
*) echo "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
exportBoolean PUMPKIN_ONLINE_MODE ONLINE_MODE
|
||||
exportBoolean PUMPKIN_HARDCORE HARDCORE
|
||||
exportBoolean PUMPKIN_ALLOW_NETHER ALLOW_NETHER
|
||||
exportBoolean PUMPKIN_FORCE_GAMEMODE FORCE_GAMEMODE
|
||||
exportBoolean PUMPKIN_ENFORCE_WHITELIST ENFORCE_WHITELIST
|
||||
exportBoolean PUMPKIN_ACCEPTS_TRANSFERS ACCEPTS_TRANSFERS
|
||||
exportBoolean PUMPKIN_PREVENT_PROXY_CONNECTIONS PREVENT_PROXY_CONNECTIONS
|
||||
exportBoolean PUMPKIN_PVP PVP
|
||||
exportBoolean PUMPKIN_ENABLE_RCON ENABLE_RCON
|
||||
exportBoolean PUMPKIN_ENABLE_QUERY ENABLE_QUERY
|
||||
exportBoolean PUMPKIN_RESOURCE_PACK_ENFORCE RESOURCE_PACK_ENFORCE
|
||||
|
||||
exportInteger PUMPKIN_MAX_PLAYERS MAX_PLAYERS
|
||||
exportInteger PUMPKIN_VIEW_DISTANCE VIEW_DISTANCE
|
||||
exportInteger PUMPKIN_SIMULATION_DISTANCE SIMULATION_DISTANCE
|
||||
exportInteger PUMPKIN_OP_PERMISSION_LEVEL OP_PERMISSION_LEVEL
|
||||
exportInteger PUMPKIN_SPAWN_PROTECTION SPAWN_PROTECTION
|
||||
|
||||
if [[ -v MODE ]]; then
|
||||
PUMPKIN_GAMEMODE=$(normalizeGamemode "$MODE")
|
||||
export PUMPKIN_GAMEMODE
|
||||
fi
|
||||
|
||||
if [[ -v DIFFICULTY ]]; then
|
||||
PUMPKIN_DIFFICULTY=$(normalizeDifficulty "$DIFFICULTY")
|
||||
export PUMPKIN_DIFFICULTY
|
||||
fi
|
||||
|
||||
# The image enables the whitelist whenever one is provided
|
||||
if [[ -v WHITELIST || -v WHITELIST_FILE ]]; then
|
||||
export PUMPKIN_WHITE_LIST=true
|
||||
else
|
||||
exportBoolean PUMPKIN_WHITE_LIST ENABLE_WHITELIST
|
||||
fi
|
||||
|
||||
if [[ -v RESOURCE_PACK ]]; then
|
||||
export PUMPKIN_RESOURCE_PACK_ENABLED=true
|
||||
fi
|
||||
|
||||
# Only override the listening addresses when a port was declared
|
||||
if [[ -v SERVER_PORT ]]; then
|
||||
export PUMPKIN_JAVA_ADDRESS="0.0.0.0:${SERVER_PORT}"
|
||||
fi
|
||||
if [[ -v RCON_PORT ]]; then
|
||||
export PUMPKIN_RCON_ADDRESS="0.0.0.0:${RCON_PORT}"
|
||||
fi
|
||||
if [[ -v QUERY_PORT ]]; then
|
||||
export PUMPKIN_QUERY_ADDRESS="0.0.0.0:${QUERY_PORT}"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$pumpkinConfig" ]]; then
|
||||
log "Creating initial Pumpkin configuration"
|
||||
cp /image/pumpkin.toml "$pumpkinConfig"
|
||||
fi
|
||||
|
||||
log "Applying Pumpkin configuration from environment variables"
|
||||
# Undeclared variables only warn, so only surface failures
|
||||
if ! pumpkinPatchResult=$(mc-image-helper patch --patch-env-prefix "" /image/pumpkin-config-patch.json 2>&1); then
|
||||
logWarning "Failed to apply one or more settings to ${pumpkinConfig}"
|
||||
echo "$pumpkinPatchResult" | applyLogPrefix
|
||||
fi
|
||||
|
||||
exec "$(dirname "$0")/start-setupWorld" "$@"
|
||||
+38
-6
@@ -91,7 +91,9 @@ oldState=$(shopt -po xtrace || true)
|
||||
shopt -u -o xtrace
|
||||
# Patch Log4j remote code execution vulnerability
|
||||
# See https://www.minecraft.net/en-us/article/important-message--security-vulnerability-java-edition
|
||||
if versionLessThan 1.7; then
|
||||
if isFamily NATIVE; then
|
||||
: # Native server, so there is no log4j to patch
|
||||
elif versionLessThan 1.7; then
|
||||
: # No patch required here.
|
||||
elif isFamily VANILLA && versionLessThan 1.12; then
|
||||
patchLog4jConfig log4j2_17-111.xml https://launcher.mojang.com/v1/objects/dd2b723346a8dcd48e7f4d245f6bf09e98db9696/log4j2_17-111.xml
|
||||
@@ -111,7 +113,9 @@ if ${useFallbackJvmFlag}; then
|
||||
JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true ${JVM_OPTS}"
|
||||
fi
|
||||
|
||||
if versionLessThan 1.7; then
|
||||
if isFamily NATIVE; then
|
||||
: # Native server, so no Log4jPatcher agent
|
||||
elif versionLessThan 1.7; then
|
||||
: # No patch required here.
|
||||
elif versionLessThan 1.18.1; then
|
||||
if isTrue "${SKIP_LOG4J_PATCHER:-false}"; then
|
||||
@@ -123,7 +127,9 @@ fi
|
||||
|
||||
# Set up log4j2 configuration with templating support
|
||||
LOGFILE="${SERVER_DIR}/log4j2.xml"
|
||||
if ${useGeneratedLogs}; then
|
||||
if isFamily NATIVE; then
|
||||
: # Native server, so no log4j configuration
|
||||
elif ${useGeneratedLogs}; then
|
||||
# Set up log configuration defaults
|
||||
: "${LOG_LEVEL:=info}"
|
||||
: "${ROLLING_LOG_MAX_FILES:=1000}"
|
||||
@@ -195,12 +201,12 @@ else
|
||||
fi
|
||||
|
||||
# Optional disable console
|
||||
if versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
|
||||
if ! isFamily NATIVE && versionLessThan 1.14 && [[ ${CONSOLE,,} = false ]]; then
|
||||
EXTRA_ARGS+=" --noconsole"
|
||||
fi
|
||||
|
||||
# Optional disable GUI for headless servers
|
||||
if [[ ${GUI,,} = false ]]; then
|
||||
if ! isFamily NATIVE && [[ ${GUI,,} = false ]]; then
|
||||
EXTRA_ARGS+=" nogui"
|
||||
fi
|
||||
|
||||
@@ -472,7 +478,10 @@ function copyFilesForCurseForge() {
|
||||
cp -f ${baseDataDir}/eula.txt "${FTB_DIR}/"
|
||||
}
|
||||
|
||||
if versionLessThan 'b1.8'; then
|
||||
if isFamily NATIVE; then
|
||||
# Native server, always probed with the modern server list ping
|
||||
rm -f "$mcHealthEnvPath"
|
||||
elif versionLessThan 'b1.8'; then
|
||||
echo "
|
||||
DISABLE_HEALTHCHECK=true
|
||||
" > "$mcHealthEnvPath"
|
||||
@@ -601,6 +610,29 @@ elif [[ $SERVER =~ run.sh ]]; then
|
||||
set -x
|
||||
fi
|
||||
exec ${SERVER_RUNNER} "${mcServerRunnerArgs[@]}" --shell bash -- "${SERVER}" $EXTRA_ARGS
|
||||
elif isFamily NATIVE; then
|
||||
# Native server, so no JVM arguments
|
||||
if [[ ! -x "$SERVER" ]]; then
|
||||
log "Making $SERVER executable"
|
||||
if ! chmod +x "$SERVER"; then
|
||||
logError "Failed to make $SERVER executable"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if isTrue "${SETUP_ONLY}"; then
|
||||
echo "SETUP_ONLY: ${SERVER}"
|
||||
exit
|
||||
fi
|
||||
|
||||
runPreStartScript
|
||||
if isTrue "${DEBUG_EXEC}"; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
log "Starting the Minecraft server..."
|
||||
# shellcheck disable=SC2086
|
||||
exec ${SERVER_RUNNER} ${bootstrapArgs} "${mcServerRunnerArgs[@]}" -- "${SERVER}" "$@" $EXTRA_ARGS
|
||||
else
|
||||
# If we have a bootstrap.txt file... feed that in to the server stdin
|
||||
if [ -f $bootstrapPath ]; then
|
||||
|
||||
Reference in new issue
Block a user