mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-09-18 11:57:57 +00:00
Add REMOVE_OLD_CONFIGS to clear old configs before modpack install (#4266)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 "$@"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user