Merge pull request #3326 from krig/rook-binary-location

ceph: Look for binaries on PATH if not found
This commit is contained in:
Blaine Gardner authored and GitHub committed 2019-06-25 09:51:45 -06:00
commit 004f795a79
1 file changed
+8
+8
View File
@@ -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