icinga-powershell-framework/lib/core/icingaagent/writers/Write-IcingaAgentApiConfig.psm1

21 lines
902 B
PowerShell
Raw Normal View History

2019-09-29 12:25:40 -04:00
function Write-IcingaAgentApiConfig()
{
param(
[int]$Port = 5665
);
[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");
$ApiConf = [string]::Format('{0}{1}{2}{2}', $ApiConf, '}', "`r`n");
$ApiConf = $ApiConf.Substring(0, $ApiConf.Length - 4);
Set-Content -Path (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\api.conf') -Value $ApiConf;
Write-IcingaConsoleNotice 'Api configuration has been written successfully';
2019-09-29 12:25:40 -04:00
}