-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuninstall.go
37 lines (31 loc) · 882 Bytes
/
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
package main
import (
"fmt"
"os/exec"
"github.com/ramantehlan/mateix/packages/command"
)
// Uninstall is to delete the mateix tool from the system
func Uninstall() {
var files = []string{
"/usr/bin/mateix",
"/usr/bin/mateixWatch",
"/etc/systemd/system/multi-user.target.wants/mateix-watch.service",
"/etc/systemd/system/mateix-watch.service",
"/etc/.mateix",
}
fmt.Println("Service stopped")
command.Execute(exec.Command("sudo", "mateixWatch", "stop"))
for file := range files {
if command.FileExist(files[file]) {
fi := command.GetStat(files[file])
switch mode := fi.Mode(); {
case mode.IsDir():
command.Execute(exec.Command("sudo", "rm", "-r", files[file]))
fmt.Println("Removed ", files[file])
case mode.IsRegular():
command.Execute(exec.Command("sudo", "rm", files[file]))
fmt.Println("Removed ", files[file])
}
}
}
}