From c54f38e271e3259fe648a61fcbcac811f9d2f7bc Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 4 Apr 2024 14:36:11 +0700 Subject: [PATCH] cmd/cli: log new version when upgrading successfully --- cmd/cli/cli.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index b2cd3b94..deeeb7ca 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -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 }