From e114c37b95acc88acfe6db5ce046e0ba184fb4cc Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Mon, 4 Nov 2019 09:20:10 +0100 Subject: [PATCH] Fixes duplicate connection question --- .../misc/Start-IcingaAgentInstallWizard.psm1 | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 index e5c25f0..a941a0a 100644 --- a/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 +++ b/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1 @@ -219,16 +219,6 @@ function Start-IcingaAgentInstallWizard() } } - if ($null -eq $AcceptConnections) { - if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Will this Agent connect to its parent endpoint(s)?' -Default 'y').result -eq 1) { - $InstallerArguments += "-AcceptConnections 1"; - $AcceptConnections = 1; - } else { - $InstallerArguments += "-AcceptConnections 0"; - $AcceptConnections = 0; - } - } - if ($Endpoints.Count -eq 0) { $ArrayString = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please specify all endpoints this Agent will report to (separated by ",")' -Default 'v').answer; $Endpoints = ($ArrayString.Replace(' ', '')).Split(','); @@ -245,6 +235,20 @@ function Start-IcingaAgentInstallWizard() } } + [bool]$CanConnectToParent = $FALSE; + + if ($null -eq $AcceptConnections) { + if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Is this Agent able to connect to its parent node for certificate generation and general communication?' -Default 'y').result -eq 1) { + $CanConnectToParent = $TRUE; + $InstallerArguments += ("-AcceptConnections 1"); + } else { + $InstallerArguments += ("-AcceptConnections 0"); + } + } elseif ($AcceptConnections) { + $CanConnectToParent = $TRUE; + $InstallerArguments += ("-AcceptConnections 1"); + } + if ($AcceptConnections -eq 0) { if ($null -eq $AddFirewallRule) { if ((Get-IcingaAgentInstallerAnswerInput -Prompt ([string]::Format('Do you want to open the Windows Firewall for incoming traffic on Port "{0}"?', $CAPort)) -Default 'y').result -eq 1) { @@ -317,20 +321,6 @@ function Start-IcingaAgentInstallWizard() $GlobalZoneConfig += $GlobalZones; } - [bool]$CanConnectToParent = $FALSE; - - if ($null -eq $AcceptConnections) { - if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Is this Agent able to connect to its parent node for certificate generation?' -Default 'y').result -eq 1) { - $CanConnectToParent = $TRUE; - $InstallerArguments += ("-AcceptConnections 1"); - } else { - $InstallerArguments += ("-AcceptConnections 0"); - } - } elseif ($AcceptConnections) { - $CanConnectToParent = $TRUE; - $InstallerArguments += ("-AcceptConnections 1"); - } - if ($CanConnectToParent) { if ([string]::IsNullOrEmpty($CAEndpoint)) { $CAEndpoint = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter the FQDN for either ONE of your Icinga parent node/nodes or your Icinga 2 CA master' -Default 'v' -DefaultInput (Get-IPConfigFromString $EndpointConnections[0]).address).answer;