-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathcmd_uninstall.go
46 lines (36 loc) · 979 Bytes
/
cmd_uninstall.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
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
var uninstallCommand = cli.Command{
Name: "uninstall",
Usage: "completely remove dlite",
Description: "remove the user's virtual machine as well as the system service and reset all configuration changes",
Action: func(ctx *cli.Context) error {
var hostname string
var home string
if err := spin("Removing virtual machine", func() error {
stringRequest("stop")
currentUser := getUser()
home = currentUser.Home
basePath := getPath(currentUser)
cfg, err := readConfig(basePath)
if err != nil {
return err
}
hostname = cfg.Hostname
err = removeSSHConfig(currentUser, hostname)
if err != nil {
return err
}
return os.RemoveAll(basePath)
}); err.ExitCode() != 0 {
return err
}
fmt.Println("")
fmt.Println("Next we'll run a few steps that require sudo, you may be prompted for your password.")
return runCleanup(hostname, home)
},
}