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) {
|
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 {
|
if err != nil {
|
||||||
a.Logger.Debugln(err)
|
a.Logger.Debugln(err)
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/amidaware/rmmagent/shared"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
trmm "github.com/wh1te909/trmm-shared"
|
trmm "github.com/wh1te909/trmm-shared"
|
||||||
)
|
)
|
||||||
@ -251,10 +252,16 @@ func (a *Agent) Install(i *Installer) {
|
|||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
a.Logger.Infoln("Starting service...")
|
a.Logger.Infoln("Starting service...")
|
||||||
out := a.ControlService(winSvcName, "start")
|
out := a.ControlService(winSvcName, "start")
|
||||||
|
|
||||||
|
if shared.TEST {
|
||||||
|
goto SKIPSTART;
|
||||||
|
}
|
||||||
|
|
||||||
if !out.Success {
|
if !out.Success {
|
||||||
a.installerMsg(out.ErrorMsg, "error", i.Silent)
|
a.installerMsg(out.ErrorMsg, "error", i.Silent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SKIPSTART: a.Logger.Infoln("Skipping service start in test.")
|
||||||
a.Logger.Infoln("Adding windows defender exclusions")
|
a.Logger.Infoln("Adding windows defender exclusions")
|
||||||
a.addDefenderExlusions()
|
a.addDefenderExlusions()
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
|
|||||||
viper.Set("meshdir", meshdir)
|
viper.Set("meshdir", meshdir)
|
||||||
viper.SetConfigPermissions(0660)
|
viper.SetConfigPermissions(0660)
|
||||||
configLocation := "/etc/tacticalagent"
|
configLocation := "/etc/tacticalagent"
|
||||||
if strings.HasSuffix(os.Args[0], ".test") {
|
if shared.TEST {
|
||||||
configLocation = "tacticalagent"
|
configLocation = "tacticalagent"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,14 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/amidaware/rmmagent/shared"
|
||||||
"github.com/gonutz/w32/v2"
|
"github.com/gonutz/w32/v2"
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) {
|
func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) {
|
||||||
k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Error creating registry key:", err)
|
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) {
|
func (a *Agent) checkExistingAndRemove(silent bool) {
|
||||||
hasReg := false
|
hasReg := false
|
||||||
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
_, 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 {
|
if err == nil {
|
||||||
hasReg = true
|
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