更新工作区配置,删除不再使用的Cloudflare相关文件,优化日志输出格式,增强主机信息收集功能,调整代码结构以提高可维护性。

This commit is contained in:
zeaslity
2025-03-28 00:15:08 +08:00
parent c2ca7eb6d7
commit 6816638267
19 changed files with 847 additions and 155 deletions

View File

@@ -2,7 +2,7 @@ package cmd
import (
"agent-wdd/cmd/beans"
"agent-wdd/config"
"agent-wdd/host_info"
"agent-wdd/log"
"agent-wdd/op"
"agent-wdd/utils"
@@ -96,13 +96,13 @@ func addBaseSubcommands(cmd *cobra.Command) {
log.Info("Selinux 关闭!")
// 如果configCache的OS为空则收集OS信息
if config.ConfigCache.Agent.OS.Hostname == "" {
if host_info.ConfigCache.Agent.OS.Hostname == "" {
log.Warning("ConfigCache OS is nil")
config.ConfigCache.Agent.OS.Gather()
config.ConfigCache.Agent.OS.SaveConfig()
host_info.ConfigCache.Agent.OS.Gather()
host_info.ConfigCache.Agent.OS.SaveConfig()
}
os := config.ConfigCache.Agent.OS
os := host_info.ConfigCache.Agent.OS
if os.IsUbuntuType {
log.Info("Ubuntu 系统跳过关闭selinux")
return
@@ -234,7 +234,7 @@ func addBaseSubcommands(cmd *cobra.Command) {
log.Info("Common tool installation!")
// Whether It can connect to internet
if config.CanConnectInternet() <= 1 {
if host_info.CanConnectInternet() <= 1 {
log.Error("服务器无法连接互联网无法执行tools")
return
}
@@ -244,7 +244,7 @@ func addBaseSubcommands(cmd *cobra.Command) {
packOperator := op.AgentPackOperator
packOperator.PackageInit()
os := config.ConfigCache.Agent.OS
os := host_info.ConfigCache.Agent.OS
if os.IsUbuntuType {
packOperator.Install(ubuntuCommonTools)
} else {
@@ -299,7 +299,7 @@ func addHarborSubcommands(harborCmd *cobra.Command) {
utils.UnzipFile(harborLocalInstallPath, "/root/wdd/")
// 获取本机的内网IPv4地址
configCache := config.ConfigCache
configCache := host_info.ConfigCache
if len(configCache.Agent.Network.Interfaces) == 0 {
log.Error("没有获取到本机的ipv4地址无法安装harbor! 请执行 info all !")
}
@@ -596,7 +596,7 @@ func addDockerSubcommands(cmd *cobra.Command) {
packOperator := op.AgentPackOperator
packOperator.PackageInit()
configCache := config.ConfigCache
configCache := host_info.ConfigCache
if configCache.Agent.OS.IsUbuntuType {
// 安装apt-transport-https ca-certificates curl gnupg software-properties-common 依赖部分
packOperator.Install([]string{"apt-transport-https", "ca-certificates", "curl", "gnupg", "software-properties-common"})
@@ -886,7 +886,7 @@ func addDockerSubcommands(cmd *cobra.Command) {
}
// 获取当前内网IP
ip := config.ConfigCache.Agent.Network.Interfaces[0].IPv4
ip := host_info.ConfigCache.Agent.Network.Interfaces[0].IPv4
if ip == "" {
log.Error("获取当前内网IP失败, 无法进行docker config配置")
return
@@ -956,7 +956,7 @@ func addDockerComposeSubcommands(cmd *cobra.Command) {
log.Info("安装 Docker Compose 版本: %s", version)
// 检查是否可以连接互联网
if config.CanConnectInternet() <= 1 {
if host_info.CanConnectInternet() <= 1 {
log.Error("服务器无法连接互联网,无法在线安装 Docker Compose")
return
}