mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
cmd/cli: allow running upgrade while ctrld not installed
This commit is contained in:
committed by
Cuong Manh Le
parent
0d6ca57536
commit
09936f1f07
@@ -854,9 +854,9 @@ NOTE: Uninstalling will set DNS to values provided by DHCP.`,
|
||||
mainLog.Load().Error().Msg(err.Error())
|
||||
return
|
||||
}
|
||||
svcInstalled := true
|
||||
if _, err := s.Status(); errors.Is(err, service.ErrNotInstalled) {
|
||||
mainLog.Load().Warn().Msg("service not installed")
|
||||
return
|
||||
svcInstalled = false
|
||||
}
|
||||
bin, err := os.Executable()
|
||||
if err != nil {
|
||||
@@ -895,6 +895,9 @@ NOTE: Uninstalling will set DNS to values provided by DHCP.`,
|
||||
}
|
||||
|
||||
doRestart := func() bool {
|
||||
if !svcInstalled {
|
||||
return true
|
||||
}
|
||||
tasks := []task{
|
||||
{s.Stop, false},
|
||||
{s.Start, false},
|
||||
@@ -906,7 +909,9 @@ NOTE: Uninstalling will set DNS to values provided by DHCP.`,
|
||||
}
|
||||
return false
|
||||
}
|
||||
mainLog.Load().Debug().Msg("Restarting ctrld service using new binary")
|
||||
if svcInstalled {
|
||||
mainLog.Load().Debug().Msg("Restarting ctrld service using new binary")
|
||||
}
|
||||
if doRestart() {
|
||||
_ = os.Remove(oldBin)
|
||||
_ = os.Chmod(bin, 0755)
|
||||
|
||||
Reference in New Issue
Block a user