mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Add easier handling to set user permissions
This commit is contained in:
parent
9209a4e671
commit
709402e9c3
3 changed files with 15 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Reference in a new issue