|
|
|
|
@ -3,6 +3,7 @@ package vmware
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"errors"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"regexp"
|
|
|
|
|
)
|
|
|
|
|
@ -13,9 +14,20 @@ type IfconfigIPFinder struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *IfconfigIPFinder) HostIP() (string, error) {
|
|
|
|
|
ifconfigPath, err := exec.LookPath("ifconfig")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
var ifconfigPath string
|
|
|
|
|
|
|
|
|
|
// On some systems, ifconfig is in /sbin which is generally not
|
|
|
|
|
// on the PATH for a standard user, so we just check that first.
|
|
|
|
|
if _, err := os.Stat("/sbin/ifconfig"); err == nil {
|
|
|
|
|
ifconfigPath = "/sbin/ifconfig"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ifconfigPath == "" {
|
|
|
|
|
var err error
|
|
|
|
|
ifconfigPath, err = exec.LookPath("ifconfig")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stdout := new(bytes.Buffer)
|
|
|
|
|
|