Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
LordHepipud committed Aug 26, 2022
1 parent b1dc837 commit bb2d97c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
9 changes: 4 additions & 5 deletions icinga-powershell-framework.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function Invoke-IcingaCommand()
# Ensure we set the path to another folder to prevent locking the Framework Root Folder
Set-Location (Get-IcingaForWindowsRootPath);

$IcingaShellState = powershell.exe -NoExit -Command {
powershell.exe -NoExit -Command {
$Script = $args[0];
$RootPath = $args[1];
$Version = $args[2];
Expand All @@ -314,9 +314,6 @@ function Invoke-IcingaCommand()
if ($Shell -eq $FALSE -And [string]::IsNullOrEmpty($Script)) {
Install-Icinga;

# Return the current variables
Write-Output $Global:Icinga;

exit $LASTEXITCODE;
}

Expand All @@ -341,7 +338,9 @@ function Invoke-IcingaCommand()
}

# In case we applied updates to the Framework while inside the IMC -> reopen it
if ($null -ne $IcingaShellState -And $IcingaShellState.ContainsKey('InstallWizard') -And $IcingaShellState.InstallWizard.Updating) {
if (Test-IcingaForWindowsManagementConsoleUpdating) {
Set-IcingaForWindowsManagementConsoleUpdating -Completed;

# Use the same arguments again to open the IMC
$IMCReopenArguments = @{
'ScriptBlock' = $ScriptBlock;
Expand Down
1 change: 0 additions & 1 deletion lib/core/installer/Install-Icinga.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function Install-Icinga()
'HeaderPrint' = $FALSE;
'JumpToSummary' = $FALSE;
'Closing' = $FALSE;
'Updating' = $FALSE;
}
);
} else {
Expand Down
18 changes: 6 additions & 12 deletions lib/core/installer/tools/SetUpdatingIMC.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ function Set-IcingaForWindowsManagementConsoleUpdating()
[switch]$Completed = $FALSE
);

if ($null -eq $Global:Icinga) {
return;
}

if ($Global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) {
return;
}
Set-IcingaForWindowsManagementConsoleClosing;

if ($Global:Icinga.InstallWizard.ContainsKey('Updating') -eq $FALSE) {
return;
$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;
}

Set-IcingaForWindowsManagementConsoleClosing;
$global:Icinga.InstallWizard.Updating = (-Not ([bool]$Completed));
}
14 changes: 2 additions & 12 deletions lib/core/installer/tools/TestUpdatingIMC.psm1
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
function Test-IcingaForWindowsManagementConsoleUpdating()
{
if ($null -eq $Global:Icinga) {
return $FALSE;
}
$UpdateFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework.update';

if ($Global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) {
return $FALSE;
}

if ($Global:Icinga.InstallWizard.ContainsKey('Updating') -eq $FALSE) {
return $FALSE;
}

return $global:Icinga.InstallWizard.Updating;
return (Test-Path -Path $UpdateFile);
}

0 comments on commit bb2d97c

Please sign in to comment.