mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-03 03:21:50 +02:00
fix(agent): find macmon if /opt/homebrew/bin is not in path (#1746)
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -86,3 +89,24 @@ func ReadUintFile(path string) (uint64, bool) {
|
||||
}
|
||||
return parsed, true
|
||||
}
|
||||
|
||||
// LookPathHomebrew is like exec.LookPath but also checks Homebrew paths.
|
||||
func LookPathHomebrew(file string) (string, error) {
|
||||
foundPath, lookPathErr := exec.LookPath(file)
|
||||
if lookPathErr == nil {
|
||||
return foundPath, nil
|
||||
}
|
||||
var homebrewPath string
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
homebrewPath = filepath.Join("/opt", "homebrew", "bin", file)
|
||||
case "linux":
|
||||
homebrewPath = filepath.Join("/home", "linuxbrew", ".linuxbrew", "bin", file)
|
||||
}
|
||||
if homebrewPath != "" {
|
||||
if _, err := os.Stat(homebrewPath); err == nil {
|
||||
return homebrewPath, nil
|
||||
}
|
||||
}
|
||||
return "", lookPathErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user