mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Improves IMC update and uninstall handling for Framework
This commit is contained in:
parent
29b3f925bd
commit
adde8c0c81
8 changed files with 72 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
* [#531](https://github.com/Icinga/icinga-powershell-framework/pull/531) Adds `Test-IcingaStateFile` and `Repair-IcingaStateFile`, which is integrated into `Test-IcingaAgent`, to ensure the Icinga Agent state file is healthy and not corrupt, causing the Icinga Agent to fail on start
|
||||
* [#534](https://github.com/Icinga/icinga-powershell-framework/pull/534) Improves Icinga and Director configuration generator, by wrapping PowerShell arrays inside `@()` instead of simply writing them comma separated
|
||||
* [#536](https://github.com/Icinga/icinga-powershell-framework/pull/536) Adds new function `Test-IcingaArrayFilter` for easier include and exclude filtering during plugin runtime and to allow filtering of array content for intended values only
|
||||
* [#560](https://github.com/Icinga/icinga-powershell-framework/pull/560) Improves handling for Icinga Management Console which will now terminate itself during full uninstallation and restarts after updating the Icinga PowerShell Framework, to apply changes directly
|
||||
|
||||
## 1.9.2 (2022-06-03)
|
||||
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ function Invoke-IcingaCommand()
|
|||
-FileName 'icinga-powershell-framework.psd1' `
|
||||
-BindingVariable IcingaFrameworkData;
|
||||
|
||||
# Ensure we always remove the update file in case present
|
||||
Set-IcingaForWindowsManagementConsoleUpdating -Completed;
|
||||
|
||||
# Print a header informing our user that loaded the Icinga Framework with a specific
|
||||
# version. We can also skip the header by using $SKipHeader
|
||||
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Shell) {
|
||||
|
|
@ -335,6 +338,24 @@ function Invoke-IcingaCommand()
|
|||
if (Test-Path $PSScriptRoot) {
|
||||
Set-Location $PSScriptRoot;
|
||||
}
|
||||
|
||||
# In case we applied updates to the Framework while inside the IMC -> reopen it
|
||||
if (Test-IcingaForWindowsManagementConsoleUpdating) {
|
||||
Set-IcingaForWindowsManagementConsoleUpdating -Completed;
|
||||
|
||||
# Use the same arguments again to open the IMC
|
||||
$IMCReopenArguments = @{
|
||||
'ScriptBlock' = $ScriptBlock;
|
||||
'SkipHeader' = $SkipHeader;
|
||||
'Manage' = $Manage;
|
||||
'Shell' = $Shell;
|
||||
'RebuildCache' = $RebuildCache;
|
||||
'DeveloperMode' = $DeveloperMode;
|
||||
'ArgumentList' = $ArgumentList;
|
||||
};
|
||||
|
||||
Invoke-IcingaCommand @IMCReopenArguments;
|
||||
}
|
||||
}
|
||||
|
||||
function Start-IcingaShellAsUser()
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ function Uninstall-IcingaForWindows()
|
|||
if ($ComponentsOnly -eq $FALSE) {
|
||||
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
|
||||
Unregister-IcingaEventLog;
|
||||
# Ensure we close the IMC in case being open and we uninstall the Framework
|
||||
Set-IcingaForWindowsManagementConsoleClosing;
|
||||
}
|
||||
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows service';
|
||||
Uninstall-IcingaForWindowsService -RemoveFiles | Out-Null;
|
||||
|
|
|
|||
|
|
@ -175,4 +175,8 @@ function Install-Icinga()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -ne (Get-Command -Name 'Set-IcingaForWindowsManagementConsoleClosing' -ErrorAction SilentlyContinue)) {
|
||||
Set-IcingaForWindowsManagementConsoleClosing -Completed;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
lib/core/installer/tools/SetCloseIMC.psm1
Normal file
20
lib/core/installer/tools/SetCloseIMC.psm1
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function Set-IcingaForWindowsManagementConsoleClosing()
|
||||
{
|
||||
param (
|
||||
[switch]$Completed = $FALSE
|
||||
);
|
||||
|
||||
if ($null -eq $Global:Icinga) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($Global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($Global:Icinga.InstallWizard.ContainsKey('Closing') -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
$global:Icinga.InstallWizard.Closing = (-Not ([bool]$Completed));
|
||||
}
|
||||
15
lib/core/installer/tools/SetUpdatingIMC.psm1
Normal file
15
lib/core/installer/tools/SetUpdatingIMC.psm1
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function Set-IcingaForWindowsManagementConsoleUpdating()
|
||||
{
|
||||
param (
|
||||
[switch]$Completed = $FALSE
|
||||
);
|
||||
|
||||
Set-IcingaForWindowsManagementConsoleClosing;
|
||||
|
||||
$UpdateFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework.update';
|
||||
if ($Completed) {
|
||||
Remove-ItemSecure -Path $UpdateFile -Force -Retries 5 | Out-Null;
|
||||
} else {
|
||||
New-Item -Path $UpdateFile -ItemType File -Force | Out-Null;
|
||||
}
|
||||
}
|
||||
6
lib/core/installer/tools/TestUpdatingIMC.psm1
Normal file
6
lib/core/installer/tools/TestUpdatingIMC.psm1
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
function Test-IcingaForWindowsManagementConsoleUpdating()
|
||||
{
|
||||
$UpdateFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework.update';
|
||||
|
||||
return (Test-Path -Path $UpdateFile);
|
||||
}
|
||||
|
|
@ -165,6 +165,9 @@ function Install-IcingaComponent()
|
|||
Stop-IcingaService 'icinga2';
|
||||
Start-Sleep -Seconds 1;
|
||||
}
|
||||
|
||||
# Ensure we close the IMC in case we do some updates on the Framework
|
||||
Set-IcingaForWindowsManagementConsoleUpdating;
|
||||
}
|
||||
|
||||
if ((Test-Path $ComponentFolder) -eq $FALSE) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue