diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index da3e3ea..89794fd 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -25,15 +25,13 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#787](https://github.com/Icinga/icinga-powershell-framework/pull/787) Fixes the return value in case the `Agent` component could not be installed from `$FALSE` to `null` * [#796](https://github.com/Icinga/icinga-powershell-framework/issues/796) [#798](https://github.com/Icinga/icinga-powershell-framework/issues/798) Fixes an issue with the new check handling, which did not properly convert values from checks to the correct performance data values and base values in some cases * [#797](https://github.com/Icinga/icinga-powershell-framework/issues/797) Fixes plugins throwing `UNKNOWN` in case `-TresholdInterval` is used for Metrics over Time, when checks are newly registered and checked, before the first MoT is executed and collected +* [#800](https://github.com/Icinga/icinga-powershell-framework/pull/800) Fixes an issue for certain plugins, like `Invoke-IcingaCheckProcess`, which reports unknown if MetricsOverTime is used for checks that do not write performance data * [#809](https://github.com/Icinga/icinga-powershell-framework/issues/809) Fixes plugin compiler not handling `AddSummaryHeader` properly for nested check packages, not adding any check information ### Enhancements * [#810](https://github.com/Icinga/icinga-powershell-framework/pull/810) Adds support to suppress messages for `Disable-IcingaUntrustedCertificateValidation` - -## 1.13.3 (tbd) - -* [#800](https://github.com/Icinga/icinga-powershell-framework/pull/800) Fixes an issue for certain plugins, like `Invoke-IcingaCheckProcess`, which reports unknown if MetricsOverTime is used for checks that do not write performance data +* [#812](https://github.com/Icinga/icinga-powershell-framework/pull/812) Adds new Cmdlet `Set-IcingaForWindowsServicesDelayedStart` which will update the Icinga Agent and Icinga for Windows service to run with delayed autostart ## 1.13.2 (2025-02-03) diff --git a/lib/core/framework/Install-IcingaForWindowsService.psm1 b/lib/core/framework/Install-IcingaForWindowsService.psm1 index 8c52348..3246975 100644 --- a/lib/core/framework/Install-IcingaForWindowsService.psm1 +++ b/lib/core/framework/Install-IcingaForWindowsService.psm1 @@ -68,7 +68,7 @@ function Install-IcingaForWindowsService() ); if ($IfWService.Present -eq $FALSE) { - $ServiceCreation = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('create icingapowershell binPath= "{0}" DisplayName= "Icinga PowerShell Service" start= auto', $Path)); + $ServiceCreation = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('create icingapowershell binPath= "{0}" DisplayName= "Icinga PowerShell Service" start= delayed-auto', $Path)); $Global:Icinga.Protected.Environment.'PowerShell Service'.Present = $TRUE; $Global:Icinga.Protected.Environment.'PowerShell Service'.User = $User; $Global:Icinga.Protected.Environment.'PowerShell Service'.ServicePath = $Path; diff --git a/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 b/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 index 9b10f56..b631299 100644 --- a/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 +++ b/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 @@ -165,4 +165,13 @@ function Invoke-IcingaForWindowsMigration() Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.13.0.1'); } + + if (Test-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.13.3')) { + Write-IcingaConsoleNotice 'Applying pending migrations required for Icinga for Windows v1.13.3'; + + # Update the Icinga Agent and Icinga for Windows service to delayed start + Set-IcingaForWindowsServicesDelayedStart; + + Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.13.3'); + } } diff --git a/lib/core/icingaagent/repair/Repair-IcingaService.psm1 b/lib/core/icingaagent/repair/Repair-IcingaService.psm1 index e2b0c97..c0a7f06 100644 --- a/lib/core/icingaagent/repair/Repair-IcingaService.psm1 +++ b/lib/core/icingaagent/repair/Repair-IcingaService.psm1 @@ -60,7 +60,7 @@ function Repair-IcingaService() -Objects $IcingaServicePath; $IcingaServicePath = [string]::Format('\"{0}\" --scm \"daemon\"', $IcingaServicePath); - $IcingaService = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('create icinga2 binPath= "{0}" DisplayName= "Icinga 2" start= auto', $IcingaServicePath)); + $IcingaService = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('create icinga2 binPath= "{0}" DisplayName= "Icinga 2" start= delayed-auto', $IcingaServicePath)); if ($IcingaService.ExitCode -ne 0) { Write-IcingaConsoleError ` diff --git a/lib/core/repository/Install-IcingaComponent.psm1 b/lib/core/repository/Install-IcingaComponent.psm1 index 57e449a..3b2df36 100644 --- a/lib/core/repository/Install-IcingaComponent.psm1 +++ b/lib/core/repository/Install-IcingaComponent.psm1 @@ -288,6 +288,7 @@ function Install-IcingaComponent() [void](Install-IcingaForWindowsService -Path $ServiceBin -User $ServiceUser -Password (Get-IcingaInternalPowerShellServicePassword)); Update-IcingaServiceUser; Set-IcingaInternalPowerShellServicePassword -Password $null; + Set-IcingaForWindowsServicesDelayedStart; $Success = 1; break; } @@ -405,6 +406,7 @@ function Install-IcingaComponent() Set-IcingaServiceUser -User $ServiceUser -SetPermission | Out-Null; Update-IcingaServiceUser; + Set-IcingaForWindowsServicesDelayedStart; Write-IcingaConsoleNotice 'Installation of component "agent" with version "{0}" was successful.' -Objects $MSIData.ProductVersion; } else { diff --git a/lib/core/windows/Set-IcingaForWindowsServicesDelayedStart.psm1 b/lib/core/windows/Set-IcingaForWindowsServicesDelayedStart.psm1 new file mode 100644 index 0000000..aef0a92 --- /dev/null +++ b/lib/core/windows/Set-IcingaForWindowsServicesDelayedStart.psm1 @@ -0,0 +1,36 @@ +<# +.SYNOPSIS + Configures the Icinga services to use delayed auto-start. +.DESCRIPTION + The `Set-IcingaForWindowsServicesDelayedStart` function sets the startup type of the Icinga 2 and Icinga PowerShell services to "delayed-auto" using the `sc.exe` command. This ensures that the services start after other critical system services during the boot process. +.EXAMPLE + Set-IcingaForWindowsServicesDelayedStart + + This example sets the Icinga 2 and Icinga PowerShell services to delayed auto-start if they are present in the environment. +#> +function Set-IcingaForWindowsServicesDelayedStart() +{ + Set-IcingaServiceEnvironment; + + $IcingaAgentService = $Global:Icinga.Protected.Environment.'Icinga Service'; + $IcingaForWindowsService = $Global:Icinga.Protected.Environment.'PowerShell Service'; + + if ($null -ne $IcingaAgentService -And $IcingaAgentService.Present) { + $ServiceUpdate = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'config icinga2 start= delayed-auto'; + + if ($ServiceUpdate.ExitCode -ne 0) { + Write-IcingaConsoleError ([string]::Format('Failed to set the icinga2 service to delayed autostart: {0}', $ServiceUpdate.Message)); + } else { + Write-IcingaConsoleNotice 'Successfully set the icinga2 service to delayed autostart'; + } + } + if ($null -ne $IcingaForWindowsService -And $IcingaForWindowsService.Present) { + $ServiceUpdate = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'config icingapowershell start= delayed-auto'; + + if ($ServiceUpdate.ExitCode -ne 0) { + Write-IcingaConsoleError ([string]::Format('Failed to set the icingapowershell service to delayed autostart: {0}', $ServiceUpdate.Message)); + } else { + Write-IcingaConsoleNotice 'Successfully set the icingapowershell service to delayed autostart'; + } + } +}