diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 08bc7008..3430f943 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Enhancements * [#756](https://github.com/Icinga/icinga-powershell-framework/pull/756) Adds feature to set process priority for Icinga for Windows to BelowNormal for improved Host performance +* [#757](https://github.com/Icinga/icinga-powershell-framework/pull/757) Adds new Cmdlets `Start-Icinga`, `Stop-Icinga`, `Start-IcingaForWindows` and `Stop-IcingaForWindows` in addition to the existing Cmdlets `Restart-Icinga` and `Restart-IcingaForWindows` ## 1.13.0 Beta-1 (2024-08-30) diff --git a/lib/core/framework/Install-IcingaForWindowsService.psm1 b/lib/core/framework/Install-IcingaForWindowsService.psm1 index 0d7bfa92..8c523485 100644 --- a/lib/core/framework/Install-IcingaForWindowsService.psm1 +++ b/lib/core/framework/Install-IcingaForWindowsService.psm1 @@ -46,7 +46,7 @@ function Install-IcingaForWindowsService() if ($IfWService.Status -eq 'Running') { Write-IcingaConsoleNotice 'Stopping Icinga PowerShell service'; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Start-Sleep -Seconds 1; } @@ -93,7 +93,7 @@ function Install-IcingaForWindowsService() Set-IcingaServiceUser -User 'LocalSystem' -Service 'icingapowershell' | Out-Null; Restart-IcingaForWindows; Start-Sleep -Seconds 1; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Start-Sleep -Seconds 1; if ($IfWService.Status -eq 'Running') { diff --git a/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 b/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 index 6f0afb14..52a27c50 100644 --- a/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 +++ b/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 @@ -57,7 +57,7 @@ function Install-IcingaFrameworkUpdate() if ($ServiceStatus -eq 'Running') { Write-IcingaConsoleNotice 'Stopping Icinga PowerShell service'; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Start-Sleep -Seconds 1; } if ($AgentStatus -eq 'Running') { diff --git a/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 b/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 index 98cc4711..9b10f561 100644 --- a/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 +++ b/lib/core/framework/Invoke-IcingaForWindowsMigration.psm1 @@ -17,7 +17,7 @@ function Invoke-IcingaForWindowsMigration() Write-IcingaConsoleNotice 'Applying pending migrations required for Icinga for Windows v1.8.0'; if ($ServiceStatus -eq 'Running') { - Stop-IcingaWindowsService; + Stop-IcingaForWindows; } $ApiChecks = Get-IcingaPowerShellConfig -Path 'Framework.Experimental.UseApiChecks'; @@ -46,7 +46,7 @@ function Invoke-IcingaForWindowsMigration() $ServiceStatus = (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue).Status; if ($ServiceStatus -eq 'Running') { - Stop-IcingaWindowsService; + Stop-IcingaForWindows; } # Convert the time intervals for the background daemon services from the previous index handling diff --git a/lib/core/framework/Uninstall-IcingaForWindowsService.psm1 b/lib/core/framework/Uninstall-IcingaForWindowsService.psm1 index 093e7da2..fa447eb4 100644 --- a/lib/core/framework/Uninstall-IcingaForWindowsService.psm1 +++ b/lib/core/framework/Uninstall-IcingaForWindowsService.psm1 @@ -26,7 +26,7 @@ function Uninstall-IcingaForWindowsService() $ServiceData = Get-IcingaForWindowsServiceData; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Start-Sleep -Seconds 1; $ServiceCreation = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'delete icingapowershell'; diff --git a/lib/core/installer/menu/manage/settings/services/ManageServices.psm1 b/lib/core/installer/menu/manage/settings/services/ManageServices.psm1 index 02d9f860..51d59ca0 100644 --- a/lib/core/installer/menu/manage/settings/services/ManageServices.psm1 +++ b/lib/core/installer/menu/manage/settings/services/ManageServices.psm1 @@ -83,7 +83,7 @@ function Show-IcingaForWindowsMenuManageIcingaForWindowsServices() 'DisabledReason' = 'The Icinga for Windows service is either not installed or not running'; 'AdminMenu' = $TRUE; 'Action' = @{ - 'Command' = 'Stop-IcingaWindowsService'; + 'Command' = 'Stop-IcingaForWindows'; } }, @{ diff --git a/lib/core/jea/Deny-IcingaJEACommand.psm1 b/lib/core/jea/Deny-IcingaJEACommand.psm1 index b69530a4..59ca2820 100644 --- a/lib/core/jea/Deny-IcingaJEACommand.psm1 +++ b/lib/core/jea/Deny-IcingaJEACommand.psm1 @@ -65,7 +65,7 @@ function Deny-IcingaJEACommand() 'Restart-IcingaForWindows'.ToLower() { return $TRUE; }; - 'Stop-IcingaWindowsService'.ToLower() { + 'Stop-IcingaForWindows'.ToLower() { return $TRUE; }; 'Stop-IcingaService'.ToLower() { diff --git a/lib/core/repository/Install-IcingaComponent.psm1 b/lib/core/repository/Install-IcingaComponent.psm1 index c86bc09c..eba1a23f 100644 --- a/lib/core/repository/Install-IcingaComponent.psm1 +++ b/lib/core/repository/Install-IcingaComponent.psm1 @@ -163,7 +163,7 @@ function Install-IcingaComponent() if ($ServiceStatus -eq 'Running') { Write-IcingaConsoleNotice 'Stopping Icinga for Windows service'; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Start-Sleep -Seconds 1; } if ($AgentStatus -eq 'Running') { diff --git a/lib/core/windows/Restart-Icinga.psm1 b/lib/core/windows/Restart-Icinga.psm1 index 378ebacb..a03e5155 100644 --- a/lib/core/windows/Restart-Icinga.psm1 +++ b/lib/core/windows/Restart-Icinga.psm1 @@ -1,5 +1,5 @@ function Restart-Icinga() { - Restart-IcingaService -Service 'icinga2'; - Restart-IcingaForWindows; + Stop-Icinga; + Start-Icinga; } diff --git a/lib/core/windows/Restart-IcingaWindowsService.psm1 b/lib/core/windows/Restart-IcingaWindowsService.psm1 index 38cdb6cf..8d436949 100644 --- a/lib/core/windows/Restart-IcingaWindowsService.psm1 +++ b/lib/core/windows/Restart-IcingaWindowsService.psm1 @@ -1,16 +1,7 @@ function Restart-IcingaForWindows() { - [string]$JeaPid = Get-IcingaJEAServicePid; - - Stop-IcingaService -Service 'icingapowershell'; - - if ((Test-IcingaJEAServiceRunning -JeaPid $JeaPid)) { - Stop-IcingaJEAProcess -JeaPid $JeaPid; - } - - Restart-IcingaService -Service 'icingapowershell'; - # Update the process priority after each restart - Start-IcingaWindowsScheduledTaskProcessPriority; + Stop-IcingaForWindows; + Start-IcingaForWindows; } Set-Alias -Name 'Restart-IcingaWindowsService' -Value 'Restart-IcingaForWindows'; diff --git a/lib/core/windows/Start-Icinga.psm1 b/lib/core/windows/Start-Icinga.psm1 new file mode 100644 index 00000000..0d49fca6 --- /dev/null +++ b/lib/core/windows/Start-Icinga.psm1 @@ -0,0 +1,5 @@ +function Start-Icinga() +{ + Start-IcingaService -Service 'icinga2'; + Start-IcingaForWindows; +} diff --git a/lib/core/windows/Start-IcingaForWindows.psm1 b/lib/core/windows/Start-IcingaForWindows.psm1 new file mode 100644 index 00000000..574220b1 --- /dev/null +++ b/lib/core/windows/Start-IcingaForWindows.psm1 @@ -0,0 +1,6 @@ +function Start-IcingaForWindows() +{ + Start-IcingaService -Service 'icingapowershell'; + # Update the process priority after each restart + Start-IcingaWindowsScheduledTaskProcessPriority; +} diff --git a/lib/core/windows/Stop-Icinga.psm1 b/lib/core/windows/Stop-Icinga.psm1 new file mode 100644 index 00000000..fa8ed7e7 --- /dev/null +++ b/lib/core/windows/Stop-Icinga.psm1 @@ -0,0 +1,5 @@ +function Stop-Icinga() +{ + Stop-IcingaService -Service 'icinga2'; + Stop-IcingaForWindows; +} diff --git a/lib/core/windows/Stop-IcingaWindowsService.psm1 b/lib/core/windows/Stop-IcingaWindowsService.psm1 index cb89eef0..12914753 100644 --- a/lib/core/windows/Stop-IcingaWindowsService.psm1 +++ b/lib/core/windows/Stop-IcingaWindowsService.psm1 @@ -1,4 +1,4 @@ -function Stop-IcingaWindowsService() +function Stop-IcingaForWindows() { [string]$JeaPid = Get-IcingaJEAServicePid; @@ -8,3 +8,5 @@ function Stop-IcingaWindowsService() Stop-Process -Id $JeaPid -Force; } } + +Set-Alias -Name 'Stop-IcingaWindowsService' -Value 'Stop-IcingaForWindows'; diff --git a/lib/core/windows/Uninstall-IcingaServiceUser.psm1 b/lib/core/windows/Uninstall-IcingaServiceUser.psm1 index 3d1ce162..ba75d786 100644 --- a/lib/core/windows/Uninstall-IcingaServiceUser.psm1 +++ b/lib/core/windows/Uninstall-IcingaServiceUser.psm1 @@ -12,7 +12,7 @@ function Uninstall-IcingaServiceUser() Write-IcingaConsoleNotice 'Uninstalling user "{0}"' -Objects $IcingaUser; Stop-IcingaService 'icinga2'; - Stop-IcingaWindowsService; + Stop-IcingaForWindows; Set-IcingaPowerShellConfig -Path 'Framework.Icinga.ServiceUser' -Value '';