Enhance Docker Installation and Management Commands

- Improved Docker installation process for Ubuntu systems
- Added support for dynamic Docker version detection
- Enhanced Docker local and online installation commands
- Implemented more robust Docker removal functionality
- Updated Docker installation to use system-specific package sources
- Added better error handling and logging for Docker operations
- Refined Docker service startup and configuration checks
This commit is contained in:
zeaslity
2025-02-28 17:45:12 +08:00
parent bffb643a56
commit 5c39bd7594
16 changed files with 586 additions and 86 deletions

View File

@@ -26,7 +26,8 @@ func (o *OS) Gather() {
o.Hostname = hostname
}
o.OsType = "linux" // 固定为linux
o.OsType = "linux" // 固定为linux
o.IsUbuntuType = true // 默认为ubuntu
// 解析系统信息
file, err := os.Open("/etc/os-release")
@@ -78,12 +79,30 @@ func (o *OS) Gather() {
}
// 检查包管理的方式
c := exec.Command("command", "-v", "apt")
_, err = c.Output()
if err == nil {
o.IsUbuntuType = true
if strings.Contains(o.OsFamily, "centos") || strings.Contains(o.OsFamily, "rhel") {
o.IsUbuntuType = false
}
// 获取系统架构
o.Arch = runtime.GOARCH
// 获取系统发行版代号
o.OSReleaseCode = judgeUbuntuReleaseFromOsVersion(o.OsVersion)
}
func judgeUbuntuReleaseFromOsVersion(osVersion string) string {
switch osVersion {
case "16.04":
return "xenial"
case "18.04":
return "bionic"
case "20.04":
return "focal"
case "22.04":
return "jammy"
default:
return "ubuntu-unknown"
}
}