-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathcmd_rpm.go
64 lines (53 loc) · 1.62 KB
/
cmd_rpm.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
54
55
56
57
58
59
60
61
62
63
64
package deploy
import (
"fmt"
"path"
"strings"
"github.com/housepower/ckman/common"
)
type RpmFacotry struct{}
const (
rpmPrefix string = "DEBIAN_FRONTEND=noninteractive rpm --force --nosignature --nodeps"
)
func (RpmFacotry) Create() CmdAdpt {
return &RpmPkg{}
}
type RpmPkg struct{}
func (p *RpmPkg) StartCmd(svr, cwd string) string {
return "systemctl start " + svr
}
func (p *RpmPkg) StopCmd(svr, cwd string) string {
return "systemctl stop " + svr
}
func (p *RpmPkg) RestartCmd(svr, cwd string) string {
return "systemctl restart " + svr
}
func (p *RpmPkg) InstallCmd(svr string, pkgs Packages) string {
var cmd string
if svr == CkSvrName {
for _, pkg := range pkgs.PkgLists {
cmd += fmt.Sprintf("%s -ivh %s;", rpmPrefix, path.Join(common.TmpWorkDirectory, pkg))
}
} else if svr == KeeperSvrName {
cmd += fmt.Sprintf("%s -ivh %s;", rpmPrefix, path.Join(common.TmpWorkDirectory, pkgs.Keeper))
}
return strings.TrimSuffix(cmd, ";")
}
func (p *RpmPkg) UpgradeCmd(svr string, pkgs Packages) string {
var cmd string
if svr == CkSvrName {
for _, pkg := range pkgs.PkgLists {
cmd += fmt.Sprintf("%s -Uvh %s;", rpmPrefix, path.Join(common.TmpWorkDirectory, pkg))
}
} else if svr == KeeperSvrName {
cmd += fmt.Sprintf("%s -Uvh %s;", rpmPrefix, path.Join(common.TmpWorkDirectory, pkgs.Keeper))
}
return strings.TrimSuffix(cmd, ";")
}
func (p *RpmPkg) Uninstall(svr string, pkgs Packages, version string) string {
if svr == KeeperSvrName {
return fmt.Sprintf("rpm -e $(rpm -qa |grep clickhouse-keeper |grep %s)", version)
} else {
return fmt.Sprintf("rpm -e $(rpm -qa |grep clickhouse |grep %s)", version)
}
}