Auto-update server-only Macs and replace Sparkle's update UI

This commit is contained in:
Ian Gulliver
2026-10-19 16:04:47 -07:00
parent 26404758c6
commit 8bca7a4369
8 changed files with 226 additions and 11 deletions
+30
View File
@@ -8,8 +8,10 @@ import (
"net"
"net/http"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"
@@ -42,6 +44,7 @@ func serveCmd(args []string) {
ctx, replaced := context.WithCancel(ctx)
defer replaced()
go watchExecutable(ctx, replaced)
go updateDaily(ctx)
hs := &http.Server{
Addr: *listenAddr,
@@ -92,3 +95,30 @@ func watchExecutable(ctx context.Context, replaced context.CancelFunc) {
return
}
}
func updateDaily(ctx context.Context) {
for {
update(ctx)
select {
case <-ctx.Done():
return
case <-time.After(24 * time.Hour):
}
}
}
func update(ctx context.Context) {
bin, err := exec.LookPath("byre-update")
if err != nil {
slog.Error("find byre-update", "err", err)
return
}
ctx, cancel := context.WithTimeout(ctx, 30*time.Minute)
defer cancel()
out, err := exec.CommandContext(ctx, bin).CombinedOutput()
if err != nil {
slog.Error("byre-update", "err", err, "output", strings.TrimSpace(string(out)))
return
}
slog.Info("byre-update", "output", strings.TrimSpace(string(out)))
}