更新工作区配置,删除不再使用的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

@@ -1,7 +1,7 @@
package cmd
import (
"agent-wdd/config"
"agent-wdd/host_info"
"agent-wdd/log"
"agent-wdd/op"
"agent-wdd/utils"
@@ -16,14 +16,14 @@ func addZshSubcommands(cmd *cobra.Command) {
// 初始化安装命令
utils.CreateFolder("/root/wdd")
if config.CanConnectInternet() <= 1 {
if host_info.CanConnectInternet() <= 1 {
log.Error("无法连接互联网无法安装zsh")
return
}
// 判定config
if config.ConfigCache.Agent.Network.Public.IPv4 == "" {
network := config.ConfigCache.Agent.Network
if host_info.ConfigCache.Agent.Network.Public.IPv4 == "" {
network := host_info.ConfigCache.Agent.Network
network.Gather()
network.SaveConfig()
}
@@ -41,7 +41,7 @@ func addZshSubcommands(cmd *cobra.Command) {
ohMyZshInstallUrl := ""
if config.ConfigCache.Agent.Network.Internet == 7 {
if host_info.ConfigCache.Agent.Network.Internet == 7 {
ohMyZshInstallUrl = "https://gitea.107421.xyz/zeaslity/ohmyzsh/raw/branch/master/tools/install.sh"
} else {
ohMyZshInstallUrl = "https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh"
@@ -65,7 +65,7 @@ func addZshSubcommands(cmd *cobra.Command) {
"/root/wdd/zsh-install.sh",
}
if config.ConfigCache.Agent.Network.Internet == 7 {
if host_info.ConfigCache.Agent.Network.Internet == 7 {
op.SingleLineCommandExecutor([]string{
"export",
"REMOTE=https://gitea.107421.xyz/zeaslity/ohmyzsh.git",
@@ -106,7 +106,7 @@ func addZshSubcommands(cmd *cobra.Command) {
}
// 下载插件
if config.ConfigCache.Agent.Network.Internet == 7 {
if host_info.ConfigCache.Agent.Network.Internet == 7 {
// 执行硬编码命令, 安装插件
for _, command := range pluginsHardCodeUrl {
op.SingleLineCommandExecutor([]string{"git", "clone", command[0], command[1]})