Fixes execution order during Agent installation

This commit is contained in:
Lord Hepipud 2019-11-05 09:35:10 +01:00
parent c4585f3b61
commit 7b8f74cd4f

View file

@ -7,11 +7,6 @@ function Install-IcingaAgent()
[bool]$AllowUpdates = $FALSE [bool]$AllowUpdates = $FALSE
); );
$IcingaData = Get-IcingaAgentInstallation;
$InstalledVersion = Get-IcingaAgentVersion;
$IcingaInstaller = Get-IcingaAgentMSIPackage -Source $Source -Version $Version -SkipDownload;
$InstallTarget = $IcingaData.RootDir;
if ([string]::IsNullOrEmpty($Version)) { if ([string]::IsNullOrEmpty($Version)) {
Write-Host 'No Icinga Agent version specified. Skipping installation.'; Write-Host 'No Icinga Agent version specified. Skipping installation.';
return $FALSE; return $FALSE;
@ -22,6 +17,11 @@ function Install-IcingaAgent()
return $FALSE; return $FALSE;
} }
$IcingaData = Get-IcingaAgentInstallation;
$InstalledVersion = Get-IcingaAgentVersion;
$IcingaInstaller = Get-IcingaAgentMSIPackage -Source $Source -Version $Version -SkipDownload;
$InstallTarget = $IcingaData.RootDir;
if ($Version -eq 'snapshot') { if ($Version -eq 'snapshot') {
if ($IcingaData.InstallDate -ge $IcingaInstaller.LastUpdate -And [string]::IsNullOrEmpty($InstalledVersion.Snapshot) -eq $FALSE) { if ($IcingaData.InstallDate -ge $IcingaInstaller.LastUpdate -And [string]::IsNullOrEmpty($InstalledVersion.Snapshot) -eq $FALSE) {
Write-Host 'There is no new snapshot package available which requires to be installed.' Write-Host 'There is no new snapshot package available which requires to be installed.'