From e5788671189002ecf6072a7baefeedcf5dc308dd Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 27 Feb 2025 18:25:56 +0700 Subject: [PATCH] internal/router: fix fresh tomato config path When ctrld performs upgrading tasks, the current binary would be moved to different file, thus the executable will return this new file name, instead of the old "/path/to/ctrld". The config path on FreshTomato is located in the same directory with ctrld binary, with ".startup" suffix. So when the binary was moved during upgrading, the config path is located wrongly. To fix it, read the binary path from service config first, then only fallback to the current executable if the path is empty (this is the same way ctrld is doing for other router platforms). --- internal/router/service_tomato.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/router/service_tomato.go b/internal/router/service_tomato.go index 1a7151a..2cf5939 100644 --- a/internal/router/service_tomato.go +++ b/internal/router/service_tomato.go @@ -45,11 +45,15 @@ func (s *tomatoSvc) Platform() string { } func (s *tomatoSvc) 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 *tomatoSvc) template() *template.Template {