package main

import (
	"flag"
	"fmt"
	"wdd.io/agent-common/logger"
	"wdd.io/agent-go/a_init"
)

var log = logger.Log

// C:\Users\wddsh\go\bin\gox.exe -osarch="linux/amd64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"
// /root/go/bin/gox -osarch="linux/amd64" -output "build/octopus-agent_{{.OS}}_{{.Arch}}"

// bash <(curl -sL http://172.28.0.10:9000/octopus/init-script-wdd.sh) --offline --url http://172.28.0.10:9000 --agent-install
//
//
//
//wget http://172.28.0.10/octopus-agent/octopus-agent_linux_amd64_2024-05-10-10-53-24 -O octopus-agent && systemctl restart octopus-agent && journalctl -u octopus-agent.service -n 200 -f

func main() {

	// 解析命令行参数
	var version string
	//var agentServerInfoConfFile string
	var mode string
	flag.StringVar(&version, "version", "", "config file version")
	flag.StringVar(&mode, "mode", "agent", "agent run mode")
	//flag.StringVar(&agentServerInfoConfFile, "agentServerInfoConfFile", "", "agent server info conf file")
	flag.Parse()

	if mode == "bastion" {
		// 堡垒机模式
		// 初始化堡垒机模式
		a_init.BastionModeInit()
		return
	}

	// 读取对应版本的配置文件
	octopusAgentConfigFileName := fmt.Sprintf("octopus-agent-%s.yaml", version)
	fmt.Println("config file name is => " + octopusAgentConfigFileName)
	//fmt.Println("agent server info file is => " + agentServerInfoConfFile)

	// 执行初始化之策工作
	businessForeverChan := a_init.INIT(octopusAgentConfigFileName)

	// 永远等待 runtime的队列消息
	<-businessForeverChan

}
