64 lines
2.0 KiB
Bash
64 lines
2.0 KiB
Bash
#!/usr/bin/env 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
|
|
agm_yesno 'Audiogame Manager News' 'Audiogame Manager News' 'Audiogame manager news is available. Would you like to play it now?' || 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
|
|
agm_yesno "Audiogame Manager" "Audiogame Manager" "Updates are available. Would you like to update now?" || return
|
|
|
|
# Perform git pull quietly, then show only the important changes
|
|
local updateResult
|
|
git pull --quiet >/dev/null 2>&1
|
|
updateResult=$?
|
|
|
|
# Get the important information: commit messages and summary
|
|
local changesSummary
|
|
changesSummary=$({
|
|
echo "UPDATE COMPLETED"
|
|
echo
|
|
echo "Recent changes:"
|
|
git log '@{1}..' --pretty=format:'• %an: %s' | tac
|
|
echo
|
|
echo "Update summary:"
|
|
git diff --stat '@{1}..' | tail -1
|
|
} 2>/dev/null)
|
|
|
|
# Show only the meaningful update information
|
|
agm_msgbox "Update Complete" "Audiogame Manager" "$changesSummary"
|
|
|
|
exit $updateResult
|
|
}
|