From f3b19145ac6154ee1ccc76f121137ac44baec735 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Sun, 3 Nov 2019 22:17:31 +0100 Subject: [PATCH] Add service start/stop if required while upgrading framework --- lib/core/framework/Install-IcingaFrameworkUpdate.psm1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 b/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 index bce23d5..ee00576 100644 --- a/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 +++ b/lib/core/framework/Install-IcingaFrameworkUpdate.psm1 @@ -57,6 +57,12 @@ function Install-IcingaFrameworkUpdate() return; } + $ServiceStatus = (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue).Status; + + if ($ServiceStatus -eq 'Running') { + Stop-IcingaService 'icingapowershell'; + } + $NewDirectory = (Join-Path -Path $ModuleDirectory -ChildPath 'icinga-powershell-framework'); $ExtractDir = (Join-Path -Path $ModuleDirectory -ChildPath $Extracted); $BackupDir = (Join-Path -Path $ExtractDir -ChildPath 'previous'); @@ -95,5 +101,9 @@ function Install-IcingaFrameworkUpdate() Test-IcingaAgent; + if ($ServiceStatus -eq 'Running') { + Start-IcingaService 'icingapowershell'; + } + Write-Host 'Framework update has been completed'; }