Added Linux $PATH support and fixed FlagSet typo

Signed-off-by: Dan Finneran <daniel.finneran@gmail.com>
This commit is contained in:
thebsdbox 2017-04-11 11:48:51 +01:00
parent eae5422a0d
commit b6e8d4fd63

View File

@ -58,7 +58,7 @@ guestOS = "other3xlinux-64"
`
func runVMware(args []string) {
vmwareArgs := flag.NewFlagSet("hyperkit", flag.ExitOnError)
vmwareArgs := flag.NewFlagSet("vmware", flag.ExitOnError)
vmwareArgs.Usage = func() {
fmt.Printf("USAGE: %s run vmware [options] prefix\n\n", os.Args[0])
fmt.Printf("'prefix' specifies the path to the VM image.\n")
@ -102,6 +102,16 @@ func runVMware(args []string) {
vmrunArgs = []string{"-T", "fusion", "start", prefix + ".vmx"}
}
if runtime.GOOS == "linux" {
path = "vmrun"
fullVMrunPath, err := exec.LookPath(path)
if err != nil {
log.Fatalf("Unable to find %s within the $PATH", path)
}
path = fullVMrunPath
vmrunArgs = []string{"-T", "ws", "start", prefix + ".vmx"}
}
// Check executables exist before attempting to execute
if _, err := os.Stat(path); os.IsNotExist(err) {
log.Fatalf("ERROR VMware exectuables can not be found, ensure software is installed")