Files
scadaproj/docs/deploy/2026-11-19-qa-nam-ldap/mxgw-upgrade.tmpl.ps1
T

25 lines
1.7 KiB
PowerShell

# MxAccessGateway QA 76a71bc8 -> e74918cc with the NAM base appsettings.json. Rendered: __MODE__ = dry | real.
# The repo upgrade script carries the live appsettings*.json into the new app\, so the NAM base file is put in place
# first (GwAdmin/GwReader removed; the LDAP settings themselves live in the NSSM env, written by env-mxgw.ps1).
$ErrorActionPreference = 'Stop'
$Mode = '__MODE__'
$Stage = 'E:\psrem-stage\mxgw-e74918cc'
$Zip = Join-Path $Stage 'mxgw-e74918cc.zip'
$want = 'F0999B75BEE196375AEB8E3E277A0E948C54A747FD5251D336461C9665D847F2'
$got = (Get-FileHash $Zip -Algorithm SHA256).Hash
if ($got -ne $want) { "ABORT zip hash $got"; exit 1 }
$exp = Join-Path $Stage 'expanded'
if (-not (Test-Path (Join-Path $exp 'Worker\MxGateway.Worker.exe'))) { Expand-Archive -Path $Zip -DestinationPath $exp -Force }
"staged Server = " + [Diagnostics.FileVersionInfo]::GetVersionInfo((Join-Path $exp 'Server\ZB.MOM.WW.MxGateway.Server.dll')).ProductVersion
"staged Worker = " + [Diagnostics.FileVersionInfo]::GetVersionInfo((Join-Path $exp 'Worker\MxGateway.Worker.exe')).ProductVersion
$live = 'E:\ApiInstall\MxAccessGateway\app\appsettings.json'
if ($Mode -eq 'real') {
$nam = Join-Path $Stage 'appsettings.json.nam'
Get-Content $nam -Raw | ConvertFrom-Json | Out-Null
Copy-Item $nam $live -Force
"live appsettings.json <- NAM base, sha256 $((Get-FileHash $live).Hash.Substring(0,16))"
}
$a = @{ ServerSource = (Join-Path $exp 'Server'); WorkerSource = (Join-Path $exp 'Worker'); NssmPath = 'C:\ProgramData\ZB\qa-build\tools\nssm.exe'; ExpectedSha = 'e74918cc'; Label = 'nam-e74918cc' }
if ($Mode -ne 'real') { $a.DryRun = $true }
& (Join-Path $Stage 'Upgrade-MxGatewayService.ps1') @a 2>&1 | Out-String -Width 300