Agent: support PowerShell 2.x, fix 32bit issues

PowerShell Agent Kickstart for Windows: Fixed install dir detection on 32bit
Windows and added support for PowerShell 2.x
This commit is contained in:
Christian Stein 2016-11-25 15:31:43 +01:00 committed by Thomas Gelf
parent 7895023498
commit ac3e541317

View File

@ -276,20 +276,18 @@ function Icinga2AgentModule {
if (-Not $this.config('agent_version')) {
return;
}
$WebStatusCode = 0;
$url = $this.config('download_url') + $this.getProperty('install_msi_package');
$this.info('Downloading Icinga 2 Agent Binary from ' + $url + ' ...');
$execptionMsg = '';
Try {
$WebStatusCode = Invoke-WebRequest -UseBasicParsing -Method Head -Uri "$url"
if ($WebStatusCode.StatusCode -eq 200) {
Invoke-WebRequest "$url" -OutFile $this.getInstallerPath();
} else {
throw 'Failed to download Icinga 2 Agent Installer from URL';
Try {
$client = new-object System.Net.WebClient;
$client.DownloadFile($url, $this.getInstallerPath());
if (-Not $this.installerExists()) {
throw 'Unable to locate downloaded Icinga 2 Agent installer file from ' + $url + '. Download destination: ' + $this.getInstallerPath();
}
} catch {
throw 'Unable to download Icinga 2 Agent from ' + $url + '. Error: ' + $_.Exception.Message;
throw 'Unable to download Icinga 2 Agent from ' + $url + '. Please ensure the link does exist and access is possible. Error: ' + $_.Exception.Message;
}
}
@ -382,7 +380,7 @@ function Icinga2AgentModule {
$architecture = '';
$icingaInstallerName = '';
if ([IntPtr]::Size -eq 4) {
$defaultInstallDir = ${Env:ProgramFiles(x86)} + "\ICINGA2";
$defaultInstallDir = ${Env:ProgramFiles} + "\ICINGA2";
$architecture = "x86";
$regPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*';
} else {