-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.go
40 lines (30 loc) · 799 Bytes
/
start.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/codegangsta/cli"
"os"
"os/exec"
"syscall"
)
var Start = cli.Command{
Name: "start",
ShortName: "s",
Usage: "Initializes the desired vm in headless mode",
Description: "Expects the vm name as the argument.",
Action: func(c *cli.Context) {
vm_name := c.Args().First()
if vm_name == "" {
println("Please specify vm name")
return
}
binary, err := exec.LookPath("VBoxManage")
if err != nil {
panic(err)
}
args := []string{"VBoxManage", "startvm", vm_name, "-type", "headless"}
env := os.Environ()
err = syscall.Exec(binary, args, env)
if err != nil {
panic(err)
}
},
}