Files
Robot-Clash/server/deploy/deploy-all.ps1

32 lines
1.8 KiB
PowerShell
Raw Normal View History

2026-11-18 15:18:38 +01:00
# Komplett-Deploy in einem: Server einrichten, Code hochladen, starten, Status prüfen.
# Aus dem Projektordner in Windows PowerShell: .\server\deploy\deploy-all.ps1
# Beim ersten Mal fragt SSH nach dem Hetzner-Root-Passwort (mehrfach) und einmal nach dem Fingerprint (yes).
param(
[string]$Server = "root@91.99.166.238",
[string]$Domain = "roboclash.michael-media.de",
[string]$App = "/opt/robotclash"
)
$ErrorActionPreference = "Stop"
$repo = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
Write-Host "== 1/4 Server einrichten (Node, Caddy, Dienst, Firewall) ==" -ForegroundColor Cyan
scp "$repo\server\deploy\setup.sh" "${Server}:/root/setup.sh"
ssh $Server "bash /root/setup.sh $Domain"
Write-Host "== 2/4 Code hochladen (Spiel + Server) ==" -ForegroundColor Cyan
ssh $Server "mkdir -p $App/game $App/server"
scp -r -q "$repo\game" "${Server}:$App/"
Get-ChildItem "$repo\server" -File |
Where-Object { $_.Name -ne ".env" -and $_.Name -notlike "*.sqlite*" } |
ForEach-Object { scp -q $_.FullName "${Server}:$App/server/" }
Write-Host "== 3/4 Abhaengigkeiten installieren + Dienst starten ==" -ForegroundColor Cyan
ssh $Server "cd $App/server && (npm ci --omit=dev 2>/dev/null || npm install --omit=dev) && systemctl restart robotclash"
Write-Host "== 4/4 Status ==" -ForegroundColor Cyan
ssh $Server "sleep 1; systemctl --no-pager --lines=6 status robotclash; echo '--- lokal (Node) ---'; curl -s -o /dev/null -w 'node:8080 -> HTTP %{http_code}\n' http://localhost:8080/; echo -n '--- caddy: '; systemctl is-active caddy"
Write-Host ""
Write-Host "Fertig. Oeffne: https://$Domain/ (Browser: Strg+F5 oder Inkognito)" -ForegroundColor Green
Write-Host "Beim ersten Aufruf holt Caddy automatisch das TLS-Zertifikat (ein paar Sekunden)." -ForegroundColor Green