|
9 | 9 | "groundseg/structs" |
10 | 10 | "io" |
11 | 11 | "io/ioutil" |
12 | | - "os/exec" |
13 | 12 | "path/filepath" |
14 | 13 | "strings" |
15 | 14 | "time" |
@@ -52,9 +51,6 @@ func init() { |
52 | 51 | version, err := cli.ServerVersion(context.TODO()) |
53 | 52 | if err != nil { |
54 | 53 | zap.L().Error(fmt.Sprintf("Error getting Docker version: %v", err)) |
55 | | - if strings.Contains(err.Error(), "is too new") { |
56 | | - updateDocker() |
57 | | - } |
58 | 54 | return |
59 | 55 | } |
60 | 56 | //go getContainerStats() |
@@ -97,63 +93,6 @@ func killContainerUsingPort(n uint16) error { |
97 | 93 | return nil |
98 | 94 | } |
99 | 95 |
|
100 | | -// attempt to update docker daemon (ubuntu/mint only) |
101 | | -func updateDocker() { |
102 | | - zap.L().Info("Unsupported Docker version detected -- attempting to upgrade") |
103 | | - packages := []string{"docker.io", "docker-doc", "docker-compose", "podman-docker", "containerd", "runc"} |
104 | | - for _, pkg := range packages { |
105 | | - out, err := exec.Command("apt-get", "remove", "-y", pkg).CombinedOutput() |
106 | | - if err != nil { |
107 | | - zap.L().Error(fmt.Sprintf("Couldn't update Docker: error removing package %s: %v\n%s", pkg, err, out)) |
108 | | - return |
109 | | - } |
110 | | - } |
111 | | - commands := []string{ |
112 | | - "apt-get update", |
113 | | - "apt-get install -y ca-certificates curl gnupg", |
114 | | - "install -m 0755 -d /etc/apt/keyrings", |
115 | | - `curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg`, // Added --yes |
116 | | - "chmod a+r /etc/apt/keyrings/docker.gpg", |
117 | | - } |
118 | | - for _, cmd := range commands { |
119 | | - out, err := exec.Command("sh", "-c", cmd).CombinedOutput() |
120 | | - if err != nil { |
121 | | - zap.L().Error(fmt.Sprintf("Error executing command '%s': %v\n%s", cmd, err, out)) |
122 | | - } |
123 | | - } |
124 | | - out, err := exec.Command("sh", "-c", ". /etc/os-release && echo $VERSION_CODENAME").Output() |
125 | | - if err != nil { |
126 | | - zap.L().Error(fmt.Sprintf("Couldn't update Docker: Error fetching version codename: %v\n%s", err, out)) |
127 | | - return |
128 | | - } |
129 | | - codename := strings.TrimSpace(string(out)) |
130 | | - if contains([]string{"ulyana", "ulyssa", "uma", "una"}, codename) { |
131 | | - codename = "focal" |
132 | | - } else if contains([]string{"vanessa", "vera", "victoria"}, codename) { |
133 | | - codename = "jammy" |
134 | | - } |
135 | | - archOut, archErr := exec.Command("sh", "-c", "dpkg --print-architecture").Output() |
136 | | - if archErr != nil { |
137 | | - zap.L().Error(fmt.Sprintf("Couldn't update Docker: Error fetching system architecture: %v\n%s", archErr, archOut)) |
138 | | - return |
139 | | - } |
140 | | - architecture := strings.TrimSpace(string(archOut)) |
141 | | - sourcesList := fmt.Sprintf("deb [arch=%s signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu %s stable", architecture, codename) |
142 | | - cmd := fmt.Sprintf("echo '%s' | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", sourcesList) |
143 | | - out, err = exec.Command("sh", "-c", cmd).CombinedOutput() |
144 | | - if err != nil { |
145 | | - zap.L().Error(fmt.Sprintf("Couldn't update Docker: Error updating Docker sources list: %v\n%s", err, out)) |
146 | | - return |
147 | | - } |
148 | | - dockerPackages := []string{"install", "-y", "docker-ce", "docker-ce-cli", "containerd.io"} |
149 | | - out, err = exec.Command("apt-get", dockerPackages...).CombinedOutput() |
150 | | - if err != nil { |
151 | | - zap.L().Error(fmt.Sprintf("Couldn't update Docker: Error installing Docker packages: %v\n%s", err, out)) |
152 | | - return |
153 | | - } |
154 | | - zap.L().Info("Successfully updated Docker") |
155 | | -} |
156 | | - |
157 | 96 | // return the container status of a slice of ships |
158 | 97 | func GetShipStatus(patps []string) (map[string]string, error) { |
159 | 98 | statuses := make(map[string]string) |
|
0 commit comments