-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.go
More file actions
51 lines (43 loc) · 1007 Bytes
/
uninstall.go
File metadata and controls
51 lines (43 loc) · 1007 Bytes
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
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
)
func uninstall() error {
path, err := getMyPath()
if err != nil {
return err
}
switch runtime.GOOS {
case "windows":
result, err := execute("nssm.exe", path, "stop", "utmstack")
if err {
return fmt.Errorf("%s", result)
}
result, err = execute("nssm.exe", path, "remove", "utmstack", "confirm")
if err {
return fmt.Errorf("%s", result)
}
case "linux":
result, err := execute("systemctl", path, "disable", "utmstack")
if err {
return fmt.Errorf("%s", result)
}
result, err = execute("systemctl", path, "stop", "utmstack")
if err {
return fmt.Errorf("%s", result)
}
result, err = execute("rm", path, filepath.Join("/", "etc", "systemd", "system", "utmstack.service"))
if err {
return fmt.Errorf("%s", result)
}
result, err = execute("systemctl", path, "daemon-reload")
if err {
return fmt.Errorf("%s", result)
}
}
os.Remove(filepath.Join(path, "config.yml"))
return nil
}