@@ -4,17 +4,15 @@ import (
4
4
"fmt"
5
5
"github.com/linuxsuren/http-downloader/pkg/exec"
6
6
"runtime"
7
- "strings"
8
- "time"
9
7
)
10
8
11
- // ConntrackInstallerInCentOS is the installer of Docker in CentOS
12
- type ConntrackInstallerInCentOS struct {
9
+ // conntrackInstallerInCentOS is the installer of Docker in CentOS
10
+ type conntrackInstallerInCentOS struct {
13
11
count int
14
12
}
15
13
16
14
// Available check if support current platform
17
- func (d * ConntrackInstallerInCentOS ) Available () (ok bool ) {
15
+ func (d * conntrackInstallerInCentOS ) Available () (ok bool ) {
18
16
if runtime .GOOS == "linux" {
19
17
_ , err := exec .LookPath ("yum" )
20
18
ok = err == nil
@@ -23,70 +21,35 @@ func (d *ConntrackInstallerInCentOS) Available() (ok bool) {
23
21
}
24
22
25
23
// Install installs the Docker
26
- func (d * ConntrackInstallerInCentOS ) Install () (err error ) {
24
+ func (d * conntrackInstallerInCentOS ) Install () (err error ) {
27
25
if err = exec .RunCommand ("yum" , "install" , "-y" ,
28
- "yum-utils" ); err != nil {
29
- return
30
- }
31
- if err = exec .RunCommand ("yum-config-manager" , "--add-repo" ,
32
- "https://download.docker.com/linux/centos/docker-ce.repo" ); err != nil {
33
- return
34
- }
35
- if err = exec .RunCommand ("yum" , "install" , "-y" ,
36
- "docker-ce" ,
37
- "docker-ce-cli" ,
38
- "containerd.io" ); err != nil {
26
+ "conntrack" ); err != nil {
39
27
return
40
28
}
41
29
return
42
30
}
43
31
44
32
// Uninstall uninstalls the Docker
45
- func (d * ConntrackInstallerInCentOS ) Uninstall () (err error ) {
33
+ func (d * conntrackInstallerInCentOS ) Uninstall () (err error ) {
46
34
err = exec .RunCommand ("yum" , "remove" , "-y" ,
47
- "docker" ,
48
- "docker-client" ,
49
- "docker-client-latest" ,
50
- "docker-common" ,
51
- "docker-latest" ,
52
- "docker-latest-logrotate" ,
53
- "docker-logrotate" ,
54
- "docker-engine" ,
55
- "docker-ce" ,
56
- "docker-ce-cli" ,
57
- "containerd.io" )
35
+ "conntrack" )
58
36
return
59
37
}
60
38
61
39
// WaitForStart waits for the service be started
62
- func (d * ConntrackInstallerInCentOS ) WaitForStart () (ok bool , err error ) {
63
- var result string
64
- if result , err = exec .RunCommandAndReturn ("systemctl" , "" , "status" , "docker" ); err != nil {
65
- return
66
- } else if strings .Contains (result , "Unit docker.service could not be found" ) {
67
- err = fmt .Errorf ("unit docker.service could not be found" )
68
- } else if strings .Contains (result , "Active: active" ) {
69
- ok = true
70
- } else {
71
- if d .count > 0 {
72
- fmt .Println ("waiting for Docker service start" )
73
- } else if d .count > 9 {
74
- return
75
- }
76
-
77
- d .count ++
78
- time .Sleep (time .Second * 1 )
79
- return d .WaitForStart ()
80
- }
40
+ func (d * conntrackInstallerInCentOS ) WaitForStart () (ok bool , err error ) {
41
+ ok = true
81
42
return
82
43
}
83
44
84
45
// Start starts the Docker service
85
- func (d * ConntrackInstallerInCentOS ) Start () error {
86
- return exec .RunCommand ("systemctl" , "start" , "docker" )
46
+ func (d * conntrackInstallerInCentOS ) Start () error {
47
+ fmt .Println ("not supported yet" )
48
+ return nil
87
49
}
88
50
89
51
// Stop stops the Docker service
90
- func (d * ConntrackInstallerInCentOS ) Stop () error {
91
- return exec .RunCommand ("systemctl" , "stop" , "docker" )
52
+ func (d * conntrackInstallerInCentOS ) Stop () error {
53
+ fmt .Println ("not supported yet" )
54
+ return nil
92
55
}
0 commit comments