-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathdeps_linux_arm64.go
More file actions
81 lines (69 loc) · 2.24 KB
/
Copy pathdeps_linux_arm64.go
File metadata and controls
81 lines (69 loc) · 2.24 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//go:build linux && arm64
// +build linux,arm64
package dependency
import (
"fmt"
"path/filepath"
"github.com/utmstack/UTMStack/agent/config"
"github.com/utmstack/UTMStack/shared/exec"
"github.com/utmstack/UTMStack/shared/fs"
"github.com/utmstack/UTMStack/shared/svc"
)
// GetDependencies returns the list of dependencies for Linux arm64.
// Linux arm64 uses integrated collectors, no beats needed.
func GetDependencies() []Dependency {
basePath := fs.GetExecutablePath()
return []Dependency{
{
Name: "updater",
Version: getUpdaterVersion(),
BinaryPath: filepath.Join(basePath, UpdaterFile("")),
DownloadURL: func(server string) string {
return fmt.Sprintf(config.DependUrl, server, config.DependenciesPort, UpdaterFile(""))
},
Critical: false,
PreDownload: preDownloadUpdater,
Configure: configureUpdater,
Uninstall: uninstallUpdater,
},
// Auditd dependency - auto-configures Linux audit daemon
// No download - installs from system package manager
{
Name: "auditd",
Version: AuditdVersion,
BinaryPath: "/sbin/auditctl", // Check if auditd tools exist
Critical: false,
Configure: configureAuditd,
Update: updateAuditdRules,
Uninstall: cleanupAuditd,
},
}
}
func configureUpdater() error {
updaterPath := filepath.Join(fs.GetExecutablePath(), UpdaterFile(""))
if err := exec.Run("chmod", fs.GetExecutablePath(), "755", updaterPath); err != nil {
return fmt.Errorf("error setting permissions on updater: %v", err)
}
return exec.Run(updaterPath, fs.GetExecutablePath(), "install")
}
func uninstallUpdater() error {
updaterPath := filepath.Join(fs.GetExecutablePath(), UpdaterFile(""))
if !fs.Exists(updaterPath) {
return nil
}
return exec.Run(updaterPath, fs.GetExecutablePath(), "uninstall")
}
func preDownloadUpdater() (func(), error) {
// Stop the updater service before download
if err := svc.Stop(config.SERVICE_UPDATER_NAME); err != nil {
// Service might not be running or installed yet - that's OK
// Return cleanup function anyway (safe to start)
return func() {
_ = svc.Start(config.SERVICE_UPDATER_NAME)
}, nil
}
// Return cleanup function that restarts the service
return func() {
_ = svc.Start(config.SERVICE_UPDATER_NAME)
}, nil
}