[ Agent ] [ Executor ] - agent启动脚本
This commit is contained in:
59
agent-go/main-dev.go
Normal file
59
agent-go/main-dev.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"agent-go/executor"
|
||||||
|
logger2 "agent-go/logger"
|
||||||
|
"agent-go/register"
|
||||||
|
)
|
||||||
|
|
||||||
|
var log = logger2.Log
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
var agentOP = &executor.AgentOsOperator{
|
||||||
|
InstallCommandPrefix: []string{
|
||||||
|
"apt-get", "install", "--allow-downgrades", "-y",
|
||||||
|
},
|
||||||
|
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
|
||||||
|
CanAccessInternet: true,
|
||||||
|
IsOsTypeUbuntu: true,
|
||||||
|
IsAgentInnerWall: false,
|
||||||
|
AgentArch: "amd64",
|
||||||
|
AgentOSReleaseCode: "focal",
|
||||||
|
AgentServerInfo: ®ister.AgentServerInfo{
|
||||||
|
ServerName: "",
|
||||||
|
ServerIPPbV4: "158.247.241.43",
|
||||||
|
ServerIPInV4: "10.0.4.6",
|
||||||
|
ServerIPPbV6: "",
|
||||||
|
ServerIPInV6: "",
|
||||||
|
Location: "",
|
||||||
|
Provider: "",
|
||||||
|
ManagePort: "",
|
||||||
|
CPUCore: "",
|
||||||
|
CPUBrand: "",
|
||||||
|
OSInfo: "",
|
||||||
|
OSKernelInfo: "",
|
||||||
|
TCPControl: "",
|
||||||
|
Virtualization: "",
|
||||||
|
IoSpeed: "",
|
||||||
|
MemoryTotal: "",
|
||||||
|
DiskTotal: "",
|
||||||
|
DiskUsage: "",
|
||||||
|
Comment: "",
|
||||||
|
MachineID: "",
|
||||||
|
AgentVersion: "",
|
||||||
|
TopicName: "",
|
||||||
|
},
|
||||||
|
OssOfflinePrefix: "https://oss-s1.107421.xyz/",
|
||||||
|
}
|
||||||
|
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("shutdownFirewall"))
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("modifyHostname", "seoul-amd64-07"))
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("disableSwap"))
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("removeDocker"))
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("installDocker", "20"))
|
||||||
|
//executor.BasicPrettyPrint(agentOP.Exec("removeDockerCompose"))
|
||||||
|
executor.BasicPrettyPrint(agentOP.Exec("installDockerCompose"))
|
||||||
|
executor.BasicPrettyPrint(agentOP.Exec("installZSH"))
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
//import (
|
|
||||||
// "agent-go/g"
|
|
||||||
// logger2 "agent-go/logger"
|
|
||||||
// "agent-go/register"
|
|
||||||
// "flag"
|
|
||||||
// "fmt"
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//var log = logger2.Log
|
|
||||||
//
|
|
||||||
//func main() {
|
|
||||||
//
|
|
||||||
// // 解析命令行参数
|
|
||||||
// var version string
|
|
||||||
// var agentServerInfoConf string
|
|
||||||
// flag.StringVar(&version, "version", "", "config file version")
|
|
||||||
// flag.StringVar(&agentServerInfoConf, "agentServerInfoConf", "", "agent server info conf file")
|
|
||||||
// flag.Parse()
|
|
||||||
// // 读取对应版本的配置文件
|
|
||||||
// filename := fmt.Sprintf("octopus-agent-%s.yaml", version)
|
|
||||||
// println("config file name is => " + filename)
|
|
||||||
// println("agent server info file is => " + agentServerInfoConf)
|
|
||||||
//
|
|
||||||
// // 初始化Nacos的连接配置
|
|
||||||
// g.G.AgentConfig = register.ParseConfiguration(filename)
|
|
||||||
//
|
|
||||||
// // 执行初始化之策工作
|
|
||||||
// businessForeverChan := INIT(agentServerInfoConf)
|
|
||||||
//
|
|
||||||
// // 永远等待 runtime的队列消息
|
|
||||||
// <-businessForeverChan
|
|
||||||
//}
|
|
||||||
@@ -1,59 +1,34 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
//import (
|
||||||
"agent-go/executor"
|
// "agent-go/g"
|
||||||
logger2 "agent-go/logger"
|
// logger2 "agent-go/logger"
|
||||||
"agent-go/register"
|
// "agent-go/register"
|
||||||
)
|
// "flag"
|
||||||
|
// "fmt"
|
||||||
var log = logger2.Log
|
//)
|
||||||
|
//
|
||||||
func main() {
|
//var log = logger2.Log
|
||||||
|
//
|
||||||
var agentOP = &executor.AgentOsOperator{
|
//func main() {
|
||||||
InstallCommandPrefix: []string{
|
//
|
||||||
"apt-get", "install", "--allow-downgrades", "-y",
|
// // 解析命令行参数
|
||||||
},
|
// var version string
|
||||||
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
|
// var agentServerInfoConf string
|
||||||
CanAccessInternet: true,
|
// flag.StringVar(&version, "version", "", "config file version")
|
||||||
IsOsTypeUbuntu: true,
|
// flag.StringVar(&agentServerInfoConf, "agentServerInfoConf", "", "agent server info conf file")
|
||||||
IsAgentInnerWall: false,
|
// flag.Parse()
|
||||||
AgentArch: "amd64",
|
// // 读取对应版本的配置文件
|
||||||
AgentOSReleaseCode: "focal",
|
// filename := fmt.Sprintf("octopus-agent-%s.yaml", version)
|
||||||
AgentServerInfo: ®ister.AgentServerInfo{
|
// println("config file name is => " + filename)
|
||||||
ServerName: "",
|
// println("agent server info file is => " + agentServerInfoConf)
|
||||||
ServerIPPbV4: "158.247.241.43",
|
//
|
||||||
ServerIPInV4: "10.0.4.6",
|
// // 初始化Nacos的连接配置
|
||||||
ServerIPPbV6: "",
|
// g.G.AgentConfig = register.ParseConfiguration(filename)
|
||||||
ServerIPInV6: "",
|
//
|
||||||
Location: "",
|
// // 执行初始化之策工作
|
||||||
Provider: "",
|
// businessForeverChan := INIT(agentServerInfoConf)
|
||||||
ManagePort: "",
|
//
|
||||||
CPUCore: "",
|
// // 永远等待 runtime的队列消息
|
||||||
CPUBrand: "",
|
// <-businessForeverChan
|
||||||
OSInfo: "",
|
//}
|
||||||
OSKernelInfo: "",
|
|
||||||
TCPControl: "",
|
|
||||||
Virtualization: "",
|
|
||||||
IoSpeed: "",
|
|
||||||
MemoryTotal: "",
|
|
||||||
DiskTotal: "",
|
|
||||||
DiskUsage: "",
|
|
||||||
Comment: "",
|
|
||||||
MachineID: "",
|
|
||||||
AgentVersion: "",
|
|
||||||
TopicName: "",
|
|
||||||
},
|
|
||||||
OssOfflinePrefix: "https://oss-s1.107421.xyz/",
|
|
||||||
}
|
|
||||||
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("shutdownFirewall"))
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("modifyHostname", "seoul-amd64-07"))
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("disableSwap"))
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("removeDocker"))
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("installDocker", "20"))
|
|
||||||
//executor.BasicPrettyPrint(agentOP.Exec("removeDockerCompose"))
|
|
||||||
executor.BasicPrettyPrint(agentOP.Exec("installDockerCompose"))
|
|
||||||
executor.BasicPrettyPrint(agentOP.Exec("installZSH"))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
OctopusAgentUrl=https://happybirthday.107421.xyz/octopus-agent/
|
OctopusAgentUrl=https://happybirthday.107421.xyz/octopus-agent/
|
||||||
OctopusAgentShell=https://happybirthday.107421.xyz/octopus-agent/shell
|
OctopusAgentShell=https://happybirthday.107421.xyz/shell
|
||||||
AgentConfigUrl=https://happybirthday.107421.xyz/agent-config/
|
AgentConfigUrl=https://happybirthday.107421.xyz/agent-config
|
||||||
OctopusAgentPath=/octopus-agent/shell
|
OctopusAgentPath=/octopus-agent/shell
|
||||||
##### environment variables ######
|
##### environment variables ######
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ CheckAndDownloadLatestVersion() {
|
|||||||
|
|
||||||
for agentConfig in "${agentConfigFileList[@]}"; do
|
for agentConfig in "${agentConfigFileList[@]}"; do
|
||||||
colorEcho $BLUE "agent config file is => $agentConfig"
|
colorEcho $BLUE "agent config file is => $agentConfig"
|
||||||
wget -q "$AgentConfigUrl$agentConfig"
|
wget -q "$AgentConfigUrl/$agentConfig"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -372,7 +372,10 @@ BootUPAgent() {
|
|||||||
colorEcho $BLUE "开始配置Agent启动的基础环境信息!"
|
colorEcho $BLUE "开始配置Agent启动的基础环境信息!"
|
||||||
wget ${OctopusAgentShell}/octopus-env.sh -qO $OctopusAgentPath/lib/octopus-env.sh
|
wget ${OctopusAgentShell}/octopus-env.sh -qO $OctopusAgentPath/lib/octopus-env.sh
|
||||||
chmod +x $OctopusAgentPath/lib/octopus-env.sh
|
chmod +x $OctopusAgentPath/lib/octopus-env.sh
|
||||||
|
echo ""
|
||||||
|
colorEcho $BLUE "开始获取Agent的系统信息!"
|
||||||
$OctopusAgentPath/lib/octopus-env.sh
|
$OctopusAgentPath/lib/octopus-env.sh
|
||||||
|
echo ""
|
||||||
|
|
||||||
colorEcho $BLUE "start to daemon the octopus agent"
|
colorEcho $BLUE "start to daemon the octopus agent"
|
||||||
systemdAgent
|
systemdAgent
|
||||||
|
|||||||
Reference in New Issue
Block a user