From c95b638faaeea60905b070ebce03ec348ce1123e Mon Sep 17 00:00:00 2001 From: Harrison Black Date: Mon, 18 May 2026 21:59:23 +1000 Subject: [PATCH] feat: Server library cleanup on paper install (#4046) --- docs/configuration/misc-options.md | 6 ++++++ scripts/start-deployPaper | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/configuration/misc-options.md b/docs/configuration/misc-options.md index f9676d10..da5d6888 100644 --- a/docs/configuration/misc-options.md +++ b/docs/configuration/misc-options.md @@ -22,6 +22,12 @@ docker run -d --pull=always \ -p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server ``` +## Clean server libraries + +By default, supported server types remove stale server libraries during installation by setting `CLEAN_SERVER_LIBRARIES` to `true`. Set `CLEAN_SERVER_LIBRARIES` to `false` to disable this cleanup if it causes unexpected behavior. + +Currently, library cleanup is supported by `TYPE=PAPER`. Other server jar types are not yet supported. + ## Running as alternate user/group ID By default, the container will switch to and run the Minecraft server as user ID 1000 and group ID 1000; however, that can be changed by setting the environment variables `UID` and `GID`. diff --git a/scripts/start-deployPaper b/scripts/start-deployPaper index 07919f8a..9907d4a3 100755 --- a/scripts/start-deployPaper +++ b/scripts/start-deployPaper @@ -11,17 +11,26 @@ handleDebugMode : "${PAPER_DOWNLOAD_URL:=}" : "${PAPER_CUSTOM_JAR:=}" : "${PAPER_CONFIG_DEFAULTS_REPO:=${PAPER_CONFIG_REPO:=https://raw.githubusercontent.com/Shonz1/minecraft-default-configs/main}}" +: "${CLEAN_SERVER_LIBRARIES:=true}" resultsFile=/data/.paper.env if [[ $PAPER_CUSTOM_JAR ]]; then export SERVER="$PAPER_CUSTOM_JAR" elif [[ $PAPER_DOWNLOAD_URL ]]; then - if ! mc-image-helper install-paper \ - --output-directory=/data \ - --results-file="$resultsFile" \ - --url="$PAPER_DOWNLOAD_URL"; then - logError "Failed to download from custom PaperMC URL" - exit 1 + + args=( + --output-directory=/data + --results-file="$resultsFile" + --url="$PAPER_DOWNLOAD_URL" + ) + + if [[ $CLEAN_SERVER_LIBRARIES ]]; then + args+=(--clean-libraries) + fi + + if ! mc-image-helper install-paper "${args[@]}"; then + logError "Failed to download from custom PaperMC URL" + exit 1 fi applyResultsFile ${resultsFile} else @@ -35,6 +44,11 @@ else if [[ $PAPER_BUILD ]]; then args+=(--build="$PAPER_BUILD") fi + + if [[ $CLEAN_SERVER_LIBRARIES ]]; then + args+=(--clean-libraries) + fi + if ! mc-image-helper install-paper "${args[@]}"; then logError "Failed to download $PAPER_PROJECT" exit 1