[agent-wdd] 完成Excecutor和Operator部分,完成base tools部分
This commit is contained in:
@@ -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: "通用工具安装 利用本机的yum,apt等从网络安装常用的软件",
|
||||
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 利用本机的yum,apt等从网络安装常用的软件
|
||||
func addToolsSubcommands(cmd *cobra.Command) {
|
||||
// 检测本机使用的包安装方式为apt还是yum
|
||||
// 检查本机
|
||||
//
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user