i updatet the script and please be advised that it is now very sexy.
much more refinde, less bloat, less asking for unnecessary confirmations. one might just asume that the whole reason for the old script to exist is to make this new shiny one look even better. without further ado, godhood brought to script:
#!/bin/bash
echo " + "
echo " | ALU "
echo " | Ascension Launcher Updater"
echo " + "
echo " "
echo "welcome to the launcher launcher"
echo " "
VERSION_MIN=0
VERSION_MAX=999
if [ ! -f current_version.txt ]; then
echo " "
echo "first time launch"
echo " "
touch current_version.txt
mkdir old_launchers
if [ ! -f ascension-launcher-*.AppImage ]; then
echo "[ERR] no launcher found"
echo "${VERSION_MIN}" > current_version.txt
echo "[ERR] make sure this script is in the same directory as the ascension launcher"
echo "[ERR] make sure you have not renamed the ascension launcher"
echo " "
echo "[ERR] the script will search for updates starting with version ${VERSION_MIN}"
echo "[ERR] this may take a while"
echo " "
read -r -p "set next starting value manualy? [y/N] " response
if [[ "$response" =~ ^([yY])$ ]]; then
echo " "
echo "input any value ranging from ${VERSION_MIN} to ${VERSION_MAX}: "
read input
echo "$input" > current_version.txt
echo "new starting value is ${input}"
fi
else
VERSION=$( ls ascension-launcher-*.AppImage )
VERSION=${VERSION%.*}
VERSION=${VERSION##*-}
echo "${VERSION}" > current_version.txt
fi
fi
VERSION=$( < current_version.txt )
VERSION_OLD=$VERSION
STATUS_OK=200
i=true
j=true
echo "checking for updates..."
while [ "$i" = true ]; do
while [ "$j" = true ]; do
STATUS_CODE=$( curl -s -o /dev/null -I -w "%{http_code}" https://download.ascension-patch.gg/update/ascension-launcher-${VERSION}.AppImage )
j=false
done
if (( $STATUS_CODE == $STATUS_OK )); then
VERSION=$((VERSION+1))
echo "${VERSION}..."
STATUS_CODE=$( curl -s -o /dev/null -I -w "%{http_code}" https://download.ascension-patch.gg/update/ascension-launcher-${VERSION}.AppImage )
if (( $STATUS_CODE != $STATUS_OK )); then
VERSION=$((VERSION-1))
echo "${VERSION}" > current_version.txt
echo "${VERSION} appears to be the latest version"
i=false
fi
else
VERSION=$((VERSION+1))
echo "${VERSION}..."
j=true
if (( $VERSION > $VERSION_MAX )); then
VERSION=$VERSION_MIN
echo "${VERSION}" > current_version.txt
echo "[ERR] no launcher found"
i=false
fi
fi
done
if (( $VERSION != $VERSION_OLD )); then
echo "downloading..."
mv ascension-launcher-*.AppImage old_launchers
wget https://download.ascension-patch.gg/update/ascension-launcher-${VERSION}.AppImage
chmod a=,u=rx ascension-launcher-*.AppImage
fi
if (( $VERSION == $VERSION_MIN )); then
echo "[ERR] no version in the range of ${VERSION_OLD} and ${VERSION_MAX} could be found"
echo "[ERR] next start will search starting with version ${VERSION_MIN}"
echo "[ERR] this may take a while"
echo " "
read -r -p "set next starting value manualy? [y/N] " response
if [[ "$response" =~ ^([yY])$ ]]; then
echo " "
echo "input any value ranging from ${VERSION_MIN} to ${VERSION_MAX}: "
read input
echo "$input" > current_version.txt
echo "new starting value is ${input}"
fi
echo " "
sleep 2
read -p "press 'enter' to quit..."
exit
fi
echo " "
echo "you appear to be up to date"
echo "launching the launcher..."
echo " "
./ascension-launcher-*.AppImage
echo " "
echo "see you soon"
sleep 2
echo " "
read -p "press 'enter' to quit..."
exit
# stay hydrated
#
# ALU brought to you by x3cutiex3