From 732581e18c94c38924271f658e9989424de84ef4 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 29 Jul 2022 20:01:19 -0500 Subject: [PATCH] Allow for multiple patterns in REMOVE_OLD_MODS_INCLUDE/EXCLUDE --- Dockerfile | 2 +- README.md | 4 +++- examples/docker-compose-spiget.yml | 7 +++++-- scripts/start-setupForgeApiMods | 2 +- scripts/start-setupModpack | 2 +- scripts/start-spiget | 1 + scripts/start-utils | 10 +++++++++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b02b3dd00b..ae8ca1355cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz -ARG MC_HELPER_VERSION=1.20.1 +ARG MC_HELPER_VERSION=1.20.3 ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION} RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ diff --git a/README.md b/README.md index 8bc1185f282..4b9ac404301 100644 --- a/README.md +++ b/README.md @@ -660,7 +660,9 @@ There are optional volume paths that can be attached to supply content to be cop By default, the [environment variable processing](#replacing-variables-inside-configs) is performed on synchronized files that match the expected suffixes in `REPLACE_ENV_SUFFIXES` (by default "yml,yaml,txt,cfg,conf,properties,hjson,json,tml,toml") and are not excluded by `REPLACE_ENV_VARIABLES_EXCLUDES` and `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. This processing can be disabled by setting `REPLACE_ENV_DURING_SYNC` to `false`. -If you want old mods/plugins to be removed before the content is brought over from those attach points, then add `-e REMOVE_OLD_MODS=TRUE`. You can fine tune the removal process by specifying the `REMOVE_OLD_MODS_INCLUDE` and `REMOVE_OLD_MODS_EXCLUDE` variables. By default, everything will be removed. You can also specify the `REMOVE_OLD_MODS_DEPTH` (default is 16) variable to only delete files up to a certain level. +If you want old mods/plugins to be removed before the content is brought over from those attach points, then add `-e REMOVE_OLD_MODS=TRUE`. You can fine tune the removal process by specifying the `REMOVE_OLD_MODS_INCLUDE` and `REMOVE_OLD_MODS_EXCLUDE` variables, which are comma separated lists of file glob patterns. If a directory is excluded, then it and all of its contents are excluded. By default, only jars are removed. + +You can also specify the `REMOVE_OLD_MODS_DEPTH` (default is 16) variable to only delete files up to a certain level. For example: `-e REMOVE_OLD_MODS=TRUE -e REMOVE_OLD_MODS_INCLUDE="*.jar" -e REMOVE_OLD_MODS_DEPTH=1` will remove all old jar files that are directly inside the `plugins/` or `mods/` directory. diff --git a/examples/docker-compose-spiget.yml b/examples/docker-compose-spiget.yml index a98c1834afb..4caf163248c 100644 --- a/examples/docker-compose-spiget.yml +++ b/examples/docker-compose-spiget.yml @@ -3,13 +3,16 @@ version: "3" services: mc: # Only using IMAGE variable to allow for local testing - image: ${IMAGE:-itzg/minecraft-server} + image: itzg/minecraft-server +# image: ${IMAGE:-itzg/minecraft-server} ports: - "25565:25565" environment: EULA: "TRUE" TYPE: SPIGOT - SPIGET_RESOURCES: 34315,3836 +# SPIGET_RESOURCES: 34315,3836 + SPIGET_RESOURCES: "" + REMOVE_OLD_MODS: "true" volumes: - data:/data diff --git a/scripts/start-setupForgeApiMods b/scripts/start-setupForgeApiMods index 91b12f292ab..bc0d566544a 100644 --- a/scripts/start-setupForgeApiMods +++ b/scripts/start-setupForgeApiMods @@ -10,7 +10,7 @@ set -e -o pipefail : "${MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES:=false}" : "${MODS_FORGEAPI_IGNORE_GAMETYPE:=false}" : "${REMOVE_OLD_MODS_DEPTH:=1} " -: "${REMOVE_OLD_MODS_INCLUDE:=*.jar}" +: "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}" # FORGEAPI_BASE_URL used in manifest downloads below FORGEAPI_BASE_URL=${FORGEAPI_BASE_URL:-https://api.curseforge.com/v1} diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 857aacc43ae..56ba24af8f2 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -5,7 +5,7 @@ set -e -o pipefail : "${REMOVE_OLD_MODS:=false}" : "${MODS_FILE:=}" : "${REMOVE_OLD_MODS_DEPTH:=1} " -: "${REMOVE_OLD_MODS_INCLUDE:=*.jar}" +: "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}" sum_file=/data/.generic_pack.sum # shellcheck source=start-utils diff --git a/scripts/start-spiget b/scripts/start-spiget index d00ea265dcb..efb20c98e1e 100755 --- a/scripts/start-spiget +++ b/scripts/start-spiget @@ -8,6 +8,7 @@ handleDebugMode : "${SPIGET_RESOURCES:=}" : "${SPIGET_DOWNLOAD_TOLERANCE:=5}" # in minutes +: "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}" acceptArgs=(--accept application/zip --accept application/java-archive --accept application/octet-stream) diff --git a/scripts/start-utils b/scripts/start-utils index a73364db279..f5482c2e07c 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -207,7 +207,15 @@ eula=${EULA,,} function removeOldMods { if [ -d "$1" ]; then - find "$1" -mindepth 1 -maxdepth ${REMOVE_OLD_MODS_DEPTH:-16} -wholename "${REMOVE_OLD_MODS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_MODS_EXCLUDE:-}" -delete + log "Removing old mods including:${REMOVE_OLD_MODS_INCLUDE} excluding:${REMOVE_OLD_MODS_EXCLUDE}" + mc-image-helper find \ + --delete \ + --type file,directory \ + --min-depth=1 --max-depth "${REMOVE_OLD_MODS_DEPTH:-16}" \ + --name "${REMOVE_OLD_MODS_INCLUDE:-*}" \ + --exclude-name "${REMOVE_OLD_MODS_EXCLUDE:-}" \ + --quiet \ + "$1" fi }