Add --force-update: immediate signed-update check, stage + service restart

This commit is contained in:
mram
2026-09-21 08:22:11 +02:00
parent e4e4348e8d
commit 6a6359a630
6 changed files with 191 additions and 28 deletions
+13
View File
@@ -186,3 +186,16 @@ func Remove() error {
}
return nil
}
// RestartIfRunning restarts the systemd unit when it is active (used after
// a forced update staged a new binary). Reports whether a restart
// happened. An inactive or missing unit is not an error. Needs root.
func RestartIfRunning() (bool, error) {
if err := exec.Command("systemctl", "is-active", "--quiet", Name+".service").Run(); err != nil {
return false, nil // inactive or not installed
}
if out, err := exec.Command("systemctl", "restart", Name+".service").CombinedOutput(); err != nil {
return false, fmt.Errorf("systemctl restart (run as root): %w (%s)", err, out)
}
return true, nil
}