mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Fixes console freezes on IMC install on 2012R2
This commit is contained in:
parent
cb613f34c5
commit
7eba933f2f
8 changed files with 34 additions and 33 deletions
|
|
@ -112,7 +112,7 @@ function Install-IcingaFrameworkComponent()
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
|
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
|
||||||
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
|
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
|
||||||
Invoke-IcingaCommand -ScriptBlock { Install-IcingaJEAProfile; } | Out-Null;
|
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Unload the module if it was loaded before
|
# Unload the module if it was loaded before
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ function Install-IcingaFrameworkUpdate()
|
||||||
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
|
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
|
||||||
Remove-IcingaFrameworkDependencyFile;
|
Remove-IcingaFrameworkDependencyFile;
|
||||||
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
|
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
|
||||||
Invoke-IcingaCommand -ScriptBlock { Install-IcingaJEAProfile; } | Out-Null;
|
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-IcingaConsoleNotice 'Framework update has been completed. Please start a new PowerShell instance now to complete the update';
|
Write-IcingaConsoleNotice 'Framework update has been completed. Please start a new PowerShell instance now to complete the update';
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,16 @@ function Restart-IcingaService()
|
||||||
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
|
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
|
||||||
Write-IcingaConsoleNotice ([string]::Format('Restarting service "{0}"', $Service));
|
Write-IcingaConsoleNotice ([string]::Format('Restarting service "{0}"', $Service));
|
||||||
|
|
||||||
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
|
& powershell.exe -Command {
|
||||||
|
$Service = $args[0];
|
||||||
try {
|
try {
|
||||||
Restart-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
|
Restart-Service "$Service" -ErrorAction Stop;
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
} catch {
|
} catch {
|
||||||
Write-IcingaConsoleError -Message 'Failed to restart service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
|
Write-IcingaConsoleError -Message 'Failed to restart service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
|
||||||
}
|
}
|
||||||
} | Out-Null;
|
} -Args $Service;
|
||||||
} else {
|
} else {
|
||||||
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,16 @@ function Start-IcingaService()
|
||||||
if (Get-Service $Service -ErrorAction SilentlyContinue) {
|
if (Get-Service $Service -ErrorAction SilentlyContinue) {
|
||||||
Write-IcingaConsoleNotice -Message 'Starting service "{0}"' -Objects $Service;
|
Write-IcingaConsoleNotice -Message 'Starting service "{0}"' -Objects $Service;
|
||||||
|
|
||||||
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
|
& powershell.exe -Command {
|
||||||
|
$Service = $args[0];
|
||||||
try {
|
try {
|
||||||
Start-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
|
Start-Service "$Service" -ErrorAction Stop;
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
} catch {
|
} catch {
|
||||||
Write-IcingaConsoleError -Message 'Failed to start service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
|
Write-IcingaConsoleError -Message 'Failed to start service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
|
||||||
}
|
}
|
||||||
} | Out-Null;
|
} -Args $Service;
|
||||||
} else {
|
} else {
|
||||||
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,19 @@ function Stop-IcingaService()
|
||||||
$Service
|
$Service
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Get-Service $Service -ErrorAction SilentlyContinue) {
|
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
|
||||||
Write-IcingaConsoleNotice -Message 'Stopping service "{0}"' -Objects $Service;
|
Write-IcingaConsoleNotice -Message 'Stopping service "{0}"' -Objects $Service;
|
||||||
|
|
||||||
Invoke-IcingaCommand -ArgumentList $Service -ScriptBlock {
|
& powershell.exe -Command {
|
||||||
|
$Service = $args[0];
|
||||||
try {
|
try {
|
||||||
Stop-Service "$($IcingaShellArgs[0])" -ErrorAction Stop;
|
Stop-Service "$Service" -ErrorAction Stop;
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
} catch {
|
} catch {
|
||||||
Write-IcingaConsoleError -Message 'Failed to stop service "{0}". Error: {1}' -Objects $IcingaShellArgs[0], $_.Exception.Message;
|
Write-IcingaConsoleError -Message 'Failed to stop service "{0}". Error: {1}' -Objects $Service, $_.Exception.Message;
|
||||||
}
|
}
|
||||||
} | Out-Null;
|
} -Args $Service;
|
||||||
} else {
|
} else {
|
||||||
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,17 +73,16 @@ function Install-IcingaAgent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$InstallProcess = Invoke-IcingaCommand -ArgumentList $IcingaInstaller, $InstallTarget -ScriptBlock {
|
$InstallProcess = & powershell.exe -Command {
|
||||||
$IcingaInstaller = $IcingaShellArgs[0];
|
$IcingaInstaller = $args[0];
|
||||||
$InstallTarget = $IcingaShellArgs[1];
|
$InstallTarget = $args[1];
|
||||||
|
|
||||||
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller.InstallerPath, $InstallTarget)) -FlushNewLines;
|
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller.InstallerPath, $InstallTarget)) -FlushNewLines;
|
||||||
|
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
|
|
||||||
return $InstallProcess;
|
return $InstallProcess;
|
||||||
}
|
} -Args $IcingaInstaller, $InstallTarget;
|
||||||
|
|
||||||
if ($InstallProcess.ExitCode -ne 0) {
|
if ($InstallProcess.ExitCode -ne 0) {
|
||||||
Write-IcingaConsoleError -Message 'Failed to install Icinga 2 Agent: {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;
|
Write-IcingaConsoleError -Message 'Failed to install Icinga 2 Agent: {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,15 @@ function Uninstall-IcingaAgent()
|
||||||
|
|
||||||
Stop-IcingaService -Service 'icinga2';
|
Stop-IcingaService -Service 'icinga2';
|
||||||
|
|
||||||
$Uninstaller = Invoke-IcingaCommand -ArgumentList $IcingaData -ScriptBlock {
|
$Uninstaller = & powershell.exe -Command {
|
||||||
$IcingaData = $IcingaShellArgs[0];
|
$IcingaData = $args[0];
|
||||||
|
|
||||||
$Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine;
|
$Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine;
|
||||||
|
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
|
|
||||||
return $Uninstaller;
|
return $Uninstaller;
|
||||||
}
|
} -Args $IcingaData;
|
||||||
|
|
||||||
if ($Uninstaller.ExitCode -ne 0) {
|
if ($Uninstaller.ExitCode -ne 0) {
|
||||||
Write-IcingaConsoleError ([string]::Format('Failed to remove Icinga Agent: {0}{1}', $Uninstaller.Message, $Uninstaller.Error));
|
Write-IcingaConsoleError ([string]::Format('Failed to remove Icinga Agent: {0}{1}', $Uninstaller.Message, $Uninstaller.Error));
|
||||||
|
|
|
||||||
|
|
@ -348,9 +348,10 @@ function Install-IcingaComponent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$MSIData = Invoke-IcingaCommand -ArgumentList $DownloadDestination -ScriptBlock {
|
$MSIData = & powershell.exe -Command {
|
||||||
return (Read-IcingaMSIMetadata -File $IcingaShellArgs[0]);
|
$DownloadDestination = $args[0];
|
||||||
}
|
return (Read-IcingaMSIMetadata -File $DownloadDestination);
|
||||||
|
} -Args $DownloadDestination;
|
||||||
|
|
||||||
if ($InstalledVersion.Full -eq $MSIData.ProductVersion -And $Force -eq $FALSE) {
|
if ($InstalledVersion.Full -eq $MSIData.ProductVersion -And $Force -eq $FALSE) {
|
||||||
Write-IcingaConsoleWarning 'The package "agent" with version "{0}" is already installed. Use "-Force" to re-install the component' -Objects $InstalledVersion.Full;
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$InstallProcess = Invoke-IcingaCommand -ArgumentList $DownloadDestination, $InstallTarget -ScriptBlock {
|
$InstallProcess = & powershell.exe -Command {
|
||||||
$IcingaInstaller = $IcingaShellArgs[0];
|
$DownloadDestination = $args[0];
|
||||||
$InstallTarget = $IcingaShellArgs[1];
|
$InstallTarget = $args[1];
|
||||||
|
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $DownloadDestination, $InstallTarget)) -FlushNewLines;
|
||||||
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller, $InstallTarget)) -FlushNewLines;
|
|
||||||
|
|
||||||
Start-Sleep -Seconds 2;
|
Start-Sleep -Seconds 2;
|
||||||
Optimize-IcingaForWindowsMemory;
|
Optimize-IcingaForWindowsMemory;
|
||||||
|
|
||||||
return $InstallProcess;
|
return $InstallProcess;
|
||||||
}
|
} -Args $DownloadDestination, $InstallTarget;
|
||||||
|
|
||||||
if ($InstallProcess.ExitCode -ne 0) {
|
if ($InstallProcess.ExitCode -ne 0) {
|
||||||
Write-IcingaConsoleError -Message 'Failed to install component "agent": {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;
|
Write-IcingaConsoleError -Message 'Failed to install component "agent": {0}{1}' -Objects $InstallProcess.Message, $InstallProcess.Error;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue