feat: Windows Service Wrapper für NexusRMM Agent

- winsvc package mit Build-Tag-basierter plattformspezifischer Implementierung:
  - service_windows.go: svc.Handler + Install/Uninstall/Start/Stop via windows/svc/mgr
  - service_stub.go: Stub-Implementierungen für nicht-Windows Builds
- main.go refaktoriert:
  - os.Executable() für absoluten Config-Pfad (Service-Modus: CWD = C:\Windows\System32)
  - Kommandozeilen-Args: install / uninstall / start / stop
  - winsvc.IsWindowsService() Erkennung → Service-Modus oder Konsolen-Modus
  - Agent-Loop als makeRunFn() extrahiert (wiederverwendbar für beide Modi)
- install-service.ps1: Convenience-Skript zum Bauen, Installieren und Starten

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-20 10:24:00 +01:00
parent c401ea8f29
commit d7b618f02d
4 changed files with 475 additions and 74 deletions

View File

@@ -0,0 +1,33 @@
//go:build !windows
package winsvc
import "errors"
const (
ServiceName = "NexusRMMAgent"
ServiceDisplayName = "NexusRMM Agent"
ServiceDescription = "NexusRMM Remote Monitoring and Management Agent"
)
func IsWindowsService() (bool, error) { return false, nil }
func Run(_ func(stop <-chan struct{})) error {
return errors.New("Windows Service wird nur unter Windows unterstützt")
}
func Install(_ string) error {
return errors.New("Windows Service wird nur unter Windows unterstützt")
}
func Uninstall() error {
return errors.New("Windows Service wird nur unter Windows unterstützt")
}
func Start() error {
return errors.New("Windows Service wird nur unter Windows unterstützt")
}
func Stop() error {
return errors.New("Windows Service wird nur unter Windows unterstützt")
}