Merge remote-tracking branch 'upstream/develop' into BigRefactor
This commit is contained in:
commit
29e304fa4e
17 changed files with 71 additions and 88 deletions
|
|
@ -281,14 +281,14 @@ func (a *Agent) NixMeshNodeID() string {
|
|||
meshSuccess := false
|
||||
a.Logger.Debugln("Getting mesh node id")
|
||||
|
||||
if !trmm.FileExists(a.MeshSystemBin) {
|
||||
a.Logger.Debugln(a.MeshSystemBin, "does not exist. Skipping.")
|
||||
if !trmm.FileExists(a.MeshSystemEXE) {
|
||||
a.Logger.Debugln(a.MeshSystemEXE, "does not exist. Skipping.")
|
||||
return ""
|
||||
}
|
||||
|
||||
opts := a.NewCMDOpts()
|
||||
opts.IsExecutable = true
|
||||
opts.Shell = a.MeshSystemBin
|
||||
opts.Shell = a.MeshSystemEXE
|
||||
opts.Command = "-nodeid"
|
||||
|
||||
for !meshSuccess {
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ func (a *Agent) RecoverMesh() {
|
|||
}
|
||||
|
||||
func (a *Agent) getMeshNodeID() (string, error) {
|
||||
out, err := CMD(a.MeshSystemBin, []string{"-nodeid"}, 10, false)
|
||||
out, err := CMD(a.MeshSystemEXE, []string{"-nodeid"}, 10, false)
|
||||
if err != nil {
|
||||
a.Logger.Debugln(err)
|
||||
return "", err
|
||||
|
|
@ -835,6 +835,11 @@ func (a *Agent) InstallService() error {
|
|||
|
||||
// skip on first call of inno setup if this is a new install
|
||||
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
s, err := service.New(a, a.ServiceConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,19 +138,11 @@ func (a *Agent) Install(i *Installer) {
|
|||
rClient.SetProxy(i.Proxy)
|
||||
}
|
||||
|
||||
var arch string
|
||||
switch a.Arch {
|
||||
case "x86_64":
|
||||
arch = "64"
|
||||
case "x86":
|
||||
arch = "32"
|
||||
}
|
||||
|
||||
var installerMeshSystemBin string
|
||||
var installerMeshSystemEXE string
|
||||
if len(i.MeshDir) > 0 {
|
||||
installerMeshSystemBin = filepath.Join(i.MeshDir, "MeshAgent.exe")
|
||||
installerMeshSystemEXE = filepath.Join(i.MeshDir, "MeshAgent.exe")
|
||||
} else {
|
||||
installerMeshSystemBin = a.MeshSystemBin
|
||||
installerMeshSystemEXE = a.MeshSystemEXE
|
||||
}
|
||||
|
||||
var meshNodeID string
|
||||
|
|
@ -159,7 +151,7 @@ func (a *Agent) Install(i *Installer) {
|
|||
mesh := filepath.Join(a.ProgramDir, a.MeshInstaller)
|
||||
if i.LocalMesh == "" {
|
||||
a.Logger.Infoln("Downloading mesh agent...")
|
||||
payload := map[string]string{"arch": arch, "plat": a.Platform}
|
||||
payload := map[string]string{"goarch": a.GoArch, "plat": a.Platform}
|
||||
r, err := rClient.R().SetBody(payload).SetOutput(mesh).Post(fmt.Sprintf("%s/api/v3/meshexe/", baseURL))
|
||||
if err != nil {
|
||||
a.installerMsg(fmt.Sprintf("Failed to download mesh agent: %s", err.Error()), "error", i.Silent)
|
||||
|
|
@ -178,7 +170,7 @@ func (a *Agent) Install(i *Installer) {
|
|||
a.Logger.Debugln("Mesh agent:", mesh)
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
meshNodeID, err = a.installMesh(mesh, installerMeshSystemBin, i.Proxy)
|
||||
meshNodeID, err = a.installMesh(mesh, installerMeshSystemEXE, i.Proxy)
|
||||
if err != nil {
|
||||
a.installerMsg(fmt.Sprintf("Failed to install mesh agent: %s", err.Error()), "error", i.Silent)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
etcConfig = "/etc/tacticalagent"
|
||||
)
|
||||
|
||||
func (a *Agent) checkExistingAndRemove(silent bool) {}
|
||||
|
||||
func (a *Agent) installerMsg(msg, alert string, silent bool) {
|
||||
|
|
@ -40,10 +44,7 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me
|
|||
viper.Set("proxy", proxy)
|
||||
viper.Set("meshdir", meshdir)
|
||||
viper.SetConfigPermissions(0660)
|
||||
configLocation := "/etc/tacticalagent"
|
||||
|
||||
err := viper.SafeWriteConfigAs(configLocation)
|
||||
|
||||
err := viper.SafeWriteConfigAs(etcConfig)
|
||||
if err != nil {
|
||||
log.Fatalln("createAgentConfig", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ 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 err == nil {
|
||||
hasReg = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@ var (
|
|||
)
|
||||
|
||||
func (a *Agent) RunRPC() {
|
||||
if rmm.DEBUG {
|
||||
a.Logger.Infoln("DEBUG BUILD STARTED")
|
||||
}
|
||||
|
||||
a.Logger.Infoln("Agent service started")
|
||||
go a.RunAsService()
|
||||
var wg sync.WaitGroup
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"api": "",
|
||||
"clientid": 1,
|
||||
"siteid": 1,
|
||||
"description": "",
|
||||
"agenttype": "workstation",
|
||||
"power": false,
|
||||
"rdp": false,
|
||||
"ping": false,
|
||||
"token": "",
|
||||
"localmesh": "",
|
||||
"cert": "",
|
||||
"proxy": "",
|
||||
"timeout": 30,
|
||||
"silent": true,
|
||||
"nomesh": true,
|
||||
"meshdir": "",
|
||||
"meshnodeid": ""
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue