[agent-wdd] 完成Excecutor和Operator部分,完成base tools部分

This commit is contained in:
zeaslity
2025-02-14 17:17:55 +08:00
parent dabf63f10f
commit ce0395ae66
12 changed files with 380 additions and 23 deletions

View File

@@ -1,10 +1,22 @@
package cmd
import (
"agent-wdd/config"
"agent-wdd/log"
"agent-wdd/op"
"fmt"
"github.com/spf13/cobra"
)
var (
ubuntuCommonTools = []string{
"iputils-ping", "net-tools", "dnsutils", "lsof", "curl", "wget", "mtr-tiny", "vim", "htop", "lrzsz",
}
centosCommonTools = []string{
"deltarpm", "net-tools", "iputils", "bind-utils", "lsof", "curl", "wget", "vim", "mtr", "htop",
}
)
// 添加base子命令
func addBaseSubcommands(cmd *cobra.Command) {
// 1.1 docker
@@ -23,9 +35,37 @@ func addBaseSubcommands(cmd *cobra.Command) {
// 其他base子命令...
// 通用工具安装
commonToolsInstall := &cobra.Command{
Use: "tools",
Short: "通用工具安装 利用本机的yumapt等从网络安装常用的软件",
Run: func(cmd *cobra.Command, args []string) {
log.Info("Common tool installation!")
// Whether It can connect to internet
if config.CanConnectInternet() <= 1 {
log.Error("服务器无法连接互联网无法执行tools")
return
}
// package install
// only support ubuntu(debian) centos(debian openEuler)
packOperator := op.AgentPackOperator
packOperator.PackageInit()
os := config.ConfigCache.Agent.OS
if os.IsUbuntuType {
packOperator.Install(ubuntuCommonTools)
} else {
packOperator.Install(centosCommonTools)
}
},
}
cmd.AddCommand(
dockerCmd,
dockerComposeCmd,
commonToolsInstall,
// 其他命令...
)
}
@@ -64,10 +104,3 @@ func addDockerSubcommands(cmd *cobra.Command) {
func addDockerComposeSubcommands(cmd *cobra.Command) {
}
// addToolsSubcommands 利用本机的yumapt等从网络安装常用的软件
func addToolsSubcommands(cmd *cobra.Command) {
// 检测本机使用的包安装方式为apt还是yum
// 检查本机
//
}