all: use correct binary path when running upgrade

For safety reason, ctrld will create a backup of the current binary when
running upgrade command.

However, on systems where ctrld status is got by parsing ps command
output, the current binary path is important and must be the same with
the original binary. Depends on kernel version, using os.Executable may
return new backup binary path, aka "ctrld_previous", not the original
"ctrld" binary. This causes upgrade command see ctrld as not running
after restart -> upgrade failed.

Fixing this by recording the binary path before creating new service, so
the ctrld service status can be checked correctly.
This commit is contained in:
Cuong Manh Le
2024-05-15 17:54:41 +07:00
committed by Cuong Manh Le
parent 5710f2e984
commit 486096416f
3 changed files with 27 additions and 14 deletions

View File

@@ -49,11 +49,15 @@ func (s *merlinSvc) Platform() string {
}
func (s *merlinSvc) configPath() string {
path, err := os.Executable()
if err != nil {
return ""
bin := s.Config.Executable
if bin == "" {
path, err := os.Executable()
if err != nil {
return ""
}
bin = path
}
return path + ".startup"
return bin + ".startup"
}
func (s *merlinSvc) template() *template.Template {