diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-30 00:54:16 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-30 00:54:16 +0200 |
commit | 6f8c05ea93ec52819785d73f0377d35b1073dc3f (patch) | |
tree | 30df23a7ebd67e4bd55669259beeb1159380a490 | |
parent | 6dbd164227b88239c3e479f49e6c936dc652085a (diff) |
Fixed syncthing binDir when set to '.'0.1.0
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | lib/syncthing/st.go | 12 |
2 files changed, 11 insertions, 2 deletions
@@ -92,6 +92,7 @@ package-all: GOOS=windows GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package @echo "# Build darwin amd64..." GOOS=darwin GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package + make -f $(ROOT_SRCDIR)/Makefile clean test: tools/glide go test --race $(shell $(LOCAL_TOOLSDIR)/glide novendor) diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go index a750036..1f78757 100644 --- a/lib/syncthing/st.go +++ b/lib/syncthing/st.go @@ -95,9 +95,17 @@ func (s *SyncThing) startProc(exeName string, args []string, env []string, eChan exec.Command("bash", "-c", "pkill -9 "+exeName).Output() } - path, err := exec.LookPath(path.Join(s.binDir, exeName)) + // When not set (or set to '.') set bin to path of xds-agent executable + bdir := s.binDir + if bdir == "" || bdir == "." { + if dir, err := filepath.Abs(filepath.Dir(os.Args[0])); err == nil { + bdir = dir + } + } + + path, err := exec.LookPath(path.Join(bdir, exeName)) if err != nil { - return nil, fmt.Errorf("Cannot find %s executable in %s", exeName, s.binDir) + return nil, fmt.Errorf("Cannot find %s executable in %s", exeName, bdir) } cmd := exec.Command(path, args...) cmd.Env = os.Environ() |