67 lines
2.8 KiB
PowerShell
67 lines
2.8 KiB
PowerShell
function Install-LegacyUtilityPackage {
|
|
<#
|
|
.SYNOPSIS
|
|
Used to install a legacy Alkami utility.
|
|
Examples would include the legacy "Deconversion" utility, the CacheBuster or LogParser tools, etc, from the ORB legacy product.
|
|
|
|
.PARAMETER Path
|
|
[string] The location where the files are already installed to. (Typically via package manager, such as chocolatey)
|
|
|
|
.PARAMETER NeedsShared
|
|
[switch] Used to indicate this project uses the legacy Alkami.Ioc.dll library that requires access to the C:\Orb\Shared or similar folder.
|
|
#>
|
|
[CmdletBinding()]
|
|
[OutputType([void])]
|
|
Param(
|
|
[Parameter(Mandatory = $true, Position = 0)]
|
|
[string]$Path,
|
|
[switch]$NeedsShared
|
|
)
|
|
|
|
$loglead = (Get-LogLeadName)
|
|
|
|
if (!(Test-IsAdmin)){
|
|
throw "$logLead : You are not running as administrator. Can not continue."
|
|
}
|
|
|
|
# Why continue if the files don't exist on disk?
|
|
if (!(Test-Path $Path)) {
|
|
throw "$logLead : Could not find the path specified at [$Path]"
|
|
}
|
|
|
|
if (!(Test-PathIsInApprovedPackageLocation $Path)) {
|
|
Write-Error "$logLead : Can not configure legacy utilities from paths not in 'Approved Locations' (see Test-PathIsInApprovedPackageLocation) using this installer."
|
|
return
|
|
}
|
|
|
|
$utilityName = (Get-ChocoPackageFromPath -Path $Path)
|
|
|
|
Write-Host "$loglead : LegacyUtility [$utilityName] being installed by $($env:username) on $($env:computername) at $(Get-Date)"
|
|
|
|
if ($NeedsShared) {
|
|
## This is in a choco or similar location.
|
|
## We should take the parent of our path and ensure that a "Shared" symlink exists at that point
|
|
## The purpose of this is for Alkami.Ioc resolver to find the parent path in the lookup
|
|
## This introduces a hard-limit that no package can be called Shared (unless it's the Legacy ORB "Shared" folder from the build process)
|
|
$SharedTargetPath = (Join-Path (Split-Path $Path -Parent) "Shared")
|
|
|
|
if (!(Test-Path $SharedTargetPath)) {
|
|
<#
|
|
## Create the symlink here
|
|
cmd /c mklink /J $SharedTargetPath (Get-OrbSharedPath)
|
|
## can be rewritten as
|
|
$cmdArguments @(
|
|
"/c" # run a command as provided in the following strings
|
|
"mklink" # run the make-link command from the cmd.exe interpreter
|
|
"/J" # create a junction type
|
|
$SharedTargetPath # where we are targeting
|
|
(Get-OrbSharedPath) # where it should actually point to
|
|
)
|
|
(Invoke-CallOperatorWithPathAndParameters "C:\WINDOWS\System32\cmd.exe" $cmdArguments)
|
|
## which is better represented by the following line
|
|
#>
|
|
(New-Item -ItemType SymbolicLink -Path $SharedTargetPath -Target (Get-OrbSharedPath)) | Out-Null
|
|
}
|
|
}
|
|
}
|