Add REMOVE_OLD_CONFIGS to clear old configs before modpack install (#4266)

This commit is contained in:
alberto-is
2026-09-17 07:25:14 -05:00
committed by GitHub
parent efade6567b
commit 22749e08b7
8 changed files with 75 additions and 0 deletions
+9
View File
@@ -9,6 +9,11 @@ set -e -o pipefail
: "${PLUGINS_FILE:=}"
: "${REMOVE_OLD_MODS_DEPTH:=1} "
: "${REMOVE_OLD_MODS_INCLUDE:=*.jar,*-version.json}"
: "${REMOVE_OLD_CONFIGS:=false}"
: "${CONFIG_OUT_DIR:=/data/config}"
: "${REMOVE_OLD_CONFIGS_DEPTH:=16}"
: "${REMOVE_OLD_CONFIGS_INCLUDE:=*}"
: "${REMOVE_OLD_CONFIGS_EXCLUDE:=}"
: "${CF_USE_HTTP2:=false}" # CF downloads are faster with HTTP 1.1
: "${MODRINTH_LOADER:=}"
@@ -25,6 +30,10 @@ if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then
rm -f "$sum_file"
fi
if isTrue "${REMOVE_OLD_CONFIGS}"; then
removeOldConfigs "$CONFIG_OUT_DIR"
fi
function handlePackwiz() {
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
+17
View File
@@ -547,6 +547,23 @@ function removeOldMods {
fi
}
function removeOldConfigs {
if [ -d "$1" ]; then
log "Removing old configs including='${REMOVE_OLD_CONFIGS_INCLUDE}' excluding='${REMOVE_OLD_CONFIGS_EXCLUDE}' up to depth=${REMOVE_OLD_CONFIGS_DEPTH}"
args=(
--delete
--type file
--min-depth=1 --max-depth "${REMOVE_OLD_CONFIGS_DEPTH}"
--name "${REMOVE_OLD_CONFIGS_INCLUDE}"
--exclude-name "${REMOVE_OLD_CONFIGS_EXCLUDE}"
)
if ! isDebugging; then
args+=(--quiet)
fi
mc-image-helper find "${args[@]}" "$1"
fi
}
function get() {
mc-image-helper get "$@"
}