-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.go
More file actions
59 lines (50 loc) · 1.16 KB
/
install.go
File metadata and controls
59 lines (50 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"os"
"strconv"
"time"
)
func install(ip, utmKey, skip string) {
var insecure bool
if skip == "yes" {
insecure = true
}
hostName, err := os.Hostname()
if err != nil {
h.Error("can't get the hostname: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
agent, err := registerAgent(AGENTMANAGERPROTO+"://"+ip+":"+strconv.Itoa(AGENTMANAGERPORT), hostName, utmKey, insecure)
if err != nil {
h.Error("can't register agent: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
cnf := config{Server: ip, AgentID: agent.ID, AgentKey: agent.Key, SkipCertValidation: insecure}
err = writeConfig(cnf)
if err != nil {
h.Error("can't write agent config: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
err = configureBeat(ip)
if err != nil {
h.Error("can't configure beat: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
err = configureWazuh(ip, cnf.AgentKey)
if err != nil {
h.Error("can't configure wazuh: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
err = autoStart()
if err != nil {
h.Error("can't configure agent service: %v", err)
time.Sleep(10 * time.Second)
os.Exit(1)
}
os.Exit(0)
}