From eae85b0299759250f0493175d0e43618b1b2ab30 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 20 Sep 2020 17:43:18 -0400 Subject: [PATCH] Merged to master. --- audiogame-manager.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 69f465b..ffe0b89 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -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"