resonite/scripts/03_download_mods.sh
Merith-TK 402c386429
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 4s
net9 harmony
2025-01-07 19:51:36 +00:00

68 lines
No EOL
2.6 KiB
Bash
Executable file

#!/bin/bash
## TOOOTTALLY NOT AI GENERATED NOTHING TO SEE HERE
# real note, this was because I normally program in
# golang and really, *really* didnt want to have to write
# and maintain a binary in a language many people dont
# want to use simply because google made it...
# shell scripts are typically known by docker hosters so...
# Define file URLs and their associated positions
file_urls=(
"https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/ResoniteModLoader.dll /data/resonite/Headless/Libraries/ResoniteModLoader.dll"
# "https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/0Harmony.dll /data/resonite/Headless/rml_libs/0Harmony.dll"
# net9 Harmony
"https://github.com/stiefeljackal/pardeike.Harmony/releases/download/temp-release/0Harmony.dll /data/resonite/Headless/rml_libs/0Harmony.dll"
)
# Function to download a file from URL to destination
download_file() {
local url="$1"
local destination="$2"
# make sure destination directory exists
mkdir -p "$(dirname "$destination")"
# Use curl to download file
if curl -fsSL "$url" -o "$destination"; then
echo "File downloaded successfully: $destination"
else
echo "Failed to download file: $destination"
exit 1
fi
}
# Loop through each file URL and download
for file_url in "${file_urls[@]}"; do
read -r url destination <<< "$file_url"
# Backup existing file if exists
if [ -f "$destination" ]; then
mv "$destination" "${destination}.bak"
fi
# Download file
download_file "$url" "$destination"
done
# Download additional files from a list of URLs to /data/resonite/Headless/rml_mods
# shellcheck disable=SC2153
for url in $MOD_URLS ; do
destination="/data/resonite/Headless/rml_mods/$(basename "$url")"
# Check if file already exists, if yes, skip download
if [ ! -f "$destination" ]; then
echo "Downloading mod: $url"
download_file "$url" "$destination"
fi
done
# if resonte mod loader is enabled, create and link rml_mods, libs, and config
if [ "$RESONITE_MOD_LOADER" == "true" ]; then
for dir in rml_mods rml_libs rml_config; do
if [ -d "/data/resonite/Headless/$dir" ]; then
continue
fi
mkdir -p "/data/resonite/Headless/$dir"
ln -s "./Headless/$dir" "./$dir"
done
if [ ! -f "/data/resonite/Libraries/ResoniteModLoader.dll" ]; then
mkdir -p "/data/resonite/Libraries"
ln -s "/data/resonite/Headless/Libraries/ResoniteModLoader.dll" "/data/resonite/Libraries/ResoniteModLoader.dll"
fi
fi