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

@@ -46,7 +46,7 @@ func GetInterfaces() []Interface {
// 获取所有网卡信息
netInterfaces, err := net.Interfaces()
log.Info("all network interfaces: %v", netInterfaces)
// log.Info("all network interfaces: %v", netInterfaces)
if err != nil {
log.Error("获取网卡信息失败: %v", err)
return interfaces
@@ -120,17 +120,35 @@ func judgeCanConnectInternet() int {
Timeout: 3 * time.Second,
}
_, err := client.Get("https://www.google.com")
if err == nil {
return 9
results := make(chan int, 2)
go func() {
_, err := client.Get("https://www.google.com")
if err == nil {
results <- 9
} else {
results <- 1
}
}()
go func() {
_, err := client.Get("https://www.baidu.com")
if err == nil {
results <- 7
} else {
results <- 1
}
}()
maxResult := 1
for i := 0; i < 2; i++ {
result := <-results
if result > maxResult {
maxResult = result
}
}
_, err = client.Get("https://www.baidu.com")
if err == nil {
return 7
}
return 1
return maxResult
}
// GetPublicInfo 获取服务器的公网信息
@@ -194,13 +212,14 @@ func (p PublicInfo) GetPublicInfo() PublicInfo {
}
// 打印解析结果
log.Info("IP信息:\n%+v\n", info)
// log.Info("IP信息:\n%+v\n", info)
// 保存信息
p.IPv4 = info.IP
p.ASN = info.Org
p.Country = info.Country
p.City = info.City
p.Timezone = info.Timezone
ConfigCache.Agent.Network.Public = p