-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support to restore original config after using old PS module
Fixes #65
- Loading branch information
1 parent
96733eb
commit c0e0066
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
lib/core/icingaagent/misc/Reset-IcingaAgentConfigFile.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<# | ||
.SYNOPSIS | ||
Checks for old configurations provided by the old PowerShell module | ||
and restores the original configuration file | ||
.DESCRIPTION | ||
Restores the original Icinga 2 configuration by replacing the existing | ||
configuration created by the old PowerShell module with the plain one | ||
from the Icinga 2 backup file | ||
.FUNCTIONALITY | ||
Restores original Icinga 2 configuration icinga2.conf | ||
.EXAMPLE | ||
PS>Reset-IcingaAgentConfigFile; | ||
.LINK | ||
https://github.com/Icinga/icinga-powershell-framework | ||
#> | ||
|
||
function Reset-IcingaAgentConfigFile() | ||
{ | ||
$ConfigDir = Get-IcingaAgentConfigDirectory; | ||
$OldConfig = Join-Path -Path $ConfigDir -ChildPath 'icinga2.conf'; | ||
$OldConfigBackup = Join-Path -Path $ConfigDir -ChildPath 'icinga2.conf.old.module'; | ||
$OriginalConfig = Join-Path -Path $ConfigDir -ChildPath 'icinga2.confdirector.bak'; | ||
|
||
if ((Test-Path $OriginalConfig)) { | ||
Write-Host 'Found icinga2.conf backup file created by old PowerShell module. Restoring original configuration'; | ||
|
||
Move-Item -Path $OldConfig -Destination $OldConfigBackup; | ||
Move-Item -Path $OriginalConfig -Destination $OldConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters