Files
ProjectOctopus/agent-go/a_init/BastionInitializaion.go
2024-04-17 15:02:41 +08:00

112 lines
2.4 KiB
Go

package a_init
import (
"bufio"
"fmt"
"os"
"strings"
"wdd.io/agent-go/a_agent"
"wdd.io/agent-go/a_init/bastion_init"
)
/*
完全离线模式
交互模式 手动运行 接受输入并且执行指令 类似于cli
1. 环境信息检测打印输出
2. 接受用户输入 执行指令
3. 功能
3.1 安装docker
3.2 安装docker-compose
3.3 安装minio
3.4 安装rabbitmq
3.5 安装kubernetes
*/
// BastionModeInit 堡垒机模式 完全离线模式
func BastionModeInit() {
// Build For Operator
_ = &a_agent.AgentServerInfo{
ServerName: "BastionSingle",
ServerIPPbV4: "127.0.0.1",
ServerIPInV4: "127.0.0.1",
ServerIPPbV6: "",
ServerIPInV6: "",
Location: "Bastion",
Provider: "Bastion",
ManagePort: "22",
CPUCore: "",
CPUBrand: "",
OSInfo: "",
OSKernelInfo: "",
TCPControl: "",
Virtualization: "",
Platform: "",
PlatformFamily: "",
PlatformVersion: "",
KernelVersion: "",
KernelArch: "",
IoSpeed: "",
MemoryTotal: "",
DiskTotal: "",
DiskUsage: "",
Comment: "",
MachineID: "",
AgentVersion: "",
TopicName: "BastionNode",
}
// re-get agentInfo from status module
//agentInfo := a_status.ReportAgentInfo()
//refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo)
//buildAgentOsOperator(agentInfo, agentServerInfo)
// install docker
//agentOsOperator := a_executor.AgentOsOperatorCache
// boot up minio & rabbitmq
//agentOsOperator.InstallDockerFromLocalExec(nil)
//agentOsOperator.InstallDockerComposeFromLocalExec()
// build for socks server
words := []string{"apple", "apricot", "apprentice", "application"}
t := bastion_init.NewTrie()
t.InsertAll(words)
prefix := "ap"
closest, err := bastion_init.FindClosestWord(t, prefix)
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("The closest word to '%s' is '%s'\n", prefix, closest)
}
reader := bufio.NewReader(os.Stdin)
for {
bastion_init.PrintBastionHelp()
fmt.Println()
fmt.Print("enter ==> ")
text, _ := reader.ReadString('\n')
text = strings.TrimSpace(text)
if text == "quit" {
break
} else if text == "help" {
bastion_init.PrintBastionHelp()
} else {
// Execute the command
fmt.Println("Executing command:", text)
}
}
}
// uniformInputCommand 归一化输入的命令
func uniformInputCommand(inputString string) {
}