diff --git a/scripts/blaise/check_cma_packages.ps1 b/scripts/blaise/check_cma_packages.ps1 index 00faa40e..24b562ff 100644 --- a/scripts/blaise/check_cma_packages.ps1 +++ b/scripts/blaise/check_cma_packages.ps1 @@ -1,12 +1,11 @@ . "$PSScriptRoot\..\logging_functions.ps1" - -$CurrentPath = Get-Location +. "$PSScriptRoot\..\blaise\install_cma_packages.ps1" $Blaise = Get-ItemProperty -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.DisplayName -match 'blaise' } | Select-Object CMAInstalledPackage if (!$Blaise.CMAInstalledPackage) { LogInfo("CMA is not installed") - . "$CurrentPath\scripts\blaise\install_cma_packages.ps1" + Install-Cma-Packages -CreateDatabaseTables "true" Set-ItemProperty -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" -Name "CMAInstalledPackage" -Value $env:ENV_CMA_MULTI_PACKAGE | Where-Object { $_.DisplayName -match 'blaise' } } else { @@ -18,7 +17,7 @@ else { } else { LogInfo("CMA mutli package version needs to be changed") - . "$CurrentPath\scripts\blaise\install_cma_packages.ps1" + Install-Cma-Packages -CreateDatabaseTables "false" Set-ItemProperty -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" -Name "CMAInstalledPackage" -Value $env:ENV_CMA_MULTI_PACKAGE | Where-Object { $_.DisplayName -match 'blaise' } } } \ No newline at end of file diff --git a/scripts/blaise/install_cma_packages.ps1 b/scripts/blaise/install_cma_packages.ps1 index 0786c4f8..e5dc3ba1 100644 --- a/scripts/blaise/install_cma_packages.ps1 +++ b/scripts/blaise/install_cma_packages.ps1 @@ -90,7 +90,11 @@ function Install-PackageViaBlaiseCli { [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] - [string]$FilePath + [string]$FilePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$CreateDatabaseTables ) if (-not (Test-FileExists -FilePath $FilePath)) { @@ -99,28 +103,37 @@ function Install-PackageViaBlaiseCli { $InstrumentName = [System.IO.Path]::GetFileNameWithoutExtension($FilePath) LogInfo("Installing package '$InstrumentName' from '$FilePath' into server park '$ServerParkName' via Blaise CLI") - & "C:\BlaiseServices\BlaiseCli\blaise.cli.exe" questionnaireinstall -s $ServerParkName -q $InstrumentName -f $FilePath -o "false" + & "C:\BlaiseServices\BlaiseCli\blaise.cli.exe" questionnaireinstall -s $ServerParkName -q $InstrumentName -f $FilePath -o $CreateDatabaseTables } -try { - LogInfo("Unzipping CMA multi-package '$CmaMultiPackage' to '$CmaInstrumentPath'") - Expand-ZipFile -FilePath "$CmaInstrumentPath\$CmaMultiPackage" -DestinationPath $CmaInstrumentPath - - # Install the "CMA" package via Server Manager as it does not use a data interface / database - Install-PackageViaServerManager -ServerParkName $CmaServerParkName -FilePath "$CmaInstrumentPath\CMA.bpkg" +function Install-Cma-Packages { + param ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$CreateDatabaseTables + ) - # Install remaining CMA instruments using Blaise CLI for MySQL data interface database configuration - $InstrumentList = 'CMA_Attempts', 'CMA_ContactInfo', 'CMA_Launcher', 'CMA_Logging' - foreach ($Instrument in $InstrumentList) { - Install-PackageViaBlaiseCli -ServerParkName $CmaServerParkName -FilePath "$CmaInstrumentPath\$Instrument.bpkg" + try { + LogInfo("Unzipping CMA multi-package '$CmaMultiPackage' to '$CmaInstrumentPath'") + Expand-ZipFile -FilePath "$CmaInstrumentPath\$CmaMultiPackage" -DestinationPath $CmaInstrumentPath + + # Install the "CMA" package via Server Manager as it does not use a data interface / database + Install-PackageViaServerManager -ServerParkName $CmaServerParkName -FilePath "$CmaInstrumentPath\CMA.bpkg" + + # Install remaining CMA instruments using Blaise CLI for MySQL data interface database configuration + $InstrumentList = 'CMA_Attempts', 'CMA_ContactInfo', 'CMA_Launcher', 'CMA_Logging' + foreach ($Instrument in $InstrumentList) { + Install-PackageViaBlaiseCli -ServerParkName $CmaServerParkName -FilePath "$CmaInstrumentPath\$Instrument.bpkg" -CreateDatabaseTables $CreateDatabaseTables + } + + LogInfo("Removing CMA working folder '$CmaInstrumentPath'") + Remove-Item -LiteralPath $CmaInstrumentPath -Force -Recurse } - - LogInfo("Removing CMA working folder '$CmaInstrumentPath'") - Remove-Item -LiteralPath $CmaInstrumentPath -Force -Recurse -} -catch { - LogError("Installing CMA packages failed") - LogError("$($_.Exception.Message)") - LogError("$($_.ScriptStackTrace)") - exit 1 + catch { + LogError("Installing CMA packages failed") + LogError("$($_.Exception.Message)") + LogError("$($_.ScriptStackTrace)") + exit 1 + } } +