[icinga-checkins] icinga.org: icingaweb2-module-director/bugfix/service-set-contraints-13309 : Agent: support PowerShell 2.x, fix 32bit issues

git at icinga.org git at icinga.org
Mon Nov 28 16:53:51 CET 2016


Module: icingaweb2-module-director
Branch: bugfix/service-set-contraints-13309
Commit: ac3e5413178b884347e236caeb83155020396abc
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=ac3e5413178b884347e236caeb83155020396abc

Author: Christian Stein <lord-hepipud at phiadariasoft.com>
Date:   Fri Nov 25 15:31:43 2016 +0100

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

---

 contrib/windows-agent-installer/Icinga2Agent.psm1 |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/contrib/windows-agent-installer/Icinga2Agent.psm1 b/contrib/windows-agent-installer/Icinga2Agent.psm1
index 931e305..1cfe17d 100644
--- a/contrib/windows-agent-installer/Icinga2Agent.psm1
+++ b/contrib/windows-agent-installer/Icinga2Agent.psm1
@@ -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"
+            $client = new-object System.Net.WebClient;
+            $client.DownloadFile($url, $this.getInstallerPath());
 
-            if ($WebStatusCode.StatusCode -eq 200) {
-                Invoke-WebRequest "$url" -OutFile $this.getInstallerPath();
-            } else {
-                throw 'Failed to download Icinga 2 Agent Installer from URL';
+            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 {



More information about the icinga-checkins mailing list