updates for testing and windows
This commit is contained in:
parent
dfe2881cd5
commit
30123bc023
@ -797,7 +797,7 @@ func (a *Agent) RecoverMesh() {
|
||||
}
|
||||
|
||||
func (a *Agent) getMeshNodeID() (string, error) {
|
||||
out, err := CMD(a.MeshSystemEXE, []string{"-nodeid"}, 10, false)
|
||||
out, err := CMD(a.MeshSystemBin, []string{"-nodeid"}, 10, false)
|
||||
if err != nil {
|
||||
a.Logger.Debugln(err)
|
||||
return "", err
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/amidaware/rmmagent/shared"
|
||||
"github.com/go-resty/resty/v2"
|
||||
trmm "github.com/wh1te909/trmm-shared"
|
||||
)
|
||||
@ -251,10 +252,16 @@ func (a *Agent) Install(i *Installer) {
|
||||
time.Sleep(1 * time.Second)
|
||||
a.Logger.Infoln("Starting service...")
|
||||
out := a.ControlService(winSvcName, "start")
|
||||
|
||||
if shared.TEST {
|
||||
goto SKIPSTART;
|
||||
}
|
||||
|
||||
if !out.Success {
|
||||
a.installerMsg(out.ErrorMsg, "error", i.Silent)
|
||||
}
|
||||
|
||||
SKIPSTART: a.Logger.Infoln("Skipping service start in test.")
|
||||
a.Logger.Infoln("Adding windows defender exclusions")
|
||||
a.addDefenderExlusions()
|
||||
|
||||
|
@ -41,7 +41,7 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
|
||||
viper.Set("meshdir", meshdir)
|
||||
viper.SetConfigPermissions(0660)
|
||||
configLocation := "/etc/tacticalagent"
|
||||
if strings.HasSuffix(os.Args[0], ".test") {
|
||||
if shared.TEST {
|
||||
configLocation = "tacticalagent"
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,14 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/amidaware/rmmagent/shared"
|
||||
"github.com/gonutz/w32/v2"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) {
|
||||
k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln("Error creating registry key:", err)
|
||||
}
|
||||
@ -78,6 +80,11 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
|
||||
func (a *Agent) checkExistingAndRemove(silent bool) {
|
||||
hasReg := false
|
||||
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||
if shared.TEST {
|
||||
err = nil
|
||||
_, err = registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
hasReg = true
|
||||
}
|
||||
|
5
shared/notest.go
Normal file
5
shared/notest.go
Normal file
@ -0,0 +1,5 @@
|
||||
//go:build !TEST
|
||||
|
||||
package shared
|
||||
|
||||
const TEST = false
|
5
shared/test.go
Normal file
5
shared/test.go
Normal file
@ -0,0 +1,5 @@
|
||||
//go:build TEST
|
||||
|
||||
package shared
|
||||
|
||||
const TEST = true
|
Loading…
Reference in New Issue
Block a user