From 8959f1ba94acc660512f8d8a407661138666e44f Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 29 Apr 2026 20:57:42 -0400 Subject: [PATCH] Try to insure thatTop Speed sserver updates get applied and the service doesn't restart the old binary. --- .includes/topspeed.sh | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/.includes/topspeed.sh b/.includes/topspeed.sh index 6ce1bae..7f6df04 100644 --- a/.includes/topspeed.sh +++ b/.includes/topspeed.sh @@ -8,6 +8,7 @@ topspeedServiceFile="/etc/systemd/system/topspeed.service" topspeedServiceScript="${topspeedInstallDir}/topspeed-service.sh" topspeedStopScript="${topspeedInstallDir}/topspeed-stop.sh" topspeedBinaryPath="${topspeedRuntimeDir}/TopSpeed.Server" +topspeedInstalledAssetFile="${topspeedRuntimeDir}/.installed-release" topspeedSessionName="topspeed" topspeedRepoApi="https://api.github.com/repos/diamondStar35/top_speed/releases" topspeedAssetPattern='^TopSpeed\.Server-linux-arm64-Release-v-.*\.zip$' @@ -112,9 +113,12 @@ stop_topspeed_service_if_present() { install_topspeed_server() { local archivePath="" local archiveDir="" + local assetName="" + local tempAssetFile="" archivePath="$(fetch_topspeed_asset)" || return 1 archiveDir="$(dirname "$archivePath")" + assetName="$(basename "$archivePath")" stop_topspeed_service_if_present # `sudoFlags` is initialized by the main launcher before sourcing this file. @@ -153,7 +157,18 @@ install_topspeed_server() { return 1 fi + tempAssetFile="$(mktemp)" + printf '%s\n' "$assetName" > "$tempAssetFile" + # shellcheck disable=SC2154 + if ! sudo "${sudoFlags[@]}" install -o "$topspeedUser" -g "$topspeedUser" -m 644 "$tempAssetFile" "$topspeedInstalledAssetFile"; then + rm -rf "$archiveDir" + rm -f "$tempAssetFile" + msgbox "Failed to record the installed Top Speed release." + return 1 + fi + rm -rf "$archiveDir" + rm -f "$tempAssetFile" return 0 } @@ -170,12 +185,63 @@ cat > "$tempServiceScript" < "\$installedAssetFile" + fi + + rm -rf "\$tempDir" + return 0 +} cd "\$runtimeDir" || exit 1 if tmux has-session -t "\$sessionName" &> /dev/null; then tmux kill-session -t "\$sessionName" fi +update_from_latest_release + if [[ ! -x "\$binaryPath" ]]; then exit 1 fi