2019-10-22 13:53:50 -04:00
|
|
|
function Register-IcingaBackgroundDaemon()
|
|
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
[string]$Command,
|
|
|
|
|
[hashtable]$Arguments
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ([string]::IsNullOrEmpty($Command)) {
|
|
|
|
|
throw 'Please specify a Cmdlet to run as Background Daemon';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (-Not (Test-IcingaFunction $Command)) {
|
|
|
|
|
throw ([string]::Format('The Cmdlet "{0}" is not available in your session. Please restart the session and try again or verify your input', $Command));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Path = [string]::Format('BackgroundDaemon.EnabledDaemons.{0}', $Command);
|
|
|
|
|
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Command', $Path)) -Value $Command;
|
|
|
|
|
Set-IcingaPowerShellConfig -Path ([string]::Format('{0}.Arguments', $Path)) -Value $Arguments;
|
|
|
|
|
|
2020-05-13 10:53:15 -04:00
|
|
|
Write-IcingaConsoleNotice ([string]::Format('Background daemon Cmdlet "{0}" has been configured', $Command));
|
2019-10-22 13:53:50 -04:00
|
|
|
}
|