Add service start/stop if required while upgrading framework

This commit is contained in:
Lord Hepipud 2019-11-03 22:17:31 +01:00
parent be24dbff2d
commit f3b19145ac

View file

@ -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';
}