Add easier handling to set user permissions

This commit is contained in:
Lord Hepipud 2019-11-03 18:01:54 +01:00
parent 9209a4e671
commit 709402e9c3
3 changed files with 15 additions and 6 deletions

View file

@ -421,11 +421,7 @@ function Start-IcingaAgentInstallWizard()
if ($RunInstaller) {
if ((Install-IcingaAgent -Version $AgentVersion -Source $PackageSource -AllowUpdates $AllowVersionChanges) -Or $Reconfigure) {
Move-IcingaAgentDefaultConfig;
Set-IcingaAgentServiceUser -User $ServiceUser -Password $ServicePass | Out-Null;
Set-IcingaAgentServicePermission | Out-Null;
Set-IcingaAcl "$Env:ProgramData\icinga2\etc";
Set-IcingaAcl "$Env:ProgramData\icinga2\var";
Set-IcingaAcl (Get-IcingaCacheDir);
Set-IcingaAgentServiceUser -User $ServiceUser -Password $ServicePass -SetPermission | Out-Null;
Install-IcingaFrameworkService -Path $ServiceBin -User $ServiceUser -Password $ServicePass | Out-Null;
Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon';
Install-IcingaAgentBaseFeatures;

View file

@ -3,7 +3,8 @@ function Set-IcingaAgentServiceUser()
param(
[string]$User,
[securestring]$Password,
[string]$Service = 'icinga2'
[string]$Service = 'icinga2',
[switch]$SetPermission
);
if ([string]::IsNullOrEmpty($User)) {
@ -26,6 +27,11 @@ function Set-IcingaAgentServiceUser()
-FlushNewLines $TRUE;
if ($Output.ExitCode -eq 0) {
if ($SetPermission) {
Set-IcingaUserPermissions;
}
Write-Host 'Service User successfully updated'
return $TRUE;
} else {

View file

@ -0,0 +1,7 @@
function Set-IcingaUserPermissions()
{
Set-IcingaAgentServicePermission | Out-Null;
Set-IcingaAcl "$Env:ProgramData\icinga2\etc";
Set-IcingaAcl "$Env:ProgramData\icinga2\var";
Set-IcingaAcl (Get-IcingaCacheDir);
}