From b3ba6b40fd28d9614dae47c3af9970548d508020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Wed, 19 Jun 2019 09:49:16 +0200 Subject: [PATCH] ceph: Look for binaries on PATH if not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similarly to #2675, try to find the rook binary on PATH in case it isn't found in /usr/local/bin/rook. Distributions generally disallow installing files into /usr/local, as it is reserved for non-system installations by the FHS. Signed-off-by: Kristoffer Grönlund --- pkg/daemon/ceph/osd/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/daemon/ceph/osd/init.go b/pkg/daemon/ceph/osd/init.go index 63b469861..d69cedab2 100644 --- a/pkg/daemon/ceph/osd/init.go +++ b/pkg/daemon/ceph/osd/init.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "os" + "os/exec" "path" "path/filepath" @@ -89,6 +90,13 @@ func copyBinary(sourceDir, targetDir, filename string) error { targetPath := path.Join(targetDir, filename) logger.Infof("copying %s to %s", sourcePath, targetPath) + // Check if the source path exists, and look in PATH if it doesn't + if _, err := os.Stat(sourcePath); err != nil { + if sourcePath, err = exec.LookPath(filename); err != nil { + return err + } + } + // Check if the target path exists, and skip the copy if it does if _, err := os.Stat(targetPath); err == nil { return nil