correctly recover if 'apt install' doesn't work

This commit is contained in:
Jeff Carr 2025-03-23 18:20:13 -05:00
parent 9b4bbeea80
commit a02078081e
1 changed files with 6 additions and 1 deletions

View File

@ -68,7 +68,12 @@ func sendMachine(s string) error {
shell.RunRealtime([]string{"mv", "-f", "/usr/bin/zood", "/usr/bin/zood.last"})
shell.RunRealtime([]string{"apt", "update"})
shell.RunRealtime([]string{"apt", "install", "zood"})
if shell.Exists("/usr/bin/zood") {
shell.RunRealtime([]string{"rm", "-f", "/usr/bin/zood.last"})
} else {
// there is not a new version of the binary. move the old one back
shell.RunRealtime([]string{"mv", "-f", "/usr/bin/zood.last", "/usr/bin/zood"})
}
os.Exit(0)
} else if strings.HasPrefix(line, "apt install") {
log.Info("machine install", line)