testing and generate
This commit is contained in:
parent
9743d7ee22
commit
3841aee4b2
24 changed files with 1087 additions and 610 deletions
|
|
@ -13,14 +13,34 @@ import (
|
|||
"github.com/amidaware/rmmagent/agent/services"
|
||||
"github.com/amidaware/rmmagent/agent/system"
|
||||
"github.com/amidaware/rmmagent/agent/tactical/config"
|
||||
"github.com/amidaware/rmmagent/agent/tactical/shared"
|
||||
"github.com/amidaware/rmmagent/agent/tasks"
|
||||
"github.com/amidaware/rmmagent/agent/utils"
|
||||
rmm "github.com/amidaware/rmmagent/shared"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gonutz/w32/v2"
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func GetVersion() string {
|
||||
path := shared.GetProgramBin()
|
||||
size := w32.GetFileVersionInfoSize(path)
|
||||
info := make([]byte, size)
|
||||
w32.GetFileVersionInfo(path, info)
|
||||
fixed, _ := w32.VerQueryValueRoot(info)
|
||||
version := fixed.FileVersion()
|
||||
stringVersion := fmt.Sprintf(
|
||||
"%d.%d.%d",
|
||||
version&0xFFFF000000000000>>48,
|
||||
version&0x0000FFFF00000000>>32,
|
||||
version&0x00000000FFFF0000>>16,
|
||||
//drop last digit version&0x000000000000FFFF>>0,
|
||||
)
|
||||
|
||||
return stringVersion
|
||||
}
|
||||
|
||||
func UninstallCleanup() {
|
||||
registry.DeleteKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`)
|
||||
patching.PatchMgmnt(false)
|
||||
|
|
@ -32,7 +52,7 @@ func AgentUpdate(url, inno, version string) {
|
|||
time.Sleep(time.Duration(utils.RandRange(1, 15)) * time.Second)
|
||||
system.KillHungUpdates()
|
||||
CleanupAgentUpdates()
|
||||
updater := filepath.Join(system.GetProgramDirectory(), inno)
|
||||
updater := filepath.Join(shared.GetProgramDirectory(), inno)
|
||||
config := config.NewAgentConfig()
|
||||
rClient := resty.New()
|
||||
rClient.SetCloseConnection(true)
|
||||
|
|
@ -71,7 +91,7 @@ func AgentUpdate(url, inno, version string) {
|
|||
}
|
||||
|
||||
func CleanupAgentUpdates() {
|
||||
pd := filepath.Join(os.Getenv("ProgramFiles"), system.ProgFilesName)
|
||||
pd := filepath.Join(os.Getenv("ProgramFiles"), shared.ProgFilesName)
|
||||
cderr := os.Chdir(pd)
|
||||
if cderr != nil {
|
||||
return
|
||||
|
|
@ -99,7 +119,7 @@ func CleanupAgentUpdates() {
|
|||
|
||||
func AgentUninstall(code string) {
|
||||
system.KillHungUpdates()
|
||||
tacUninst := filepath.Join(system.GetProgramDirectory(), GetUninstallExe())
|
||||
tacUninst := filepath.Join(shared.GetProgramDirectory(), GetUninstallExe())
|
||||
args := []string{"/C", tacUninst, "/VERYSILENT"}
|
||||
cmd := exec.Command("cmd.exe", args...)
|
||||
cmd.SysProcAttr = &windows.SysProcAttr{
|
||||
|
|
@ -109,7 +129,7 @@ func AgentUninstall(code string) {
|
|||
}
|
||||
|
||||
func GetUninstallExe() string {
|
||||
cderr := os.Chdir(system.GetProgramDirectory())
|
||||
cderr := os.Chdir(shared.GetProgramDirectory())
|
||||
if cderr == nil {
|
||||
files, err := filepath.Glob("unins*.exe")
|
||||
if err == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue