Skip to content

Commit

Permalink
Merge pull request #189 from ONSdigital/BLAIS5-4514
Browse files Browse the repository at this point in the history
Promote from BLAIS5-4514 to main
  • Loading branch information
elthorne authored Nov 5, 2024
2 parents 0bf76d1 + c3892ae commit b4b97aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
7 changes: 3 additions & 4 deletions scripts/blaise/check_cma_packages.ps1
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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' }
}
}
55 changes: 34 additions & 21 deletions scripts/blaise/install_cma_packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
}
}

0 comments on commit b4b97aa

Please sign in to comment.