Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Add admin owner group on upgrade * detailed logging #231

Merged
merged 2 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions scripts/publish/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ if (-not([string]::IsNullOrEmpty($SignType))) {
}
}
catch {
Write-Warning $_.Exception.Message
throw "Could not find msbuild"
throw "Could not find msbuild: $($_.Exception.Message)"
}

if ([string]::IsNullOrEmpty($SigningIdentity)) {
Expand All @@ -135,8 +134,7 @@ try {
}
}
catch {
Write-Warning $_.Exception.Message
throw "Could not find dotnet tools"
throw "Could not find dotnet tools: $($_.Exception.Message)"
}

DeletePreExistingFiles $OutputPath
Expand Down Expand Up @@ -171,8 +169,7 @@ try{
}
}
catch {
Write-Warning $_.Exception.Message
throw "Publish failed"
throw "Publish failed: $($_.Exception.Message)"
}

$outputConfigPath = Join-Path $applicationPath "config"
Expand Down Expand Up @@ -218,7 +215,7 @@ try {
}
}
catch {
throw "Could not build plugins for publishing"
throw "Could not build plugins for publishing: $($_.Exception.Message)"
}

# Copy setup
Expand Down
23 changes: 16 additions & 7 deletions scripts/setup/config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ function Remove($_path) {
}
}

function EnsureOwnerGroup($settings) {
shhsu marked this conversation as resolved.
Show resolved Hide resolved
$groupName = .\globals.ps1 'IIS_ADMIN_API_OWNERS'
$groupDescription = .\globals.ps1 'IIS_ADMIN_API_OWNERS_DESCRIPTION'
$currentAdUser = .\security.ps1 CurrentAdUser
.\security.ps1 EnsureLocalGroupMember -AdPath $currentAdUser -Name $groupName -Description $groupDescription
if (!$settings.security.users.administrators.Contains($groupName)) {
$settings.security.users.administrators += $groupName
}
if (!$settings.security.users.owners.Contains($groupName)) {
$settings.security.users.owners += $groupName
}
}

# Writes install time information into the appsettings.json file
# AppSettingsPath: The full path to the appsettings.json file
function Write-AppSettings($_appSettingsPath, $_port) {
Expand All @@ -126,13 +139,7 @@ function Write-AppSettings($_appSettingsPath, $_port) {
}

$settings = .\json.ps1 Get-JsonContent -Path $_appSettingsPath

$groupName = .\globals.ps1 'IIS_ADMIN_API_OWNERS'
$groupDescription = .\globals.ps1 'IIS_ADMIN_API_OWNERS_DESCRIPTION'
$currentAdUser = .\security.ps1 CurrentAdUser
.\security.ps1 EnsureLocalGroupMember -AdPath $currentAdUser -Name $groupName -Description $groupDescription
$settings.security.users.administrators += $groupName
$settings.security.users.owners += $groupName
EnsureOwnerGroup $settings

if ($IncludeDefaultCors) {
$settings.cors.rules += @{ "origin" = "https://manage.iis.net"; "allow" = $true }
Expand Down Expand Up @@ -161,6 +168,7 @@ function Migrate-AppSettings($_source, $_destination) {
if ($oldAppSettings.administrators -ne $null) {
.\json.ps1 Remove-Property -JsonObject $oldAppSettings -Name "administrators"
}
EnsureOwnerGroup $oldAppSettings

.\json.ps1 Set-JsonContent -Path $(Join-Path $Destination $userFiles["appsettings.json"]) -JsonObject $oldAppSettings
}
Expand Down Expand Up @@ -238,6 +246,7 @@ function Write-Config($obj, $_path) {
$port = [int]::parse($sPort)
}
catch {
Write-Warning $_.Exception.Message
throw "Misconfigured 'urls' in appsettings: $($appsettings.urls)."
}
}
Expand Down
20 changes: 10 additions & 10 deletions scripts/setup/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function rollback() {
Stop-Service $rollbackStore.createdService -ErrorAction SilentlyContinue
}
catch {
Write-Warning "Could not stop newly created service"
Write-Warning "Could not stop newly created service: $($_.Exception.Message)"
}

sc.exe delete "$($rollbackStore.createdService)" | Out-Null
Expand Down Expand Up @@ -172,7 +172,7 @@ function rollback() {
New-Service -BinaryPathName $binaryPath -StartupType $startType -DisplayName $name -Name $name -ErrorAction Stop | Out-Null
}
catch {
Write-Warning "Could not restore the $($name) service."
Write-Warning "Could not restore the $($name) service: $($_.Exception.Message)"
}
}

Expand All @@ -185,7 +185,7 @@ function rollback() {
.\net.ps1 DeleteSslBinding -Port $rollbackStore.newBoundCertPort
}
catch {
Write-Warning "Could not roll back SSL binding on port $($rollbackStore.newBoundCertPort)"
Write-Warning "Could not roll back SSL binding on port $($rollbackStore.newBoundCertPort): $($_.Exception.Message)"
}
}

Expand All @@ -199,7 +199,7 @@ function rollback() {
.\net.ps1 BindCert -Hash $($info.CertificateHash) -AppId $($info.AppId) -Port $($info.IpEndpoint.Port)
}
catch {
Write-Warning "Could not restore previous SSL binding"
Write-Warning "Could not restore previous SSL binding: $($_.Exception.Message)"
}
}

Expand All @@ -213,7 +213,7 @@ function rollback() {
.\config.ps1 Remove -Path $configPath
}
catch {
Write-Warning "Could not remove setup config"
Write-Warning "Could not remove setup config: $($_.Exception.Message)"
}
}

Expand All @@ -230,7 +230,7 @@ function rollback() {
}
}
catch {
write-warning "Could not delete certificate that was created during installation."
write-warning "Could not delete certificate that was created during installation: $($_.Exception.Message)"
}
}

Expand All @@ -243,7 +243,7 @@ function rollback() {
Start-Service $rollbackStore.stoppedOldService
}
catch {
write-warning "Could not restart service $($rollbackStore.stoppedOldService)."
write-warning "Could not restart service $($rollbackStore.stoppedOldService): $($_.Exception.Message)"
}
}

Expand All @@ -257,7 +257,7 @@ function rollback() {
.\files.ps1 Remove-ItemForced -Path $logsPath
}
catch {
write-warning "Could not delete logs folder $logsPath."
write-warning "Could not delete logs folder $logsPath: $($_.Exception.Message)"
}
}

Expand All @@ -271,7 +271,7 @@ function rollback() {
.\files.ps1 Remove-ItemForced -Path $adminRoot
}
catch {
write-warning "Could not delete installation folder $adminRoot."
write-warning "Could not delete installation folder $adminRoot: $($_.Exception.Message)"
}
}

Expand Down Expand Up @@ -458,7 +458,7 @@ function Install
Start-Service "$ServiceName" -ErrorAction Stop
}
catch {
throw "Could not start service"
throw "Could not start service: $($_.Exception.Message)"
}

$svc = Get-Service "$ServiceName" -ErrorAction SilentlyContinue
Expand Down
9 changes: 5 additions & 4 deletions scripts/setup/migrate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Rollback {
Stop-Service $migrateRollback.startedNewService -ErrorAction Stop
}
catch {
Write-Warning "Could not stop newly created service $($migrateRollback.startedNewService)"
Write-Warning "Could not stop newly created service $($migrateRollback.startedNewService): $($_.Exception.Message)"
}
}

Expand All @@ -37,7 +37,7 @@ function Rollback {
sc.exe delete "$($migrateRollback.createdNewService)" | Out-Null
}
catch {
Write-Warning "Could not remove newly created service '$($migrateRollback.createdNewService)'"
Write-Warning "Could not remove newly created service '$($migrateRollback.createdNewService)': $($_.Exception.Message)"
}
}

Expand All @@ -55,7 +55,7 @@ function Rollback {
New-Service -BinaryPathName $binaryPath -StartupType $startType -DisplayName $name -Name $name -ErrorAction Stop | Out-Null
}
catch {
Write-Warning "Could not restore the $($name) service."
Write-Warning "Could not restore the $($name) service: $($_.Exception.Message)"
}
}

Expand All @@ -68,7 +68,7 @@ function Rollback {
Start-Service $migrateRollback.stoppedSourceService -ErrorAction Stop
}
catch {
Write-Warning "Could not restart source service"
Write-Warning "Could not restart source service: $($_.Exception.Message)"
}
}
}
Expand Down Expand Up @@ -116,6 +116,7 @@ function Migrate {
.\sanitize-logs.ps1 -Source $source
}
catch {
Write-Warning "Error sanitizing logs: $($_.Exception.Message)"
# Never fail
}

Expand Down
1 change: 1 addition & 0 deletions scripts/setup/sanitize-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function Clear-CcsAuditPasswords($IisAdministrationPath) {
Clear-CcsAuditPasswordsFromFile -filePath $file.FullName
}
catch {
Write-Warning "Error clearing ccs audit password from $($file.FullName): $($_.Exception.Message)"
#If one file fails, do not block the remaining files
}
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/setup/security.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function GetLocalGroup($groupName) {
$group = $localAd.Children.Find($groupName, 'group')
}
catch {
Write-Warning $_.Exception.Message
#COM Exception if group doesn't exit
}
}
Expand Down Expand Up @@ -376,7 +377,7 @@ function _Set-AclForced($_path, $_acl, $_recurse) {
}
catch {
# Fail state: owner will be the Administrators group
Write-Warning "Could not restore owner for $($item.fullname)"
Write-Warning "Could not restore owner for $($item.fullname): $($_.Exception.Message)"
}

# Revert any token privileges adjusted
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Uninstall($_path)
.\security.ps1 Add-FullControl -Path $InstallationDirectory.FullName -Identity $system -Recurse
}
catch {
Write-Warning "Unable to obtain full control of installation directory"
Write-Warning "Unable to obtain full control of installation directory: $($_.Exception.Message)"
}
}

Expand Down Expand Up @@ -117,7 +117,7 @@ function Uninstall($_path)
.\files.ps1 Remove-ItemForced -Path $setupConfig -ErrorAction Stop
}
catch {
Write-Warning "Could not remove installation configuration file"
Write-Warning "Could not remove installation configuration file: $($_.Exception.Message)"
}
}
}
Expand Down