diff --git a/pkg/machine/machine.go b/pkg/machine/machine.go index 2a42aaf..12c6a26 100644 --- a/pkg/machine/machine.go +++ b/pkg/machine/machine.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "strings" "github.com/denisbrodbeck/machineid" @@ -136,3 +137,15 @@ func ExecuteCloudConfig(file, stage string) error { _, err := utils.SH(fmt.Sprintf("elemental run-stage -s %s %s", stage, file)) return err } + +func FindCommand(def string, options []string) string { + for _, p := range options { + path, err := exec.LookPath(p) + if err == nil { + return path + } + } + + // Otherwise return default + return def +}