diff --git a/docs/deploy/2026-11-19-prod-stage/common/seed-secret-prod.ps1 b/docs/deploy/2026-11-19-prod-stage/common/seed-secret-prod.ps1 index 7d3d4ce..6af0107 100644 --- a/docs/deploy/2026-11-19-prod-stage/common/seed-secret-prod.ps1 +++ b/docs/deploy/2026-11-19-prod-stage/common/seed-secret-prod.ps1 @@ -51,8 +51,13 @@ try { if (-not $match) { try { $j = $got | ConvertFrom-Json; $match = ($j.value -ceq $want) } catch {} } "$Target -> $where kek=$($env:Secrets__MasterKey__FilePath) kek-sha256=$((Get-FileHash $env:Secrets__MasterKey__FilePath).Hash.Substring(0,8)) set rc=$rc out=$(($out | Out-String).Trim()) readback-match=$match" if ($rc -ne 0 -or -not $match) { $fail++ } +} catch { + $fail++; "SEED ERROR: $($_.Exception.Message)" } finally { - Remove-Item $ValueFile, "$ValueFile.nl" -Force -ErrorAction SilentlyContinue; "value file removed: $(-not (Test-Path $ValueFile))" + # 2026-11-20: delete the value file only on success, so a failed seed can be retried without re-staging it. + Remove-Item "$ValueFile.nl" -Force -ErrorAction SilentlyContinue + if ($fail -eq 0) { Remove-Item $ValueFile -Force -ErrorAction SilentlyContinue; "value file removed: $(-not (Test-Path $ValueFile))" } + else { "value file KEPT for retry (ACL Administrators+SYSTEM): $ValueFile" } foreach ($n in $names) { Remove-Item "Env:$n" -ErrorAction SilentlyContinue } } "SEED DONE failures=$fail"; exit $fail diff --git a/docs/deploy/2026-11-19-prod-stage/mxgw/Install-MxGatewayService.ps1 b/docs/deploy/2026-11-19-prod-stage/mxgw/Install-MxGatewayService.ps1 index 8e55a6d..203be5f 100644 --- a/docs/deploy/2026-11-19-prod-stage/mxgw/Install-MxGatewayService.ps1 +++ b/docs/deploy/2026-11-19-prod-stage/mxgw/Install-MxGatewayService.ps1 @@ -65,7 +65,10 @@ function Step([string]$Description, [scriptblock]$Action) { } function Invoke-Nssm { param([string[]]$NssmArgs, [switch]$AllowFail) - $raw = & $NssmPath @NssmArgs 2>&1; $code = $LASTEXITCODE + # PROD-STAGE PATCH 4 (2026-11-20): under EAP=Stop, PS 5.1 turns native stderr redirected by 2>&1 into a terminating + # NativeCommandError, so `nssm status` on a not-yet-installed service aborted even with -AllowFail. Run it under Continue. + $eap = $ErrorActionPreference; $ErrorActionPreference = 'Continue' + try { $raw = & $NssmPath @NssmArgs 2>&1; $code = $LASTEXITCODE } finally { $ErrorActionPreference = $eap } $text = (($raw | ForEach-Object { "$_" }) -join "`n") -replace "`0", '' if ($code -ne 0 -and -not $AllowFail) { Fail "nssm $($NssmArgs[0..1] -join ' ') failed (exit $code): $text" } [pscustomobject]@{ Code = $code; Text = $text.Trim() }