-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathcmd_setup.go
53 lines (45 loc) · 1000 Bytes
/
cmd_setup.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
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"github.com/urfave/cli"
)
var setupCommand = cli.Command{
Name: "setup",
Hidden: true,
Flags: []cli.Flag{
cli.StringFlag{
Name: "hostname",
},
cli.StringFlag{
Name: "home",
},
},
Action: func(ctx *cli.Context) error {
err := ensureRoot()
if err != nil {
return err
}
hostname := ctx.String("hostname")
if hostname == "" {
return cli.NewExitError("Must specify hostname", 1)
}
domain := getDomain(hostname)
home := ctx.String("home")
if home == "" {
return cli.NewExitError("Must specify home", 1)
}
if err := spin(fmt.Sprintf("Creating /etc/resolver/%s", domain), func() error {
return installResolver(hostname)
}); err.ExitCode() != 0 {
return err
}
if err := spin("Modifying /etc/exports", func() error {
return ensureNFS(home)
}); err.ExitCode() != 0 {
return err
}
return spin("Creating /Library/LaunchDaemons/local.dlite.plist", func() error {
return installDaemon()
})
},
}