96 lines
3.7 KiB
PowerShell
96 lines
3.7 KiB
PowerShell
|
|
#Requires -Version 5.1
|
|||
|
|
<#
|
|||
|
|
.SYNOPSIS
|
|||
|
|
Stoppt die NexusRMM Entwicklungsumgebung
|
|||
|
|
.DESCRIPTION
|
|||
|
|
Beendet alle PowerShell-Fenster mit "NexusRMM" im Titel und
|
|||
|
|
fährt den PostgreSQL-Container herunter (ohne Volumes zu löschen).
|
|||
|
|
MeshCentral wird NICHT gestoppt.
|
|||
|
|
#>
|
|||
|
|
|
|||
|
|
$ErrorActionPreference = "Stop"
|
|||
|
|
$Root = "D:\001_Projekte\IT_Tool"
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# Helper
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
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. PowerShell-Fenster mit "NexusRMM" im Hauptfenstertitel schließen
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
Write-Step "Schliesse NexusRMM PowerShell-Fenster..."
|
|||
|
|
|
|||
|
|
Add-Type -AssemblyName System.Diagnostics.Process -ErrorAction SilentlyContinue
|
|||
|
|
|
|||
|
|
$currentPid = $PID
|
|||
|
|
$killed = 0
|
|||
|
|
|
|||
|
|
# GetProcesses liefert alle powershell / pwsh Instanzen
|
|||
|
|
$psProcesses = Get-Process -Name @("powershell", "pwsh") -ErrorAction SilentlyContinue
|
|||
|
|
|
|||
|
|
foreach ($proc in $psProcesses) {
|
|||
|
|
if ($proc.Id -eq $currentPid) { continue } # dieses Skript selbst nicht beenden
|
|||
|
|
|
|||
|
|
# Fenstertitel auslesen (MainWindowTitle ist leer bei verborgenen Fenstern)
|
|||
|
|
$title = $proc.MainWindowTitle
|
|||
|
|
if ($title -match "NexusRMM") {
|
|||
|
|
try {
|
|||
|
|
$proc | Stop-Process -Force
|
|||
|
|
Write-OK "Prozess beendet: PID $($proc.Id) – '$title'"
|
|||
|
|
$killed++
|
|||
|
|
} catch {
|
|||
|
|
Write-Warn "Konnte Prozess PID $($proc.Id) nicht beenden: $_"
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($killed -eq 0) {
|
|||
|
|
Write-Warn "Keine laufenden NexusRMM-Fenster gefunden."
|
|||
|
|
} else {
|
|||
|
|
Write-OK "$killed Fenster geschlossen."
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# 2. PostgreSQL-Container stoppen (ohne Volume zu entfernen)
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
Write-Step "Stoppe PostgreSQL-Container..."
|
|||
|
|
|
|||
|
|
# Prüfen ob Docker läuft
|
|||
|
|
$dockerCmd = Get-Command docker -ErrorAction SilentlyContinue
|
|||
|
|
if ($null -eq $dockerCmd) {
|
|||
|
|
Write-Warn "Docker nicht gefunden – überspringe Container-Stop."
|
|||
|
|
} else {
|
|||
|
|
Push-Location $Root
|
|||
|
|
try {
|
|||
|
|
# Nur nexusrmm-postgres stoppen, MeshCentral bleibt unberührt
|
|||
|
|
$containerRunning = docker ps --filter "name=nexusrmm-postgres" --format "{{.Names}}" 2>$null
|
|||
|
|
if ($containerRunning -match "nexusrmm-postgres") {
|
|||
|
|
docker compose stop nexusrmm-postgres
|
|||
|
|
if ($LASTEXITCODE -eq 0) {
|
|||
|
|
Write-OK "nexusrmm-postgres gestoppt."
|
|||
|
|
} else {
|
|||
|
|
Write-Fail "docker compose stop fehlgeschlagen."
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
Write-Warn "nexusrmm-postgres läuft nicht (bereits gestoppt)."
|
|||
|
|
}
|
|||
|
|
} finally {
|
|||
|
|
Pop-Location
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# 3. Zusammenfassung
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
Write-Host ""
|
|||
|
|
Write-Host "NexusRMM Entwicklungsumgebung gestoppt." -ForegroundColor Green
|
|||
|
|
Write-Host "Volumes wurden behalten (Datenbankdaten bleiben erhalten)." -ForegroundColor Yellow
|
|||
|
|
Write-Host "MeshCentral wurde nicht gestoppt." -ForegroundColor Yellow
|
|||
|
|
Write-Host ""
|
|||
|
|
Write-Host "Neu starten: .\dev-start.ps1" -ForegroundColor Cyan
|
|||
|
|
Write-Host "Alles inkl. Volumes loeschen: docker compose down -v" -ForegroundColor Cyan
|