First pass at the new check for updates function.
This commit is contained in:
parent
07054de7cb
commit
5cf7606f6e
@ -68,36 +68,21 @@ check_news() {
|
|||||||
|
|
||||||
# Automatic update function
|
# Automatic update function
|
||||||
update() {
|
update() {
|
||||||
local filePath="$(command -v ${0})"
|
local url="$(git ls-remote --get-url)"
|
||||||
if file "${filePath}" | grep -q 'Bourne-Again shell script' ; then
|
if [[ "$url" =~ ^ssh://|git@ ]] || [[ -z "$url" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# make sure the site can be reached
|
git remote update &> /dev/null
|
||||||
ping -c1 stormgames.wolfe.casa &> /dev/null || return
|
local upstream='@{u}'
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
local home="$(git rev-parse @)"
|
||||||
local downloadFile="audiogame-manager.mac"
|
local remote="$(git rev-parse "$upstream")"
|
||||||
else
|
if [[ "$home" == "$remote" ]]; then
|
||||||
if [[ "$(uname -m)" == "armv7l" ]]; then
|
return
|
||||||
local downloadFile="audiogame-manager.arm"
|
fi
|
||||||
else
|
dialog --backtitle "Audiogame Manager" \
|
||||||
local downloadFile="audiogame-manager"
|
--yesno "Updates are available. Would you like to update now?" -1 -1 --stdout || return
|
||||||
fi
|
git pull
|
||||||
fi
|
exit $?
|
||||||
if [[ "$(wget --quiet -O - https://stormgames.wolfe.casa/downloads/${downloadFile} | sha256sum | cut -d ' ' -f1)" == "$(sha256sum "${filePath}" | cut -d ' ' -f1)" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
dialog --backtitle "Audiogame Manager" --yesno "There is a new version of ${0##*/} available.\nDo you want to update now?" -1 -1
|
|
||||||
if [[ ${?} -eq 0 ]]; then
|
|
||||||
if [[ -w "$0" ]]; then
|
|
||||||
wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/${downloadFile}"
|
|
||||||
chmod +x "$0"
|
|
||||||
else
|
|
||||||
sudo wget --quiet -O "${filePath}" "https://stormgames.wolfe.casa/downloads/${downloadFile}"
|
|
||||||
sudo chmod +x "$0"
|
|
||||||
fi
|
|
||||||
echo "${0##*/} has been updated. Please launch the program again to use the latest version."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to open urls across OS.
|
# Function to open urls across OS.
|
||||||
|
Loading…
Reference in New Issue
Block a user