mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Merge pull request #812 from Icinga:feature/ensure_icinga_services_are_set_to_delayed_auto_start
Feauture: Adds support to ensure Icinga services are always set to delayed auto start Adds new Cmdlet `Set-IcingaForWindowsServicesDelayedStart` which will update the Icinga Agent and Icinga for Windows service to run with delayed autostart
This commit is contained in:
commit
7ae4fb40ad
6 changed files with 51 additions and 6 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 `
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue