Fixes duplicate connection question

This commit is contained in:
Lord Hepipud 2019-11-04 09:20:10 +01:00
parent 32d3f7d77f
commit e114c37b95

View file

@ -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) { if ($Endpoints.Count -eq 0) {
$ArrayString = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please specify all endpoints this Agent will report to (separated by ",")' -Default 'v').answer; $ArrayString = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please specify all endpoints this Agent will report to (separated by ",")' -Default 'v').answer;
$Endpoints = ($ArrayString.Replace(' ', '')).Split(','); $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 ($AcceptConnections -eq 0) {
if ($null -eq $AddFirewallRule) { 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) { 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; $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 ($CanConnectToParent) {
if ([string]::IsNullOrEmpty($CAEndpoint)) { 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; $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;