diff --git a/ersc-script.sh b/ersc-script.sh index 0c6e7a1..2f08c7b 100755 --- a/ersc-script.sh +++ b/ersc-script.sh @@ -1,14 +1,43 @@ #!/bin/bash search_paths=("$HOME/.steam/steam/steamapps/common" "$HOME/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common" "$HOME/.local/share/Steam/steamapps/common" "/mnt" "/") +repository_url="https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest" eldenring_dir="" +sc_download_url="" +local_path="" -#gets latest download url from github -sc_download_url=$(curl -s "https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest" | jq -r '.assets[0].browser_download_url') +read -p "Do you want to use the official Github-Repository [d] to download the mod or use an already downloaded .zip? [l] [D/l]: " input -if [[ -z "$sc_download_url" || "$sc_download_url" == "null" ]]; then - echo "Failed to retrieve download URL" - exit 1 +if [[ $input == "l" || $input == "L" || $input == "local" || $input == "Local" ]]; then + echo "Searching Downloads folder..." + local_path=$(timeout 5 find $HOME/Downloads -iname Seamless*.zip) || true + + if [[ -f "$local_path" && "$local_path" =~ ^.*Seamless.*.zip$ ]]; then + echo "File found at $local_path" + + else + echo "File not found in $HOME/Downloads" + read -p "Please specify the path to your local .zip archive: " input + if [[ -z "$input" || "$input" == "null" ]]; then + echo "Empty path provided" + exit 1 + + elif [[ -f "$input" ]]; then + local_path=$input + echo "File found at $local_path" + + elif [[ ! -z "$input" ]]; then + local_path=$(timeout 5 find $input -iname Seamless*.zip) + if [[ -f "$local_path" ]]; then + echo "File found at $local_path" + else + echo "File not found at $input" + exit 1 + fi + fi + fi +else + sc_download_url=$(curl -s "https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest" | jq -r '.assets[0].browser_download_url') fi echo "Searching for Elden Ring game folder" @@ -42,15 +71,21 @@ fi input="" -echo "Creating temp download folder" +echo "Creating temp folder" temp_dir=$(mktemp -d) cd "$temp_dir" -echo "Downloading Seamless Coop" -echo "Download Url: $sc_download_url" -wget -q -O seamlesscoop.zip "$sc_download_url" +if [[ -z $sc_download_url && -f $local_path ]]; then + echo "Copying .zip" + cp "$local_path" ./seamlesscoop.zip +else + echo "Downloading Seamless Coop" + echo "Download Url: $sc_download_url" + wget -q -O seamlesscoop.zip "$sc_download_url" +fi -echo "Unzipping downloaded files" + +echo "Unzipping files" unzip -q seamlesscoop.zip rm seamlesscoop.zip