Merge pull request #270 from Icinga:fix/framework_root_folder_lookup

Fix: Framework root folder lookup

Fixes `Icinga PowerShell Framework` root folder lookup, in case the module was installed with PowerShell gallery, which creates version folders for each installed version
This commit is contained in:
Lord Hepipud 2021-06-01 17:14:24 +02:00 committed by GitHub
commit 212a80cf24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 11 deletions

View file

@ -29,6 +29,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#231](https://github.com/Icinga/icinga-powershell-framework/issues/231) Fixes error while using Icinga Director Self-Service API, in case the host or host API key was deleted inside the Icinga Director and the installation wizard was called with the correct template key, while the old host key was still present inside the Icinga for Windows configuration
* [#232](https://github.com/Icinga/icinga-powershell-framework/pull/232) Fixes wrong encoding while using REST-Api checks experimental feature, and now forces UTF8
* [#237](https://github.com/Icinga/icinga-powershell-framework/issues/237) Fixes `Icinga PowerShell Framework` root folder lookup, in case the module was installed with PowerShell gallery, which creates version folders for each installed version
* [#240](https://github.com/Icinga/icinga-powershell-framework/pull/240) While filtering for certain services with `Get-IcingaServices`, there were some attributes missing from the collection. These are now added resulting in always correct output data.
* [#245](https://github.com/Icinga/icinga-powershell-framework/pull/245) Fixes loading of `.pfx` certificates by properly checking the file type
* [#265](https://github.com/Icinga/icinga-powershell-framework/pull/265) Fixes `Test-Numeric` to now accept negative numeric values and als fixes errors, causing `.` to be allowed multiple times. `ConvertFrom-TimeSpan` now properly prints on negative values if the time provided is positive or negative and also prints microseconds as `us` in case the value is loer than `1ms`

View file

@ -48,6 +48,7 @@
'Get-IcingaCacheDir',
'Get-IcingaPowerShellConfigDir',
'Get-IcingaFrameworkRootPath',
'Get-IcingaForWindowsRootPath',
'Get-IcingaPowerShellModuleFile',
'Start-IcingaShellAsUser',
'Get-IcingaPowerShellConfig',

View file

@ -319,8 +319,16 @@ function Get-IcingaPowerShellConfigDir()
function Get-IcingaFrameworkRootPath()
{
[string]$Path = $PSScriptRoot;
[int]$Index = $Path.LastIndexOf('\') + 1;
return $PSScriptRoot;
}
function Get-IcingaForWindowsRootPath()
{
[string]$Path = $PSScriptRoot;
[int]$Index = $Path.LastIndexOf('icinga-powershell-framework');
$Path = $Path.Substring(0, $Index);
return $Path;
}
@ -340,7 +348,7 @@ function Invoke-IcingaCommand()
);
Import-LocalizedData `
-BaseDirectory (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'icinga-powershell-framework') `
-BaseDirectory (Get-IcingaFrameworkRootPath) `
-FileName 'icinga-powershell-framework.psd1' `
-BindingVariable IcingaFrameworkData;

View file

@ -91,7 +91,7 @@ function Get-IcingaPowerShellModuleArchive()
'Version' = $Tag;
'Directory' = '';
'Archive' = '';
'ModuleRoot' = (Get-IcingaFrameworkRootPath);
'ModuleRoot' = (Get-IcingaForWindowsRootPath);
'Installed' = $FALSE;
};
}
@ -107,7 +107,7 @@ function Get-IcingaPowerShellModuleArchive()
'Version' = $Tag;
'Directory' = '';
'Archive' = '';
'ModuleRoot' = (Get-IcingaFrameworkRootPath);
'ModuleRoot' = (Get-IcingaForWindowsRootPath);
'Installed' = $FALSE;
};
}
@ -131,7 +131,7 @@ function Get-IcingaPowerShellModuleArchive()
'Version' = $Tag;
'Directory' = $DownloadDirectory;
'Archive' = $DownloadDestination;
'ModuleRoot' = (Get-IcingaFrameworkRootPath);
'ModuleRoot' = (Get-IcingaForWindowsRootPath);
'Installed' = $TRUE;
};
}

View file

@ -45,7 +45,7 @@ function Publish-IcingaPluginConfiguration()
}
if ([string]::IsNullOrEmpty($ComponentPath)) {
$ComponentPath = Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath ([string]::Format('icinga-powershell-{0}', $ComponentName));
$ComponentPath = Join-Path -Path (Get-IcingaForWindowsRootPath) -ChildPath ([string]::Format('icinga-powershell-{0}', $ComponentName));
}
if ((Test-Path $ComponentPath) -eq $FALSE) {

View file

@ -40,8 +40,8 @@ function Uninstall-IcingaForWindows()
$CurrentLocation = Get-Location;
if ($CurrentLocation -eq (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'icinga-powershell-framework')) {
Set-Location -Path (Get-IcingaFrameworkRootPath);
if ($CurrentLocation -eq (Get-IcingaFrameworkRootPath)) {
Set-Location -Path (Get-IcingaForWindowsRootPath);
}
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows from this host';

View file

@ -24,7 +24,7 @@ function Uninstall-IcingaFrameworkComponent()
[string]$Name = ''
);
$ModuleBase = Get-IcingaFrameworkRootPath;
$ModuleBase = Get-IcingaForWindowsRootPath;
$UninstallComponent = [string]::Format('icinga-powershell-{0}', $Name);
$UninstallPath = Join-Path -Path $ModuleBase -ChildPath $UninstallComponent;

View file

@ -24,7 +24,7 @@ function Show-IcingaForWindowsManagementConsoleRegisterBackgroundDaemons()
$ModuleInfo = $null;
Import-LocalizedData -BaseDirectory (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath $module.Name) -FileName ([string]::Format('{0}.psd1', $module.Name)) -BindingVariable ModuleInfo -ErrorAction SilentlyContinue;
Import-LocalizedData -BaseDirectory (Join-Path -Path (Get-IcingaForWindowsRootPath) -ChildPath $module.Name) -FileName ([string]::Format('{0}.psd1', $module.Name)) -BindingVariable ModuleInfo -ErrorAction SilentlyContinue;
if ($null -eq $ModuleInfo -Or $null -eq $ModuleInfo.PrivateData -Or $null -eq $ModuleInfo.PrivateData.Type -Or ([string]::IsNullOrEmpty($ModuleInfo.PrivateData.Type)) -Or $ModuleInfo.PrivateData.Type -ne 'daemon' -Or $null -eq $ModuleInfo.PrivateData.Function -Or ([string]::IsNullOrEmpty($ModuleInfo.PrivateData.Function))) {
continue;

View file

@ -10,7 +10,7 @@ function Write-IcingaConsoleHeader()
[array]$TableHeader = @();
Import-LocalizedData `
-BaseDirectory (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'icinga-powershell-framework') `
-BaseDirectory (Get-IcingaFrameworkRootPath) `
-FileName 'icinga-powershell-framework.psd1' `
-BindingVariable IcingaFrameworkData;