updated for unix build
This commit is contained in:
parent
66aca05028
commit
e20edcc9ad
37 changed files with 1001 additions and 257 deletions
|
|
@ -1,6 +1,10 @@
|
|||
package mesh
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/system"
|
||||
"github.com/amidaware/rmmagent/agent/tactical/api"
|
||||
"github.com/amidaware/rmmagent/agent/tactical/config"
|
||||
"github.com/amidaware/rmmagent/agent/utils"
|
||||
|
|
@ -26,3 +30,23 @@ func SyncMeshNodeID() error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMeshNodeID() (string, error) {
|
||||
out, err := system.CMD(GetMeshBinLocation(), []string{"-nodeid"}, 10, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
stdout := out[0]
|
||||
stderr := out[1]
|
||||
|
||||
if stderr != "" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if stdout == "" || strings.Contains(strings.ToLower(utils.StripAll(stdout)), "not defined") {
|
||||
return "", errors.New("failed to get mesh node id")
|
||||
}
|
||||
|
||||
return stdout, nil
|
||||
}
|
||||
24
agent/tactical/mesh/mesh_unix.go
Normal file
24
agent/tactical/mesh/mesh_unix.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package mesh
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/amidaware/rmmagent/agent/tactical/config"
|
||||
)
|
||||
|
||||
func GetMeshBinLocation() string {
|
||||
ac := config.NewAgentConfig()
|
||||
var MeshSysBin string
|
||||
if len(ac.CustomMeshDir) > 0 {
|
||||
MeshSysBin = filepath.Join(ac.CustomMeshDir, "meshagent")
|
||||
} else {
|
||||
MeshSysBin = "/opt/tacticalmesh/meshagent"
|
||||
}
|
||||
|
||||
return MeshSysBin
|
||||
}
|
||||
|
||||
func RecoverMesh() { }
|
||||
|
|
@ -41,27 +41,7 @@ func ForceKillMesh() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func GetMeshNodeID() (string, error) {
|
||||
out, err := system.CMD(getMeshBinLocation(), []string{"-nodeid"}, 10, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
stdout := out[0]
|
||||
stderr := out[1]
|
||||
|
||||
if stderr != "" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if stdout == "" || strings.Contains(strings.ToLower(utils.StripAll(stdout)), "not defined") {
|
||||
return "", errors.New("failed to get mesh node id")
|
||||
}
|
||||
|
||||
return stdout, nil
|
||||
}
|
||||
|
||||
func getMeshBinLocation() string {
|
||||
func GetMeshBinLocation() string {
|
||||
ac := config.NewAgentConfig()
|
||||
var MeshSysBin string
|
||||
if len(ac.CustomMeshDir) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue