Skip to content

Commit 20cda63

Browse files
authored
Merge pull request #515 from Icinga:fix/windows_2012_console_freeze_during_imc_install
Fix: Console freezes on Windows 2012 R2 during IMC installation
2 parents cb613f3 + 7eba933 commit 20cda63

8 files changed

+34
-33
lines changed

lib/core/framework/Install-IcingaFrameworkComponent.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function Install-IcingaFrameworkComponent()
112112

113113
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
114114
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
115-
Invoke-IcingaCommand -ScriptBlock { Install-IcingaJEAProfile; } | Out-Null;
115+
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
116116
}
117117

118118
# Unload the module if it was loaded before

lib/core/framework/Install-IcingaFrameworkUpdate.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Install-IcingaFrameworkUpdate()
109109
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
110110
Remove-IcingaFrameworkDependencyFile;
111111
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
112-
Invoke-IcingaCommand -ScriptBlock { Install-IcingaJEAProfile; } | Out-Null;
112+
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
113113
}
114114

115115
Write-IcingaConsoleNotice 'Framework update has been completed. Please start a new PowerShell instance now to complete the update';

lib/core/framework/Restart-IcingaService.psm1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ function Restart-IcingaService()
2727
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice ([string]::Format('Restarting service "{0}"', $Service));
2929

30-
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
30+
& powershell.exe -Command {
31+
$Service = $args[0];
3132
try {
32-
Restart-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
33+
Restart-Service "$Service" -ErrorAction Stop;
3334
Start-Sleep -Seconds 2;
3435
Optimize-IcingaForWindowsMemory;
3536
} catch {
36-
Write-IcingaConsoleError -Message 'Failed to restart service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
37+
Write-IcingaConsoleError -Message 'Failed to restart service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
3738
}
38-
} | Out-Null;
39+
} -Args $Service;
3940
} else {
4041
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
4142
}

lib/core/framework/Start-IcingaService.psm1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ function Start-IcingaService()
2727
if (Get-Service $Service -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice -Message 'Starting service "{0}"' -Objects $Service;
2929

30-
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
30+
& powershell.exe -Command {
31+
$Service = $args[0];
3132
try {
32-
Start-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
33+
Start-Service "$Service" -ErrorAction Stop;
3334
Start-Sleep -Seconds 2;
3435
Optimize-IcingaForWindowsMemory;
3536
} catch {
36-
Write-IcingaConsoleError -Message 'Failed to start service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
37+
Write-IcingaConsoleError -Message 'Failed to start service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
3738
}
38-
} | Out-Null;
39+
} -Args $Service;
3940
} else {
4041
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
4142
}

lib/core/framework/Stop-IcingaService.psm1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ function Stop-IcingaService()
2424
$Service
2525
);
2626

27-
if (Get-Service $Service -ErrorAction SilentlyContinue) {
27+
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice -Message 'Stopping service "{0}"' -Objects $Service;
2929

30-
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
30+
& powershell.exe -Command {
31+
$Service = $args[0];
3132
try {
32-
Stop-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
33+
Stop-Service "$Service" -ErrorAction Stop;
3334
Start-Sleep -Seconds 2;
3435
Optimize-IcingaForWindowsMemory;
3536
} catch {
36-
Write-IcingaConsoleError -Message 'Failed to stop service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
37+
Write-IcingaConsoleError -Message 'Failed to stop service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
3738
}
38-
} | Out-Null;
39+
} -Args $Service;
3940
} else {
4041
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
4142
}

lib/core/icingaagent/installer/Install-IcingaAgent.psm1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,16 @@ function Install-IcingaAgent()
7373
}
7474
}
7575

76-
$InstallProcess = Invoke-IcingaCommand -ArgumentList $IcingaInstaller, $InstallTarget -ScriptBlock {
77-
$IcingaInstaller = $IcingaShellArgs[0];
78-
$InstallTarget = $IcingaShellArgs[1];
79-
76+
$InstallProcess = & powershell.exe -Command {
77+
$IcingaInstaller = $args[0];
78+
$InstallTarget = $args[1];
8079
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller.InstallerPath, $InstallTarget)) -FlushNewLines;
8180

8281
Start-Sleep -Seconds 2;
8382
Optimize-IcingaForWindowsMemory;
8483

8584
return $InstallProcess;
86-
}
85+
} -Args $IcingaInstaller, $InstallTarget;
8786

8887
if ($InstallProcess.ExitCode -ne 0) {
8988
Write-IcingaConsoleError -Message 'Failed to install Icinga 2 Agent: {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;

lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ function Uninstall-IcingaAgent()
2222

2323
Stop-IcingaService -Service 'icinga2';
2424

25-
$Uninstaller = Invoke-IcingaCommand -ArgumentList $IcingaData -ScriptBlock {
26-
$IcingaData = $IcingaShellArgs[0];
27-
25+
$Uninstaller = & powershell.exe -Command {
26+
$IcingaData = $args[0];
2827
$Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine;
2928

3029
Start-Sleep -Seconds 2;
3130
Optimize-IcingaForWindowsMemory;
3231

3332
return $Uninstaller;
34-
}
33+
} -Args $IcingaData;
3534

3635
if ($Uninstaller.ExitCode -ne 0) {
3736
Write-IcingaConsoleError ([string]::Format('Failed to remove Icinga Agent: {0}{1}', $Uninstaller.Message, $Uninstaller.Error));

lib/core/repository/Install-IcingaComponent.psm1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,10 @@ function Install-IcingaComponent()
348348
}
349349
}
350350

351-
$MSIData = Invoke-IcingaCommand -ArgumentList $DownloadDestination -ScriptBlock {
352-
return (Read-IcingaMSIMetadata -File $IcingaShellArgs[0]);
353-
}
351+
$MSIData = & powershell.exe -Command {
352+
$DownloadDestination = $args[0];
353+
return (Read-IcingaMSIMetadata -File $DownloadDestination);
354+
} -Args $DownloadDestination;
354355

355356
if ($InstalledVersion.Full -eq $MSIData.ProductVersion -And $Force -eq $FALSE) {
356357
Write-IcingaConsoleWarning 'The package "agent" with version "{0}" is already installed. Use "-Force" to re-install the component' -Objects $InstalledVersion.Full;
@@ -367,17 +368,16 @@ function Install-IcingaComponent()
367368
}
368369
}
369370

370-
$InstallProcess = Invoke-IcingaCommand -ArgumentList $DownloadDestination, $InstallTarget -ScriptBlock {
371-
$IcingaInstaller = $IcingaShellArgs[0];
372-
$InstallTarget = $IcingaShellArgs[1];
373-
374-
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller, $InstallTarget)) -FlushNewLines;
371+
$InstallProcess = & powershell.exe -Command {
372+
$DownloadDestination = $args[0];
373+
$InstallTarget = $args[1];
374+
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $DownloadDestination, $InstallTarget)) -FlushNewLines;
375375

376376
Start-Sleep -Seconds 2;
377377
Optimize-IcingaForWindowsMemory;
378378

379379
return $InstallProcess;
380-
}
380+
} -Args $DownloadDestination, $InstallTarget;
381381

382382
if ($InstallProcess.ExitCode -ne 0) {
383383
Write-IcingaConsoleError -Message 'Failed to install component "agent": {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;

0 commit comments

Comments
 (0)