2019-09-29 12:25:40 -04:00
|
|
|
function Write-IcingaAgentApiConfig()
|
|
|
|
|
{
|
2023-06-27 09:59:39 -04:00
|
|
|
param (
|
|
|
|
|
[int]$Port = 5665,
|
|
|
|
|
[string]$CipherList = $null
|
2019-09-29 12:25:40 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
[string]$ApiConf = '';
|
|
|
|
|
|
|
|
|
|
$ApiConf = [string]::Format('{0}object ApiListener "api" {1}{2}', $ApiConf, '{', "`r`n");
|
|
|
|
|
$ApiConf = [string]::Format('{0} accept_commands = true;{1}', $ApiConf, "`r`n");
|
|
|
|
|
$ApiConf = [string]::Format('{0} accept_config = true;{1}', $ApiConf, "`r`n");
|
|
|
|
|
$ApiConf = [string]::Format('{0} bind_host = "::";{1}', $ApiConf, "`r`n");
|
|
|
|
|
$ApiConf = [string]::Format('{0} bind_port = {1};{2}', $ApiConf, $Port, "`r`n");
|
2023-06-27 09:59:39 -04:00
|
|
|
if ([string]::IsNullOrEmpty($CipherList) -eq $FALSE) {
|
|
|
|
|
$ApiConf = [string]::Format('{0} cipher_list = "{1}";{2}', $ApiConf, $CipherList, "`r`n");
|
|
|
|
|
}
|
2019-09-29 12:25:40 -04:00
|
|
|
$ApiConf = [string]::Format('{0}{1}{2}{2}', $ApiConf, '}', "`r`n");
|
|
|
|
|
|
|
|
|
|
$ApiConf = $ApiConf.Substring(0, $ApiConf.Length - 4);
|
2020-08-04 08:48:32 -04:00
|
|
|
|
2021-08-21 06:28:42 -04:00
|
|
|
Write-IcingaFileSecure -File (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\api.conf') -Value $ApiConf;
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice 'Api configuration has been written successfully';
|
2019-09-29 12:25:40 -04:00
|
|
|
}
|