Skip to content

Commit b2069ad

Browse files
committed
fix old version cleanup
Signed-off-by: Pascal Sthamer <pascal.sthamer@ips-hosting.com>
1 parent bb7c3be commit b2069ad

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

hytale/entrypoint.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ function install_default_plugins() {
146146
# Install a plugin by repo
147147
function _install_plugin_repo() {
148148
local repo="$1"
149-
local plugin_name
150-
plugin_name=$(basename "$repo")
149+
local mods_dir="$2"
151150

152151
local url
153152
url=$(_latest_jar_url "$repo")
@@ -159,15 +158,20 @@ function install_default_plugins() {
159158
local filename
160159
filename=$(basename "$url")
161160

161+
# Extract base name by removing version suffix (e.g., "-1.0.0.jar" or "-1.0.0-beta.1.jar" -> "")
162+
local base_name
163+
# Use sed -E for portability (
164+
base_name=$(printf '%s' "$filename" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?\.jar$//')
165+
166+
echo "Removing old versions of $base_name (keeping $filename)"
167+
find "$mods_dir" -name "${base_name}-*.jar" ! -name "$filename" -print -delete
168+
162169
# Check if this exact version is already installed
163170
if [ -f "$mods_dir/$filename" ]; then
164171
echo "Plugin $filename already installed, skipping download"
165172
return
166173
fi
167174

168-
# Remove old versions of the plugin
169-
rm -fv "$mods_dir"/*"$plugin_name"*.jar
170-
171175
echo "Downloading $repo -> $filename"
172176
wget -q -O "$mods_dir/$filename" "$url"
173177
}
@@ -177,16 +181,16 @@ function install_default_plugins() {
177181
for p in "${_plugins[@]}"; do
178182
case "$(echo "$p" | tr '[:upper:]' '[:lower:]' | xargs)" in
179183
webserver)
180-
_install_plugin_repo "nitrado/hytale-plugin-webserver"
184+
_install_plugin_repo "nitrado/hytale-plugin-webserver" "$mods_dir"
181185
;;
182186
query)
183-
_install_plugin_repo "nitrado/hytale-plugin-query"
187+
_install_plugin_repo "nitrado/hytale-plugin-query" "$mods_dir"
184188
;;
185189
performance-saver)
186-
_install_plugin_repo "nitrado/hytale-plugin-performance-saver"
190+
_install_plugin_repo "nitrado/hytale-plugin-performance-saver" "$mods_dir"
187191
;;
188192
prometheus)
189-
_install_plugin_repo "apexhosting/hytale-plugin-prometheus"
193+
_install_plugin_repo "apexhosting/hytale-plugin-prometheus" "$mods_dir"
190194
;;
191195
"")
192196
;;

0 commit comments

Comments
 (0)