Skip to content

Commit d7c6a7d

Browse files
authored
paper: download default configs before patching (#3004)
1 parent 0ff8e68 commit d7c6a7d

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

scripts/start-deployPaper

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ else
5252

5353
fi
5454

55+
# Download default configs to allow for consistent patching
56+
for c in paper-global.yml paper-world-defaults.yml spigot.yml; do
57+
DOWNLOAD_DEFAULT_CONFIGS+=",${PAPER_CONFIG_DEFAULTS_REPO}/${VERSION}/$c"
58+
done
59+
export DOWNLOAD_DEFAULT_CONFIGS
60+
5561
# Normalize on Spigot for downstream operations
5662
export FAMILY=SPIGOT
5763

scripts/start-finalExec

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ patchLog4jConfig() {
6464
canUseRollingLogs=false
6565
}
6666

67+
# Temporarily disable debugging output
68+
oldState=$(shopt -po xtrace || true)
69+
shopt -u -o xtrace
6770
# Patch Log4j remote code execution vulnerability
6871
# See https://www.minecraft.net/en-us/article/important-message--security-vulnerability-java-edition
6972
if versionLessThan 1.7; then
@@ -80,6 +83,7 @@ elif isType PURPUR && versionLessThan 1.18.1; then
8083
elif versionLessThan 1.18.1; then
8184
useFallbackJvmFlag=true
8285
fi
86+
eval "$oldState"
8387

8488
if ${useFallbackJvmFlag}; then
8589
JVM_OPTS="-Dlog4j2.formatMsgNoLookups=true ${JVM_OPTS}"

scripts/start-setupEnvVariables

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
. "${SCRIPTS:-/}start-utils"
55

66
set -e
7+
handleDebugMode
78

89
: "${REPLACE_ENV_IN_PLACE:=${REPLACE_ENV_VARIABLES:-false}}"
910
: "${REPLACE_ENV_PATHS:=/data}"
@@ -13,6 +14,7 @@ set -e
1314
: "${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS:=}"
1415
: "${PATCH_DEFINITIONS:=}"
1516
: "${DEBUG:=false}"
17+
: "${DOWNLOAD_DEFAULT_CONFIGS:=}"
1618

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

30+
if [[ $DOWNLOAD_DEFAULT_CONFIGS ]]; then
31+
log "Downloading default configs, if needed"
32+
if ! mc-image-helper mcopy \
33+
--to /data/config \
34+
--skip-existing --skip-up-to-date=false \
35+
"$DOWNLOAD_DEFAULT_CONFIGS" 2> /dev/null; then
36+
log "WARN: one or more default config files were not available from $DOWNLOAD_DEFAULT_CONFIGS"
37+
fi
38+
fi
39+
2840
if [[ ${PATCH_DEFINITIONS} ]]; then
2941
log "Applying patch definitions from ${PATCH_DEFINITIONS}"
3042
mc-image-helper patch \

scripts/start-utils

+7
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,17 @@ function compare_version() {
265265
}
266266

267267
function versionLessThan() {
268+
local oldState
269+
# The return status when listing options is zero if all optnames are enabled, non- zero otherwise.
270+
oldState=$(shopt -po xtrace || true)
271+
shopt -u -o xtrace
272+
268273
# Use if-else since strict mode might be enabled
269274
if compare_version "${VERSION}" "lt" "${1?}"; then
275+
eval "$oldState"
270276
return 0
271277
else
278+
eval "$oldState"
272279
return 1
273280
fi
274281
}

0 commit comments

Comments
 (0)