diff --git a/scripts/start-deployPaper b/scripts/start-deployPaper index 53baad26360..eaed0e11b4a 100755 --- a/scripts/start-deployPaper +++ b/scripts/start-deployPaper @@ -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 diff --git a/scripts/start-finalExec b/scripts/start-finalExec index cdfdfbea44a..f180d5f0e08 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -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 @@ -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}" diff --git a/scripts/start-setupEnvVariables b/scripts/start-setupEnvVariables index 5feb0a7f45e..fe343a43922 100755 --- a/scripts/start-setupEnvVariables +++ b/scripts/start-setupEnvVariables @@ -4,6 +4,7 @@ . "${SCRIPTS:-/}start-utils" set -e +handleDebugMode : "${REPLACE_ENV_IN_PLACE:=${REPLACE_ENV_VARIABLES:-false}}" : "${REPLACE_ENV_PATHS:=/data}" @@ -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' ..." @@ -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 \ diff --git a/scripts/start-utils b/scripts/start-utils index 9649ed971f5..eca96855a1f 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -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 }