mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-23 18:01:43 +01:00
implement system mode agent
This commit is contained in:
24
agent/pkg/agent/bare_metal.go
Normal file
24
agent/pkg/agent/bare_metal.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
installScript = `AGENT_NAME={{.Name}} \
|
||||
AGENT_PORT={{.Port}} \
|
||||
AGENT_CA_CERT={{.CACert}} \
|
||||
AGENT_SSL_CERT={{.SSLCert}} \
|
||||
bash -c "$(curl -fsSL https://raw.githubusercontent.com/yusing/go-proxy/main/scripts/install-agent.sh)"`
|
||||
installScriptTemplate = template.Must(template.New("install.sh").Parse(installScript))
|
||||
)
|
||||
|
||||
func (c *AgentEnvConfig) Generate() (string, error) {
|
||||
buf := bytes.NewBuffer(make([]byte, 0, 4096))
|
||||
if err := installScriptTemplate.Execute(buf, c); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.ReplaceAll(buf.String(), ";", "\\;"), nil
|
||||
}
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed agent.compose.yml
|
||||
var agentComposeYAML string
|
||||
var agentComposeYAMLTemplate = template.Must(template.New("agent.compose.yml").Parse(agentComposeYAML))
|
||||
var (
|
||||
//go:embed templates/agent.compose.yml
|
||||
agentComposeYAML string
|
||||
agentComposeYAMLTemplate = template.Must(template.New("agent.compose.yml").Parse(agentComposeYAML))
|
||||
)
|
||||
|
||||
const (
|
||||
DockerImageProduction = "ghcr.io/yusing/godoxy-agent:latest"
|
||||
|
||||
17
agent/pkg/agent/env.go
Normal file
17
agent/pkg/agent/env.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package agent
|
||||
|
||||
type (
|
||||
AgentEnvConfig struct {
|
||||
Name string
|
||||
Port int
|
||||
CACert string
|
||||
SSLCert string
|
||||
}
|
||||
AgentComposeConfig struct {
|
||||
Image string
|
||||
*AgentEnvConfig
|
||||
}
|
||||
Generator interface {
|
||||
Generate() (string, error)
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user