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 2c4d482e28
commit 645744ff81

View file

@ -57,6 +57,12 @@ function Install-IcingaFrameworkUpdate()
return; return;
} }
$ServiceStatus = (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue).Status;
if ($ServiceStatus -eq 'Running') {
Stop-IcingaService 'icingapowershell';
}
$NewDirectory = (Join-Path -Path $ModuleDirectory -ChildPath 'icinga-powershell-framework'); $NewDirectory = (Join-Path -Path $ModuleDirectory -ChildPath 'icinga-powershell-framework');
$ExtractDir = (Join-Path -Path $ModuleDirectory -ChildPath $Extracted); $ExtractDir = (Join-Path -Path $ModuleDirectory -ChildPath $Extracted);
$BackupDir = (Join-Path -Path $ExtractDir -ChildPath 'previous'); $BackupDir = (Join-Path -Path $ExtractDir -ChildPath 'previous');
@ -95,5 +101,9 @@ function Install-IcingaFrameworkUpdate()
Test-IcingaAgent; Test-IcingaAgent;
if ($ServiceStatus -eq 'Running') {
Start-IcingaService 'icingapowershell';
}
Write-Host 'Framework update has been completed'; Write-Host 'Framework update has been completed';
} }