diff --git a/game-scripts/swamp-update.sh b/game-scripts/swamp-update.sh index b8c9128..635fcb4 100755 --- a/game-scripts/swamp-update.sh +++ b/game-scripts/swamp-update.sh @@ -38,35 +38,23 @@ # or portions thereof with code not governed by the terms of the CPAL. cache="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/cache" -updateURL="https://www.kaldobsky.com/audiogames/Swamp.zip" - -extract_error() { - echo "There was an error extracting the zip file." - exit 1 -} +updateURL="https://www.kaldobsky.com/audiogames" +updateFiles=("Swamp.zip") -# Set the swamp directory -pushd ~/.local/wine/swamp/drive_c/Program\ Files/swamp +# Back up configuration files. +for i in losers.txt muted.txt scriptkeys.txt keyconfig.ini ; do + cp -v ~/"drive_c/Program Files/swamp/${i}" ~/"drive_c/Program Files/swamp/${i}.agm" + echo "${i} backed up as ${i}.agm" +done | dialog --progressbox "Backing up configuration files. They can be found in your swamp directory." -1 -1 -# Restore the directory stack on exit. -trap popd EXIT +sleep 3 -echo "Checking for Swamp updates..." +# Download and extract updates +for i in "${updateFiles[@]}" ; do + wget -O "${cache}/$i" "${url}/$i" + unzip -d ~/"drive_c/Program Files/swamp" "${cache}/${i}" +done | dialog --progressbox "Updating Swamp, please wait..." -1 -1 -# Check for and download new versions. -update="$(wget -N "${updateURL}" 2>&1 | grep "not modified on server")" - -if [ -n "${update}" ]; then - echo "Swamp is up to date." - exit 0 -fi - -echo "Updating Swamp..." - -# Unzip the new patch -unzip -o Swamp.zip || extract_error - -echo "Swamp has been updated." exit 0