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