Network Discovery:
- Go Agent: internal/scanner/scanner.go mit TCP-Sweep (Port 445/80/22/443),
ARP-Tabellen-Parser (Windows: arp -a, Linux: /proc/net/arp), Reverse-DNS,
50 gleichzeitige Goroutines mit Semaphore
- Go Agent main.go: COMMAND_TYPE_NETWORK_SCAN Case → scanner.Scan() → JSON stdout
- Backend: NetworkDevice Model (Id, AgentId, IpAddress, MacAddress, Hostname,
Vendor, IsManaged, FirstSeen, LastSeen)
- Backend: EF Migration AddNetworkDevices + Index auf IpAddress + MacAddress
- Backend: NetworkDevicesController GET /api/v1/network-devices + DELETE /{id}
- Backend: AgentGrpcService.ProcessNetworkScanResultAsync — upsert via MAC,
IsManaged=true wenn IP einem bekannten Agent entspricht
- Frontend: NetworkPage.tsx mit Scan-Panel, Device-Tabelle, Filter, Delete
- Frontend: App.tsx — 'Netzwerk' Nav-Eintrag mit Network Icon
Windows Dev-Setup:
- dev-start.ps1 — Startet Docker/Postgres, EF-Migrationen, Backend+Frontend
in separaten PowerShell-Fenstern; Voraussetzungen-Check (docker/dotnet/node/go)
- dev-stop.ps1 — Stoppt alle NexusRMM-Prozesse + PostgreSQL Container
- build-agent.ps1 — Baut nexus-agent.exe (Windows) + optional nexus-agent-linux
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
189 lines
7.0 KiB
PowerShell
189 lines
7.0 KiB
PowerShell
#Requires -Version 5.1
|
||
<#
|
||
.SYNOPSIS
|
||
Startet die NexusRMM Entwicklungsumgebung
|
||
.DESCRIPTION
|
||
Startet Docker (Postgres + MeshCentral), führt DB-Migrationen aus,
|
||
startet Backend und Frontend in separaten Fenstern.
|
||
#>
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
$Root = "D:\001_Projekte\IT_Tool"
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Helper-Funktionen
|
||
# ---------------------------------------------------------------------------
|
||
function Write-Step { param($msg) Write-Host "`n==> $msg" -ForegroundColor Cyan }
|
||
function Write-OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green }
|
||
function Write-Warn { param($msg) Write-Host " [!] $msg" -ForegroundColor Yellow }
|
||
function Write-Fail { param($msg) Write-Host " [FEHLER] $msg" -ForegroundColor Red }
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 1. Voraussetzungen prüfen
|
||
# ---------------------------------------------------------------------------
|
||
Write-Step "Prüfe Voraussetzungen..."
|
||
|
||
$missing = $false
|
||
|
||
$tools = @(
|
||
@{ Name = "docker"; Desc = "Docker Desktop" },
|
||
@{ Name = "dotnet"; Desc = ".NET SDK" },
|
||
@{ Name = "node"; Desc = "Node.js" },
|
||
@{ Name = "npm"; Desc = "npm" },
|
||
@{ Name = "go"; Desc = "Go" }
|
||
)
|
||
|
||
foreach ($tool in $tools) {
|
||
$cmd = Get-Command $tool.Name -ErrorAction SilentlyContinue
|
||
if ($null -eq $cmd) {
|
||
Write-Fail "$($tool.Desc) ($($tool.Name)) nicht gefunden. Bitte installieren."
|
||
$missing = $true
|
||
} else {
|
||
Write-OK "$($tool.Desc): $($cmd.Source)"
|
||
}
|
||
}
|
||
|
||
if ($missing) {
|
||
Write-Fail "Fehlende Voraussetzungen – Abbruch."
|
||
exit 1
|
||
}
|
||
|
||
# dotnet-ef prüfen
|
||
$efInstalled = dotnet tool list --global 2>$null | Select-String "dotnet-ef"
|
||
if (-not $efInstalled) {
|
||
Write-Warn "dotnet-ef nicht global installiert. Installiere jetzt..."
|
||
dotnet tool install --global dotnet-ef
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Fail "dotnet-ef konnte nicht installiert werden."
|
||
exit 1
|
||
}
|
||
Write-OK "dotnet-ef installiert."
|
||
} else {
|
||
Write-OK "dotnet-ef: vorhanden"
|
||
}
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 2. PostgreSQL per Docker starten
|
||
# ---------------------------------------------------------------------------
|
||
Write-Step "Starte PostgreSQL..."
|
||
|
||
Push-Location $Root
|
||
try {
|
||
docker compose up -d nexusrmm-postgres
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Fail "docker compose up fehlgeschlagen."
|
||
exit 1
|
||
}
|
||
} finally {
|
||
Pop-Location
|
||
}
|
||
|
||
# Warte bis PostgreSQL bereit ist (max 30 Sekunden, Intervall 2 Sekunden)
|
||
Write-Host " Warte auf PostgreSQL..." -ForegroundColor Cyan
|
||
$maxWait = 30
|
||
$waited = 0
|
||
$pgReady = $false
|
||
|
||
while ($waited -lt $maxWait) {
|
||
$result = docker exec nexusrmm-postgres pg_isready -U nexusrmm -q 2>&1
|
||
if ($LASTEXITCODE -eq 0) {
|
||
$pgReady = $true
|
||
break
|
||
}
|
||
Start-Sleep -Seconds 2
|
||
$waited += 2
|
||
}
|
||
|
||
if (-not $pgReady) {
|
||
Write-Fail "PostgreSQL ist nach $maxWait Sekunden nicht erreichbar."
|
||
exit 1
|
||
}
|
||
Write-OK "PostgreSQL bereit (Port 5433)."
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 3. EF Core Migrationen ausführen
|
||
# ---------------------------------------------------------------------------
|
||
Write-Step "Führe Datenbank-Migrationen aus..."
|
||
|
||
Push-Location "$Root\Backend"
|
||
try {
|
||
# --project: Migration-Projekt (Infrastructure enthält DbContext + Migrations)
|
||
# --startup-project: Startup-Projekt mit Verbindungsstring
|
||
dotnet ef database update `
|
||
--project "src\NexusRMM.Infrastructure" `
|
||
--startup-project "src\NexusRMM.Api" `
|
||
--no-build
|
||
if ($LASTEXITCODE -ne 0) {
|
||
# --no-build schlägt fehl wenn noch kein Build vorhanden – Build nachholen
|
||
Write-Warn "Migration mit --no-build fehlgeschlagen, baue zuerst..."
|
||
dotnet build "src\NexusRMM.Api" --configuration Debug -q
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Fail "dotnet build fehlgeschlagen."
|
||
exit 1
|
||
}
|
||
dotnet ef database update `
|
||
--project "src\NexusRMM.Infrastructure" `
|
||
--startup-project "src\NexusRMM.Api"
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Fail "dotnet ef database update fehlgeschlagen."
|
||
exit 1
|
||
}
|
||
}
|
||
} finally {
|
||
Pop-Location
|
||
}
|
||
Write-OK "Migrationen erfolgreich."
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 4. Backend in neuem PowerShell-Fenster starten
|
||
# ---------------------------------------------------------------------------
|
||
Write-Step "Starte Backend..."
|
||
|
||
$backendCmd = "Set-Location '$Root\Backend'; Write-Host 'NexusRMM Backend' -ForegroundColor Cyan; dotnet run --project src/NexusRMM.Api"
|
||
|
||
Start-Process powershell -ArgumentList @(
|
||
"-NoExit",
|
||
"-Command",
|
||
$backendCmd
|
||
) -WindowStyle Normal
|
||
|
||
Write-OK "Backend-Fenster geöffnet."
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 5. Kurz warten damit das Backend starten kann
|
||
# ---------------------------------------------------------------------------
|
||
Write-Host "`n Warte 5 Sekunden damit das Backend hochfahren kann..." -ForegroundColor Cyan
|
||
Start-Sleep -Seconds 5
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 6. Frontend in neuem PowerShell-Fenster starten
|
||
# ---------------------------------------------------------------------------
|
||
Write-Step "Starte Frontend..."
|
||
|
||
$frontendCmd = "Set-Location '$Root\Frontend'; Write-Host 'NexusRMM Frontend' -ForegroundColor Cyan; npm run dev"
|
||
|
||
Start-Process powershell -ArgumentList @(
|
||
"-NoExit",
|
||
"-Command",
|
||
$frontendCmd
|
||
) -WindowStyle Normal
|
||
|
||
Write-OK "Frontend-Fenster geöffnet."
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 7. Zusammenfassung
|
||
# ---------------------------------------------------------------------------
|
||
Write-Host ""
|
||
Write-Host "╔══════════════════════════════════════════╗" -ForegroundColor Green
|
||
Write-Host "║ NexusRMM ist bereit! ║" -ForegroundColor Green
|
||
Write-Host "╠══════════════════════════════════════════╣" -ForegroundColor Green
|
||
Write-Host "║ Frontend: http://localhost:5173 ║" -ForegroundColor Green
|
||
Write-Host "║ Backend: http://localhost:5000 ║" -ForegroundColor Green
|
||
Write-Host "║ Swagger: http://localhost:5000/swagger ║" -ForegroundColor Green
|
||
Write-Host "║ gRPC: http://localhost:5001 ║" -ForegroundColor Green
|
||
Write-Host "║ MeshCentral: https://localhost:4430 ║" -ForegroundColor Green
|
||
Write-Host "╚══════════════════════════════════════════╝" -ForegroundColor Green
|
||
Write-Host ""
|
||
Write-Host "Agent starten: .\Agent\nexus-agent.exe" -ForegroundColor Yellow
|
||
Write-Host "Alles stoppen: .\dev-stop.ps1" -ForegroundColor Yellow
|