Added update checking.

This commit is contained in:
Storm Dragon 2020-09-20 17:42:42 -04:00
parent f4a1496517
commit a876df27d7

View File

@ -1,5 +1,27 @@
#!/bin/bash
# Automatic update function
update() {
local filePath="$(command -v ${0})"
if file "${filePath}" | grep 'Bourne-Again shell script, ASCII text' ; then
return
fi
if [[ "$(wget --quiet -O - https://stormgames.wolfe.casa/downloads/audiogame-manager | sha256sum | cut -d ' ' -f1)" == "$(sha256sum "${filePath}" | cut -d ' ' -f1)" ]]; then
return
fi
echo "There is a new version of ${0##*/} available."
echo "Do you want to update now?"
read -r continue
if [[ "${continue,,}" =~ ^y|ye|yes$ ]]; then
if [[ -w "$0" ]]; then
wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/audiogame-manager"
else
sudo wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/audiogame-manager"
fi
echo "${0##*/} has been updated. Please launch the program again to use the latest version."
exit 0
fi
}
# Wine configuration section
@ -246,6 +268,8 @@ automate_installer() {
wineserver -w
}
# Check for updates
update
# If display isn't set assume we are launching from console and an X environment is running using display :0
if [[ -z "$DISPLAY" ]]; then
export DISPLAY=":0"