cmd/cli: log new version when upgrading successfully

This commit is contained in:
Cuong Manh Le
2024-04-04 14:36:11 +07:00
committed by Cuong Manh Le
parent 56b2056190
commit affef963c1

View File

@@ -916,7 +916,15 @@ NOTE: Uninstalling will set DNS to values provided by DHCP.`,
if doRestart() {
_ = os.Remove(oldBin)
_ = os.Chmod(bin, 0755)
mainLog.Load().Notice().Msg("Upgrade successful")
ver := "unknown version"
out, err := exec.Command(bin, "--version").CombinedOutput()
if err != nil {
mainLog.Load().Warn().Err(err).Msg("Failed to get new binary version")
}
if after, found := strings.CutPrefix(string(out), "ctrld version "); found {
ver = after
}
mainLog.Load().Notice().Msgf("Upgrade successful - %s", ver)
return
}