Begin Monkeyloader Work

This commit is contained in:
Merith-TK 2025-01-07 19:06:18 +00:00
parent 1fec55efc0
commit d79288f11d
8 changed files with 187 additions and 46 deletions

View file

@ -1,10 +1,10 @@
#!/bin/bash
## Setup Resonite Config
echo "Setting up Resonite Config"
echo "Setting up Resonite Config"
# if CONFIG_FILE is not set, use default config path
if [ ! -f $CONFIG_FILE ]; then
if [ ! -f $CONFIG_FILE ]; then
echo "No Resonite Config found, copying from template"
cp /mnt/defaults/resonite.json $CONFIG_FILE
fi
@ -16,10 +16,54 @@ if [ ! -n "$CONFIG_DATA" ]; then
CONFIG_DATA=$(grep -v " null," "$CONFIG_FILE")
fi
## Setup Modloader Configs
if [ "$RESONITE_MOD_LOADER" == "true" ]; then
echo "Setting up Modloader Configs"
DEFAULT_RESONITE_ARGS=$(echo "$DEFAULT_RESONITE_ARGS -LoadAssembly /data/resonite/Headless/Libraries/ResoniteModLoader.dll")
if [ "$MONKEY_LOADER" == "true" ]; then
echo "Downloading MonkeyLoader"
# Define variables
monkeyloader_url="https://github.com/ResoniteModdingGroup/MonkeyLoader.GamePacks.Resonite/releases/download/v0.21.2/MonkeyLoader-v0.24.0+Resonite-v0.21.2+RML-v3.0.4.zip"
destination_dir="/data/resonite/Headless"
zip_file="$destination_dir/MonkeyLoader.zip"
# Check if the zip file already exists
if [ ! -f "$zip_file" ]; then
echo "Downloading from $monkeyloader_url to $zip_file"
curl -L -o "$zip_file" "$monkeyloader_url"
else
echo "File already exists: $zip_file, skipping download."
fi
if [ ! -f "/data/resonite/Headless/run_monkeyloader.sh" ]; then
# Extract the zip file
echo "Extracting $zip_file to $destination_dir"
unzip -o "$zip_file" -d "$destination_dir"
# Clean up zip-specific structure (move contents correctly if necessary)
if [ -d "$destination_dir/zipfiles" ]; then
echo "Moving extracted contents to $destination_dir"
mv "$destination_dir/zipfiles/"* "$destination_dir"
rmdir "$destination_dir/zipfiles"
fi
fi
if [ -f "$destination_dir/MonkeyLoader/GamePacks/MonkeyLoader.GamePacks.Resonite.Unity.nupkg" ]; then
rm "$destination_dir/MonkeyLoader/GamePacks/MonkeyLoader.GamePacks.Resonite.Unity.nupkg"
fi
if [ -f "$destination_dir/MonkeyLoader/GamePacks/MonkeyLoader.GamePacks.Unity.nupkg" ]; then
rm "$destination_dir/MonkeyLoader/GamePacks/MonkeyLoader.GamePacks.Unity.nupkg"
fi
echo "MonkeyLoader setup complete."
else
echo "Modloader is disabled"
fi
echo "MonkeyLoader Disabled"
# Remove MonkeyLoader directory and run_monkeyloader.sh script if they exist
if [ -d "/data/resonite/Headless/MonkeyLoader" ]; then
echo "Removing MonkeyLoader directory"
rm -rf "/data/resonite/Headless/MonkeyLoader"
fi
if [ -f "/data/resonite/Headless/run_monkeyloader.sh" ]; then
echo "Removing run_monkeyloader.sh script"
rm -f "/data/resonite/Headless/run_monkeyloader.sh"
fi
fi

View file

@ -7,12 +7,6 @@
# 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"
)
# Function to download a file from URL to destination
download_file() {
local url="$1"
@ -28,30 +22,33 @@ download_file() {
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")"
for url in $MOD_URLS; do
modname=$(basename "$url")
destination=""
# Determine the destination based on the file extension
if [[ "$modname" == *.dll ]]; then
destination="/data/resonite/Headless/rml_mods/$modname"
elif [[ "$modname" == *.nupkg ]]; then
destination="/data/resonite/Headless/MonkeyLoader/Mods/$modname"
else
echo "Unknown file type for $modname, skipping."
continue
fi
# Check if file already exists, if yes, skip download
if [ ! -f "$destination" ]; then
echo "Downloading mod: $url"
download_file "$url" "$destination"
else
echo "File already exists: $destination, skipping download."
fi
done
# if resonte mod loader is enabled, create and link rml_mods, libs, and config
if [ "$RESONITE_MOD_LOADER" == "true" ]; then
if [ "$MONKEY_LOADER" == "true" ]; then
for dir in rml_mods rml_libs rml_config; do
if [ -d "/data/resonite/Headless/$dir" ]; then
continue
@ -59,8 +56,4 @@ if [ "$RESONITE_MOD_LOADER" == "true" ]; then
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

View file

@ -1,11 +1,21 @@
#!/bin/bash
cd /data/resonite/Headless || exit
if [ "$STOP_LAUNCH" == "true" ]; then
echo "STOP_LAUNCH is set to true, exiting..."
exit 0
fi
cd /data/resonite/Headless || exit
echo "Running Resonite"
echo "exec: dotnet Resonite.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS"
dotnet Resonite.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS
if [ "$MONKEY_LOADER" == "true" ]; then
echo "exec: dotnet /app/Loader.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS"
# dotnet Resonite.dll -LoadAssembly MonkeyLoader/MonkeyLoader.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS
# bash run_monkeyloader.sh $DEFAULT_RESONITE_ARGS $RESONITE_ARGS
dotnet /app/Loader.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS
else
echo "exec: dotnet Resonite.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS"
dotnet Resonite.dll $DEFAULT_RESONITE_ARGS $RESONITE_ARGS
fi