Add --force-update: immediate signed-update check, stage + service restart
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user