From 94ab6ba710c75df86ab41ae33208750fd3f8afde Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 13:41:05 +0100 Subject: [PATCH 1/8] Add support to keep PowerShell open while running as daemon --- lib/daemon/Start-IcingaPowerShellDaemon.psm1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 index 4fe858c..87bbc53 100644 --- a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 +++ b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 @@ -1,5 +1,9 @@ function Start-IcingaPowerShellDaemon() { + param( + [switch]$RunAsService + ); + $ScriptBlock = { param($IcingaDaemonData); @@ -32,4 +36,10 @@ function Start-IcingaPowerShellDaemon() $global:IcingaDaemonData.Add('Config', (Read-IcingaPowerShellConfig)); New-IcingaThreadInstance -Name "Icinga_PowerShell_Background_Daemon" -ThreadPool $IcingaDaemonData.IcingaThreadPool.BackgroundPool -ScriptBlock $ScriptBlock -Arguments @( $global:IcingaDaemonData ) -Start; + + if ($RunAsService) { + while ($TRUE) { + Start-Sleep -Seconds 100; + } + } } From 6b9782f5dcace6c50d6c6d9e7aa3e79093ab6e15 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 13:41:42 +0100 Subject: [PATCH 2/8] Add support to specify a service for changing the user for --- .../icingaagent/setters/Set-IcingaAgentServiceUser.psm1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 b/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 index 6779bf8..d627efe 100644 --- a/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 +++ b/lib/core/icingaagent/setters/Set-IcingaAgentServiceUser.psm1 @@ -2,7 +2,8 @@ function Set-IcingaAgentServiceUser() { param( [string]$User, - [securestring]$Password + [securestring]$Password, + [string]$Service = 'icinga2' ); if ([string]::IsNullOrEmpty($User)) { @@ -14,14 +15,14 @@ function Set-IcingaAgentServiceUser() $User = [string]::Format('.\{0}', $User); } - $ArgString = 'config icinga2 obj= "{0}" password="{1}"'; + $ArgString = 'config {0} obj= "{1}" password="{2}"'; if($null -eq $Password) { - $ArgString = 'config icinga2 obj= "{0}"{1}'; + $ArgString = 'config {0} obj= "{1}"{2}'; } $Output = Start-IcingaProcess ` -Executable 'sc.exe' ` - -Arguments ([string]::Format($ArgString, $User, (ConvertFrom-IcingaSecureString $Password))) ` + -Arguments ([string]::Format($ArgString, $Service, $User, (ConvertFrom-IcingaSecureString $Password))) ` -FlushNewLines $TRUE; if ($Output.ExitCode -eq 0) { From ddef1bd087ef538af1073e742c528097fcc32f20 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 13:43:20 +0100 Subject: [PATCH 3/8] Add support to download and install PowerShell service --- icinga-module-windows.psd1 | 2 +- icinga-module-windows.psm1 | 5 +++ .../framework/Expand-IcingaZipArchive.psm1 | 23 ++++++++++ .../Get-IcingaFrameworkServiceBinary.psm1 | 43 +++++++++++++++++++ .../Install-IcingaPowerShellService.psm1 | 26 +++++++++++ .../Test-IcingaZipBinaryChecksum.psm1 | 23 ++++++++++ 6 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 lib/core/framework/Expand-IcingaZipArchive.psm1 create mode 100644 lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 create mode 100644 lib/core/framework/Install-IcingaPowerShellService.psm1 create mode 100644 lib/core/framework/Test-IcingaZipBinaryChecksum.psm1 diff --git a/icinga-module-windows.psd1 b/icinga-module-windows.psd1 index fdb32d1..e8e36fe 100644 --- a/icinga-module-windows.psd1 +++ b/icinga-module-windows.psd1 @@ -25,7 +25,7 @@ Description = 'Icinga 2 Windows Agent Module, which allows to entirely monitor t PowerShellVersion = '3.0' # Aus diesem Modul zu exportierende Funktionen. Um optimale Leistung zu erzielen, verwenden Sie keine Platzhalter und löschen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Funktionen vorhanden sind. -FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Publish-IcingaModuleManifests', 'Get-IcingaPluginDir', 'Get-IcingaCustomPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir' ) +FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Publish-IcingaModuleManifests', 'Get-IcingaPluginDir', 'Get-IcingaCustomPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir', 'Get-IcingaPowerShellModuleFile' ) # Aus diesem Modul zu exportierende Cmdlets. Um optimale Leistung zu erzielen, verwenden Sie keine Plat'zhalter und löschen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Cmdlets vorhanden sind. CmdletsToExport = @() diff --git a/icinga-module-windows.psm1 b/icinga-module-windows.psm1 index c50c163..77f45d8 100644 --- a/icinga-module-windows.psm1 +++ b/icinga-module-windows.psm1 @@ -165,3 +165,8 @@ function Get-IcingaPowerShellConfigDir() { return (Join-Path -Path $PSScriptRoot -ChildPath 'config'); } + +function Get-IcingaPowerShellModuleFile() +{ + return (Join-Path -Path $PSScriptRoot -ChildPath 'icinga-module-windows.psm1'); +} diff --git a/lib/core/framework/Expand-IcingaZipArchive.psm1 b/lib/core/framework/Expand-IcingaZipArchive.psm1 new file mode 100644 index 0000000..658e63a --- /dev/null +++ b/lib/core/framework/Expand-IcingaZipArchive.psm1 @@ -0,0 +1,23 @@ +function Expand-IcingaZipArchive() +{ + param( + $Path, + $Destination + ); + + if ((Test-Path $Path) -eq $FALSE -Or (Test-Path $Destination) -eq $FALSE) { + Write-Host 'The path to the zip archive or the destination path do not exist'; + return $FALSE; + } + + Add-Type -AssemblyName System.IO.Compression.FileSystem; + + try { + [System.IO.Compression.ZipFile]::ExtractToDirectory($Path, $Destination); + return $TRUE; + } catch { + throw $_.Exception; + } + + return $FALSE; +} diff --git a/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 b/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 new file mode 100644 index 0000000..a80cc72 --- /dev/null +++ b/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 @@ -0,0 +1,43 @@ +function Get-IcingaFrameworkServiceBinary() +{ + param( + [string]$DownloadUrl, + [string]$InstallDir + ); + + $ProgressPreference = "SilentlyContinue"; + + if ([string]::IsNullOrEmpty($DownloadUrl)) { + if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you provide a custom source of the service binary?' -Default 'n').result -eq 1) { + $LatestRelease = (Invoke-WebRequest -Uri 'https://github.com/LordHepipud/icinga-windows-service/releases/latest' -UseBasicParsing).BaseResponse.ResponseUri.AbsoluteUri; + $DownloadUrl = $LatestRelease.Replace('/tag/', '/download/'); + $Tag = $DownloadUrl.Split('/')[-1]; + $DownloadUrl = [string]::Format('{0}/icinga-service-{1}.zip', $DownloadUrl, $Tag); + } else { + $DownloadUrl = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the full path to your service binary repository' -Default 'v').answer; + } + } + + if ([string]::IsNullOrEmpty($InstallDir)) { + $InstallDir = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the path you wish to install the service to' -Default 'v' -DefaultInput 'C:\Program Files\icinga-framework-service\').answer; + } + + if ((Test-Path $InstallDir) -eq $FALSE) { + New-Item -Path $InstallDir -Force -ItemType Directory | Out-Null; + } + + $ZipArchive = Join-Path -Path $InstallDir -ChildPath ($DownloadUrl.Split('/')[-1]); + $ServiceBin = Join-Path -Path $InstallDir -ChildPath 'icinga-service.exe'; + + Invoke-WebRequest -Uri $DownloadUrl -UseBasicParsing -OutFile $ZipArchive; + + if ((Expand-IcingaZipArchive -Path $ZipArchive -Destination $InstallDir) -eq $FALSE) { + throw 'Failed to expand the downloaded ZIP archive'; + } + + if ((Test-IcingaZipBinaryChecksum -Path $ServiceBin) -eq $FALSE) { + throw 'The checksum of the downloaded file and the required MD5 hash are not matching'; + } + + return $ServiceBin; +} diff --git a/lib/core/framework/Install-IcingaPowerShellService.psm1 b/lib/core/framework/Install-IcingaPowerShellService.psm1 new file mode 100644 index 0000000..cd1e2da --- /dev/null +++ b/lib/core/framework/Install-IcingaPowerShellService.psm1 @@ -0,0 +1,26 @@ +function Install-IcingaPowerShellService() +{ + param( + $Path, + $Username, + [SecureString]$Password + ); + + if ((Test-Path $Path) -eq $FALSE) { + throw 'Please specify the path directly to the service binary'; + } + + $Path = [string]::Format( + '{0} \"{1}\"', + $Path, + (Get-IcingaPowerShellModuleFile) + ); + + $ServiceCreation = Start-IcingaProcess -Executable 'sc.exe' -Arguments ([string]::Format('create icingapowershell binPath= "{0}" DisplayName= "Icinga PowerShell Service" start= auto', $Path)); + + if ($ServiceCreation.ExitCode -ne 0) { + throw ([string]::Format('Failed to install Icinga PowerShell Service: {0}{1}', $ServiceCreation.Message, $ServiceCreation.Error)); + } + + return (Set-IcingaAgentServiceUser -User $Username -Password $Password -Service 'icingapowershell'); +} diff --git a/lib/core/framework/Test-IcingaZipBinaryChecksum.psm1 b/lib/core/framework/Test-IcingaZipBinaryChecksum.psm1 new file mode 100644 index 0000000..94612fa --- /dev/null +++ b/lib/core/framework/Test-IcingaZipBinaryChecksum.psm1 @@ -0,0 +1,23 @@ +function Test-IcingaZipBinaryChecksum() +{ + param( + $Path + ); + + $MD5Path = [string]::Format('{0}.md5', $Path); + + if ((Test-Path $MD5Path) -eq $FALSE) { + return $TRUE; + } + + [string]$MD5Checksum = Get-Content $MD5Path; + $MD5Checksum = ($MD5Checksum.Split(' ')[0]).ToLower(); + + $FileHash = ((Get-FileHash $Path -Algorithm MD5).Hash).ToLower(); + + if ($MD5Checksum -ne $FileHash) { + return $FALSE; + } + + return $TRUE; +} From aeaec410d50d03e4882e13f07da3e03aa82e9cbd Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 14:31:49 +0100 Subject: [PATCH 4/8] Fixes uninstall process to stop icinga service first --- lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1 b/lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1 index 4afea1b..cb99f8f 100644 --- a/lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1 +++ b/lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1 @@ -9,6 +9,8 @@ function Uninstall-IcingaAgent() Write-Host 'Removing current installed Icinga Agent'; + Stop-IcingaService 'icinga2'; + $Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine; if ($Uninstaller.ExitCode -ne 0) { From 316c5ca67f18bd3788a0ba3ec615ba17e1bce943 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 14:32:19 +0100 Subject: [PATCH 5/8] Add smart service interaction functions --- lib/core/framework/Restart-IcingaService.psm1 | 10 ++++++++++ lib/core/framework/Start-IcingaService.psm1 | 10 ++++++++++ lib/core/framework/Stop-IcingaService.psm1 | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 lib/core/framework/Restart-IcingaService.psm1 create mode 100644 lib/core/framework/Start-IcingaService.psm1 create mode 100644 lib/core/framework/Stop-IcingaService.psm1 diff --git a/lib/core/framework/Restart-IcingaService.psm1 b/lib/core/framework/Restart-IcingaService.psm1 new file mode 100644 index 0000000..ce0f009 --- /dev/null +++ b/lib/core/framework/Restart-IcingaService.psm1 @@ -0,0 +1,10 @@ +function Restart-IcingaService() +{ + param( + $Service + ); + + if (Get-Service $Service -ErrorAction SilentlyContinue) { + Restart-Service $Service; + } +} diff --git a/lib/core/framework/Start-IcingaService.psm1 b/lib/core/framework/Start-IcingaService.psm1 new file mode 100644 index 0000000..ec4b5a7 --- /dev/null +++ b/lib/core/framework/Start-IcingaService.psm1 @@ -0,0 +1,10 @@ +function Start-IcingaService() +{ + param( + $Service + ); + + if (Get-Service $Service -ErrorAction SilentlyContinue) { + Start-Service $Service; + } +} diff --git a/lib/core/framework/Stop-IcingaService.psm1 b/lib/core/framework/Stop-IcingaService.psm1 new file mode 100644 index 0000000..ef91fa8 --- /dev/null +++ b/lib/core/framework/Stop-IcingaService.psm1 @@ -0,0 +1,10 @@ +function Stop-IcingaService() +{ + param( + $Service + ); + + if (Get-Service $Service -ErrorAction SilentlyContinue) { + Stop-Service $Service; + } +} From a1be74958913e394ac552e3f02ebfb987910cd9b Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 14:32:49 +0100 Subject: [PATCH 6/8] Rename IcingaPowerShellService to IcingaFrameworkService --- ...hellService.psm1 => Install-IcingaFrameworkService.psm1} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename lib/core/framework/{Install-IcingaPowerShellService.psm1 => Install-IcingaFrameworkService.psm1} (80%) diff --git a/lib/core/framework/Install-IcingaPowerShellService.psm1 b/lib/core/framework/Install-IcingaFrameworkService.psm1 similarity index 80% rename from lib/core/framework/Install-IcingaPowerShellService.psm1 rename to lib/core/framework/Install-IcingaFrameworkService.psm1 index cd1e2da..71abdb3 100644 --- a/lib/core/framework/Install-IcingaPowerShellService.psm1 +++ b/lib/core/framework/Install-IcingaFrameworkService.psm1 @@ -1,8 +1,8 @@ -function Install-IcingaPowerShellService() +function Install-IcingaFrameworkService() { param( $Path, - $Username, + $User, [SecureString]$Password ); @@ -22,5 +22,5 @@ function Install-IcingaPowerShellService() throw ([string]::Format('Failed to install Icinga PowerShell Service: {0}{1}', $ServiceCreation.Message, $ServiceCreation.Error)); } - return (Set-IcingaAgentServiceUser -User $Username -Password $Password -Service 'icingapowershell'); + return (Set-IcingaAgentServiceUser -User $User -Password $Password -Service 'icingapowershell'); } From f62dbd08cc98123bc98f5b77272c5724089216a5 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 14:33:56 +0100 Subject: [PATCH 7/8] Extend setup wizard with powershell framework service --- .../Get-IcingaFrameworkServiceBinary.psm1 | 38 ++++++++++--------- .../misc/Start-IcingaAgentInstallWizard.psm1 | 25 +++++++++++- 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 b/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 index a80cc72..97c8396 100644 --- a/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 +++ b/lib/core/framework/Get-IcingaFrameworkServiceBinary.psm1 @@ -1,37 +1,37 @@ function Get-IcingaFrameworkServiceBinary() { param( - [string]$DownloadUrl, - [string]$InstallDir + [string]$FrameworkServiceUrl, + [string]$ServiceDirectory ); $ProgressPreference = "SilentlyContinue"; - if ([string]::IsNullOrEmpty($DownloadUrl)) { + if ([string]::IsNullOrEmpty($FrameworkServiceUrl)) { if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you provide a custom source of the service binary?' -Default 'n').result -eq 1) { - $LatestRelease = (Invoke-WebRequest -Uri 'https://github.com/LordHepipud/icinga-windows-service/releases/latest' -UseBasicParsing).BaseResponse.ResponseUri.AbsoluteUri; - $DownloadUrl = $LatestRelease.Replace('/tag/', '/download/'); - $Tag = $DownloadUrl.Split('/')[-1]; - $DownloadUrl = [string]::Format('{0}/icinga-service-{1}.zip', $DownloadUrl, $Tag); + $LatestRelease = (Invoke-WebRequest -Uri 'https://github.com/LordHepipud/icinga-windows-service/releases/latest' -UseBasicParsing).BaseResponse.ResponseUri.AbsoluteUri; + $FrameworkServiceUrl = $LatestRelease.Replace('/tag/', '/download/'); + $Tag = $FrameworkServiceUrl.Split('/')[-1]; + $FrameworkServiceUrl = [string]::Format('{0}/icinga-service-{1}.zip', $FrameworkServiceUrl, $Tag); } else { - $DownloadUrl = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the full path to your service binary repository' -Default 'v').answer; + $FrameworkServiceUrl = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the full path to your service binary repository' -Default 'v').answer; } } - if ([string]::IsNullOrEmpty($InstallDir)) { - $InstallDir = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the path you wish to install the service to' -Default 'v' -DefaultInput 'C:\Program Files\icinga-framework-service\').answer; + if ([string]::IsNullOrEmpty($ServiceDirectory)) { + $ServiceDirectory = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the path you wish to install the service to' -Default 'v' -DefaultInput 'C:\Program Files\icinga-framework-service\').answer; } - if ((Test-Path $InstallDir) -eq $FALSE) { - New-Item -Path $InstallDir -Force -ItemType Directory | Out-Null; + if ((Test-Path $ServiceDirectory) -eq $FALSE) { + New-Item -Path $ServiceDirectory -Force -ItemType Directory | Out-Null; } - $ZipArchive = Join-Path -Path $InstallDir -ChildPath ($DownloadUrl.Split('/')[-1]); - $ServiceBin = Join-Path -Path $InstallDir -ChildPath 'icinga-service.exe'; + $ZipArchive = Join-Path -Path $ServiceDirectory -ChildPath ($FrameworkServiceUrl.Split('/')[-1]); + $ServiceBin = Join-Path -Path $ServiceDirectory -ChildPath 'icinga-service.exe'; - Invoke-WebRequest -Uri $DownloadUrl -UseBasicParsing -OutFile $ZipArchive; + Invoke-WebRequest -Uri $FrameworkServiceUrl -UseBasicParsing -OutFile $ZipArchive; - if ((Expand-IcingaZipArchive -Path $ZipArchive -Destination $InstallDir) -eq $FALSE) { + if ((Expand-IcingaZipArchive -Path $ZipArchive -Destination $ServiceDirectory) -eq $FALSE) { throw 'Failed to expand the downloaded ZIP archive'; } @@ -39,5 +39,9 @@ function Get-IcingaFrameworkServiceBinary() throw 'The checksum of the downloaded file and the required MD5 hash are not matching'; } - return $ServiceBin; + return @{ + 'FrameworkServiceUrl' = $FrameworkServiceUrl; + 'ServiceDirectory' = $ServiceDirectory; + 'ServiceBin' = $ServiceBin; + }; } diff --git a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 index 40f6c08..dc9cc37 100644 --- a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 +++ b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 @@ -24,7 +24,11 @@ function Start-IcingaAgentInstallWizard() [switch]$RunInstaller, [switch]$Reconfigure, [string]$ServiceUser, - [securestring]$ServicePass = $null + [securestring]$ServicePass = $null, + $InstallFrameworkService = $null, + $FrameworkServiceUrl = $null, + $ServiceDirectory = $null, + $ServiceBin = $null ); [array]$InstallerArguments = @(); @@ -249,6 +253,20 @@ function Start-IcingaAgentInstallWizard() } } + if ($null -eq $InstallFrameworkService) { + if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to install the PowerShell Framework as Service?' -Default 'y').result -eq 1) { + $result = Get-IcingaFrameworkServiceBinary; + $InstallerArguments += "-InstallFrameworkService 1"; + $InstallerArguments += [string]::Format("-FrameworkServiceUrl '{0}'", $result.FrameworkServiceUrl); + $InstallerArguments += [string]::Format("-ServiceDirectory '{0}'", $result.ServiceDirectory); + $InstallerArguments += [string]::Format("-ServiceBin '{0}'", $result.ServiceBin); + $ServiceBin = $result.ServiceBin; + } + } elseif ($InstallFrameworkService -eq $TRUE) { + $result = Get-IcingaFrameworkServiceBinary -FrameworkServiceUrl $FrameworkServiceUrl -ServiceDirectory $ServiceDirectory; + $ServiceBin = $result.ServiceBin; + } + if ($InstallerArguments.Count -ne 0) { $InstallerArguments += "-RunInstaller"; Write-Host 'The wizard is complete. These are the configured settings:'; @@ -276,12 +294,15 @@ function Start-IcingaAgentInstallWizard() Set-IcingaAcl "$Env:ProgramData\icinga2\etc"; Set-IcingaAcl "$Env:ProgramData\icinga2\var"; Set-IcingaAcl (Get-IcingaCacheDir); + Install-IcingaFrameworkService -Path $ServiceBin -User $ServiceUser -Password $ServicePass | Out-Null; + Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon'; Install-IcingaAgentBaseFeatures; Install-IcingaAgentCertificates -Hostname $Hostname -Endpoint $CAEndpoint -Port $CAPort -CACert $CAFile -Ticket $Ticket | Out-Null; Write-IcingaAgentApiConfig -Port $CAPort; Write-IcingaAgentZonesConfig -Endpoints $Endpoints -EndpointConnections $EndpointConnections -ParentZone $ParentZone -GlobalZones $GlobalZoneConfig -Hostname $Hostname; Test-IcingaAgent; - Restart-Service icinga2; + Restart-IcingaService 'icingapowershell'; + Restart-IcingaService 'icinga2'; } } } From 1be22689dd0f37544ade745d1e5591689e731df9 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 14:35:13 +0100 Subject: [PATCH 8/8] Updates Framework Kickstarter Script --- doc/installation/01-KickstartScript.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/installation/01-KickstartScript.md b/doc/installation/01-KickstartScript.md index 7c76ec5..b3e347f 100644 --- a/doc/installation/01-KickstartScript.md +++ b/doc/installation/01-KickstartScript.md @@ -12,7 +12,10 @@ Getting Started [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11"; $ProgressPreference = "SilentlyContinue"; -$Script = (Invoke-WebRequest -UseBasicParsing -Uri 'https://raw.githubusercontent.com/LordHepipud/icinga-framework-kickstart/master/script/icinga-framework-kickstart.ps1').Content; +$global:IcingaFrameworkKickstartSource = 'https://raw.githubusercontent.com/LordHepipud/icinga-framework-kickstart/master/script/icinga-framework-kickstart.ps1'; + +$Script = (Invoke-WebRequest -UseBasicParsing -Uri $global:IcingaFrameworkKickstartSource).Content; +$Script += "`r`n`r`n Start-IcingaFrameworkWizard;"; Invoke-Command -ScriptBlock ([Scriptblock]::Create($Script)); ```