Skip to content

Commit

Permalink
paper: download default configs before patching
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg committed Jul 20, 2024
1 parent 0ff8e68 commit d49ad2c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/start-deployPaper
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ else

fi

# Download default configs to allow for consistent patching
for c in paper-global.yml paper-world-defaults.yml spigot.yml; do
DOWNLOAD_DEFAULT_CONFIGS+=",${PAPER_CONFIG_DEFAULTS_REPO}/${VERSION}/$c"
done
export DOWNLOAD_DEFAULT_CONFIGS

# Normalize on Spigot for downstream operations
export FAMILY=SPIGOT

Expand Down
4 changes: 4 additions & 0 deletions scripts/start-finalExec
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ patchLog4jConfig() {
canUseRollingLogs=false
}

# Temporarily disable debugging output
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
Expand All @@ -80,6 +83,7 @@ elif isType PURPUR && versionLessThan 1.18.1; then
elif versionLessThan 1.18.1; then
useFallbackJvmFlag=true
fi
eval "$oldState"

if ${useFallbackJvmFlag}; then
JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true ${JVM_OPTS}"
Expand Down
12 changes: 12 additions & 0 deletions scripts/start-setupEnvVariables
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
. "${SCRIPTS:-/}start-utils"

set -e
handleDebugMode

: "${REPLACE_ENV_IN_PLACE:=${REPLACE_ENV_VARIABLES:-false}}"
: "${REPLACE_ENV_PATHS:=/data}"
Expand All @@ -13,6 +14,7 @@ set -e
: "${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS:=}"
: "${PATCH_DEFINITIONS:=}"
: "${DEBUG:=false}"
: "${DOWNLOAD_DEFAULT_CONFIGS:=}"

if isTrue "${REPLACE_ENV_IN_PLACE}"; then
log "Replacing env variables in ${REPLACE_ENV_PATHS} that match the prefix '$REPLACE_ENV_VARIABLE_PREFIX' ..."
Expand All @@ -25,6 +27,16 @@ if isTrue "${REPLACE_ENV_IN_PLACE}"; then
"${REPLACE_ENV_PATHS[@]}"
fi

if [[ $DOWNLOAD_DEFAULT_CONFIGS ]]; then
log "Downloading default configs, if needed"
if ! mc-image-helper mcopy \
--to /data/config \
--skip-existing --skip-up-to-date=false \
"$DOWNLOAD_DEFAULT_CONFIGS" 2> /dev/null; then
log "WARN: one or more default config files were not available from $DOWNLOAD_DEFAULT_CONFIGS"
fi
fi

if [[ ${PATCH_DEFINITIONS} ]]; then
log "Applying patch definitions from ${PATCH_DEFINITIONS}"
mc-image-helper patch \
Expand Down
7 changes: 7 additions & 0 deletions scripts/start-utils
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,17 @@ function compare_version() {
}

function versionLessThan() {
local oldState
# The return status when listing options is zero if all optnames are enabled, non- zero otherwise.
oldState=$(shopt -po xtrace || true)
shopt -u -o xtrace

# Use if-else since strict mode might be enabled
if compare_version "${VERSION}" "lt" "${1?}"; then
eval "$oldState"
return 0
else
eval "$oldState"
return 1
fi
}
Expand Down

0 comments on commit d49ad2c

Please sign in to comment.