From b6e8d4fd63e3eeeeaf2ed29afe935daba256721a Mon Sep 17 00:00:00 2001 From: thebsdbox Date: Tue, 11 Apr 2017 11:48:51 +0100 Subject: [PATCH] Added Linux $PATH support and fixed FlagSet typo Signed-off-by: Dan Finneran --- src/cmd/moby/run_vmware.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cmd/moby/run_vmware.go b/src/cmd/moby/run_vmware.go index 08465cca7..1ebb67d77 100644 --- a/src/cmd/moby/run_vmware.go +++ b/src/cmd/moby/run_vmware.go @@ -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")