From 499b8e3bad837f13a9331eadcefa4c7e70ce23be Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Mon, 24 Aug 2026 13:08:07 -0400 Subject: [PATCH] Default admin site/app pool from deployinfo.txt so deploys stop it The admin site (public-admin) is built and extracted into RemoteDir on every deploy, but AdminSiteName/AdminAppPool defaulted to empty, so deploy-iis-remote-apply.ps1 never stopped it before wiping RemoteDir - it kept files open under the directory being wiped, causing the intermittent Access Denied / residual-file failures. Pull the names from deployinfo.txt (already the local per-environment config file) so every deploy stops it automatically. --- scripts/deploy-iis.ps1 | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/deploy-iis.ps1 b/scripts/deploy-iis.ps1 index 174fab2..7813776 100644 --- a/scripts/deploy-iis.ps1 +++ b/scripts/deploy-iis.ps1 @@ -46,21 +46,39 @@ function Ensure-Command { } } -function Get-DefaultRemoteTarget { +# deployinfo.txt (gitignored, local-only) holds one "key value" pair per line, e.g.: +# ssh daniel_admin@kci-uluro-web +# AdminSiteName PurpleEnvelopes-Admin +# AdminAppPool PurpleEnvelopes-Admin +function Get-DeployInfoValue { + param([string]$Key) $infoPath = Join-Path $PSScriptRoot 'deployinfo.txt' if(!(Test-Path $infoPath)){ return '' } - $sshLine = Get-Content $infoPath | Where-Object { $_ -match '^\s*ssh\s+' } | Select-Object -First 1 - if([string]::IsNullOrWhiteSpace($sshLine)){ return '' } - return ($sshLine -replace '^\s*ssh\s+', '').Trim() + $pattern = '^\s*' + [regex]::Escape($Key) + '\s+' + $line = Get-Content $infoPath | Where-Object { $_ -match $pattern } | Select-Object -First 1 + if([string]::IsNullOrWhiteSpace($line)){ return '' } + return ($line -replace $pattern, '').Trim() } if([string]::IsNullOrWhiteSpace($RemoteTarget)){ - $RemoteTarget = Get-DefaultRemoteTarget + $RemoteTarget = Get-DeployInfoValue 'ssh' } if([string]::IsNullOrWhiteSpace($RemoteTarget)){ throw 'No -RemoteTarget given and scripts\deployinfo.txt not found. Create scripts\deployinfo.txt with a line like: ssh user@host' } +# The admin site (public-admin) is built and extracted into RemoteDir on every deploy +# regardless of whether it's stopped first - if its IIS site/app pool name isn't known here, +# deploy-iis-remote-apply.ps1 can't stop it before wiping RemoteDir, and it'll keep files +# open under the same directory the wipe is trying to clear. Default from deployinfo.txt so +# every deploy stops it without needing to pass -AdminSiteName/-AdminAppPool by hand. +if([string]::IsNullOrWhiteSpace($AdminSiteName)){ + $AdminSiteName = Get-DeployInfoValue 'AdminSiteName' +} +if([string]::IsNullOrWhiteSpace($AdminAppPool)){ + $AdminAppPool = Get-DeployInfoValue 'AdminAppPool' +} + Ensure-Command $SshExe Ensure-Command $ScpExe Ensure-Command git