fix: update.ps1 generalisiert fuer stopBat/startBat je Projekt

This commit is contained in:
Rhino
2026-06-20 17:00:02 +02:00
parent d614d64c58
commit 5a94406b7b
+24 -8
View File
@@ -1,9 +1,19 @@
# StatusQuo_Updates/scripts/update.ps1
# Zentraler Updater - wird von update.bat per Invoke-Expression geladen.
# Erwartet im aufrufenden Scope: $proj (Projektname z.B. 'VI3DGL'), $root (Installationspfad)
# Erwartet im aufrufenden Scope:
# $proj - Projektname (z.B. 'VI3DGL', 'FLD-Schichtplanung', 'DRIVE', 'Portal_Union')
# $root - Installationspfad (Verzeichnis mit server.ps1, VERSION usw.)
# $stopBat - (optional) Dateiname des Stop-Skripts, z.B. 'DRIVE_Stop.bat'.
# Leerstring '' = kein Stop-Schritt. Nicht gesetzt = Fallback auf 'stop.bat'.
# $startBat - (optional) Dateiname des Start-Skripts, z.B. 'DRIVE_Start.bat'.
# Nicht gesetzt = Fallback auf 'dgl.bat'.
$ErrorActionPreference = 'Stop'
$DistBase = "https://gitea.rhino.nrw/Rhino/StatusQuo_Updates/raw/branch/main/$proj"
# Stop/Start-Namen VOR jeder Ueberschreibung aus dem aufrufenden Scope lesen
$_stopName = if ($null -ne $stopBat) { $stopBat } else { 'stop.bat' }
$_startName = if ($null -ne $startBat) { $startBat } else { 'dgl.bat' }
# Lokale Version lesen
$localVer = '0.0.0'
$verFile = Join-Path $root 'VERSION'
@@ -49,10 +59,16 @@ Invoke-WebRequest -Uri "$DistBase/sync-entpacken.bat" -OutFile (Join-Path $tmp '
# Server stoppen
Write-Host "Stoppe Server ..."
$stopBat = Join-Path $root 'stop.bat'
if (Test-Path -LiteralPath $stopBat) {
& cmd /c "`"$stopBat`""
if ($_stopName -ne '') {
$_stopPath = Join-Path $root $_stopName
if (Test-Path -LiteralPath $_stopPath) {
& cmd /c "`"$_stopPath`""
Start-Sleep -Seconds 2
} else {
Write-Host " (Stop-Skript '$_stopName' nicht gefunden — übersprungen)" -ForegroundColor DarkYellow
}
} else {
Write-Host " (Kein Stop-Skript konfiguriert — übersprungen)" -ForegroundColor DarkYellow
}
# Backup
@@ -77,12 +93,12 @@ Write-Host "Version auf v$remoteVer aktualisiert." -ForegroundColor Green
Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
# Server neu starten
$dglBat = Join-Path $root 'dgl.bat'
if (Test-Path -LiteralPath $dglBat) {
Start-Process -FilePath 'cmd.exe' -ArgumentList "/c `"$dglBat`"" -WindowStyle Hidden
$_startPath = Join-Path $root $_startName
if (Test-Path -LiteralPath $_startPath) {
Start-Process -FilePath 'cmd.exe' -ArgumentList "/c `"$_startPath`"" -WindowStyle Hidden
Write-Host "Server gestartet." -ForegroundColor Green
} else {
Write-Host "dgl.bat nicht gefunden — bitte Server manuell starten." -ForegroundColor Yellow
Write-Host "Start-Skript '$_startName' nicht gefunden — bitte Server manuell starten." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "=== Update abgeschlossen ===" -ForegroundColor Green