rmmagent/agent/install_unix.go

83 lines
1.8 KiB
Go
Raw Normal View History

2022-06-22 20:20:19 +00:00
//go:build !windows
2022-06-22 20:03:45 +00:00
// +build !windows
2022-03-19 18:55:43 +00:00
/*
Copyright 2022 AmidaWare LLC.
Licensed under the Tactical RMM License Version 1.0 (the License).
You may only use the Licensed Software in accordance with the License.
A copy of the License is available at:
https://license.tacticalrmm.com
*/
package agent
import (
2022-09-23 23:05:17 +00:00
"fmt"
2022-03-19 18:55:43 +00:00
"log"
2022-09-23 23:05:17 +00:00
"os"
"runtime"
"time"
2022-06-17 05:14:44 +00:00
2022-03-19 18:55:43 +00:00
"github.com/spf13/viper"
2022-09-23 23:05:17 +00:00
trmm "github.com/wh1te909/trmm-shared"
2022-03-19 18:55:43 +00:00
)
func (a *Agent) installerMsg(msg, alert string, silent bool) {
if alert == "error" {
a.Logger.Fatalln(msg)
} else {
a.Logger.Info(msg)
}
}
func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) {
viper.SetConfigType("json")
viper.Set("baseurl", baseurl)
viper.Set("agentid", agentid)
viper.Set("apiurl", apiurl)
viper.Set("token", token)
viper.Set("agentpk", agentpk)
viper.Set("cert", cert)
viper.Set("proxy", proxy)
viper.Set("meshdir", meshdir)
viper.SetConfigPermissions(0660)
2022-06-17 05:14:44 +00:00
err := viper.SafeWriteConfigAs(etcConfig)
2022-03-19 18:55:43 +00:00
if err != nil {
log.Fatalln("createAgentConfig", err)
}
}
2022-09-23 23:05:17 +00:00
func (a *Agent) checkExistingAndRemove(silent bool) {
if runtime.GOOS == "darwin" {
if trmm.FileExists(a.MeshSystemEXE) {
a.Logger.Infoln("Existing meshagent found, attempting to remove...")
uopts := a.NewCMDOpts()
uopts.Command = fmt.Sprintf("%s -fulluninstall", a.MeshSystemEXE)
uout := a.CmdV2(uopts)
fmt.Println(uout.Stdout)
time.Sleep(1 * time.Second)
}
if trmm.FileExists(macPlistPath) {
a.Logger.Infoln("Existing tacticalagent plist found, attempting to remove...")
opts := a.NewCMDOpts()
opts.Command = fmt.Sprintf("launchctl bootout system %s", macPlistPath)
a.CmdV2(opts)
}
os.RemoveAll(macMeshSvcDir)
os.Remove(etcConfig)
os.RemoveAll(nixAgentDir)
os.Remove(macPlistPath)
}
}
2022-03-19 18:55:43 +00:00
func DisableSleepHibernate() {}
func EnablePing() {}
func EnableRDP() {}