53 lines
1.7 KiB
Bash
53 lines
1.7 KiB
Bash
# Check for latest news
|
|
check_news() {
|
|
# For use by update scripts that want to source functions in this file.
|
|
[[ "$agmNoLaunch" == "true" ]] && return
|
|
trap return INT
|
|
# url for news file
|
|
local newsFile="https://stormgames.wolfe.casa/media/agm.ogg"
|
|
local newsPath="${configFile%/*.conf}/.news"
|
|
local newsTag="$(curl --connect-timeout 5 -sI "$newsFile" | grep -i '^etag: "' | cut -d '"' -f2)"
|
|
if [[ -z "${newsTag}" ]]; then
|
|
return
|
|
fi
|
|
local newsOldTag="$(cat "$newsPath" 2> /dev/null)"
|
|
if [[ "$newsTag" != "$newsOldTag" ]]; then
|
|
dialog --yes-label 'Play' \
|
|
--no-label 'Later' \
|
|
--backtitle 'Audiogame Manager News' \
|
|
--yesno 'Audiogame manager news is available. Please use left and right arrows to navigate and enter to confirm.' -1 -1 || return
|
|
sox -qV0 "$newsFile" -d &> /dev/null
|
|
echo -n "$newsTag" > "$newsPath"
|
|
fi
|
|
}
|
|
|
|
# Automatic update function
|
|
# Automatic update function
|
|
update() {
|
|
if ! [[ -d ".git" ]]; then
|
|
return
|
|
fi
|
|
local url="$(git ls-remote --get-url)"
|
|
if [[ "$url" =~ ^ssh://|git@|gitea@ ]] || [[ -z "$url" ]]; then
|
|
return
|
|
fi
|
|
git remote update &> /dev/null
|
|
local upstream='@{u}'
|
|
local home="$(git rev-parse @)"
|
|
local remote="$(git rev-parse "$upstream")"
|
|
if [[ "$home" == "$remote" ]]; then
|
|
return
|
|
fi
|
|
dialog --backtitle "Audiogame Manager" \
|
|
--yesno "Updates are available. Would you like to update now?" -1 -1 --stdout || return
|
|
{ git pull
|
|
git log '@{1}..' --pretty=format:'%an: %s' | tac; }
|
|
exit $?
|
|
}
|
|
# Get latest news if available
|
|
check_news
|
|
# With no arguments, open the game launcher.
|
|
if [[ $# -eq 0 ]]; then
|
|
game_launcher
|
|
fi
|