From 23b1dfff413f5dbf47f89ba08e52182262a548ae Mon Sep 17 00:00:00 2001 From: cproudlock Date: Wed, 5 Aug 2026 13:30:33 -0400 Subject: [PATCH] Load the equipment catalog from the console The installer offers the catalog as a tick-box, which covers new sites and nobody else. A site that installed before it existed, or unticked the box and later changed its mind, had to be talked through an RDP session and a flask command - which is exactly the sort of thing the console exists to avoid. `shopdb-admin.ps1 catalog`, and C on the menu. It runs the dry run FIRST and prints what would be added, then asks before writing: somebody running this on a site that has been live for years deserves to see what it would touch before it touches anything. Answering anything but yes leaves it alone. An older build without the seed-catalog command is reported as such and told to update, rather than the failure being read as an empty catalog. Repair is now on the menu too. It was reachable only by typing the verb, which is little use to the operator most likely to need it. --- deploy/windows/installer/shopdb-admin.ps1 | 50 ++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/deploy/windows/installer/shopdb-admin.ps1 b/deploy/windows/installer/shopdb-admin.ps1 index 547c56c..cf7673d 100644 --- a/deploy/windows/installer/shopdb-admin.ps1 +++ b/deploy/windows/installer/shopdb-admin.ps1 @@ -22,7 +22,7 @@ [CmdletBinding()] param( [ValidateSet('menu','status','start','stop','restart','logs','open','backup', - 'check','repair','sessions','plugins','add-plugin','verify','uninstall')] + 'check','repair','catalog','sessions','plugins','add-plugin','verify','uninstall')] [string] $Command = 'menu', [string] $Path = '', # Machine-readable output for 'check'. The people running this are expected to @@ -672,6 +672,50 @@ function Invoke-Repair { Restart-App } +function Invoke-Catalog { + Head 'Load the shared equipment catalog' + Say ' Vendors, model numbers, printer supply part numbers and the type' + Say ' lists, as built up across the other sites. It only ADDS - nothing' + Say ' already here is changed or removed - so it is safe to run at any' + Say ' time, including on a site that has been running for years.' + Say '' + Say ' Nothing site-specific is included: no assets, locations or people.' + Say '' + + # Dry run FIRST, always. Somebody running this on a populated site deserves + # to see what it would touch before it touches anything. + Say ' Checking what would be added...' 'White' + $preview = Invoke-Flask @('seed','catalog','--dry-run') + if ($script:LastFlaskExit -ne 0) { + Say ' could not read the catalog' 'Red' + $preview | Select-Object -Last 8 | ForEach-Object { Say " $_" 'Red' } + Say '' + Say ' An older build may not have this command. Update first.' 'Yellow' + return + } + $preview | ForEach-Object { Say " $_" } + + if (($preview | Out-String) -match 'nothing to add') { + Say '' + Say ' Already loaded. Nothing to do.' 'Green' + return + } + + Say '' + $answer = Read-Host ' Load it? (yes/no)' + if ($answer -ne 'yes') { Say ' Left alone.' 'Yellow'; return } + + $out = Invoke-Flask @('seed','catalog') + $out | ForEach-Object { Say " $_" } + if ($script:LastFlaskExit -ne 0) { + Say '' + Say ' Catalog load FAILED. Nothing else was changed.' 'Red' + return + } + Say '' + Say ' Catalog loaded.' 'Green' +} + function Show-Sessions { Head 'Worker processes' $w = Get-CimInstance Win32_Process -Filter "Name='w3wp.exe'" -EA SilentlyContinue @@ -916,6 +960,7 @@ function Show-Menu { Write-Host ' 3 Start the application 8 Open in browser' -ForegroundColor White Write-Host ' 4 View recent logs 9 Plugins' -ForegroundColor White Write-Host ' 5 Health check V Verify this install' -ForegroundColor White + Write-Host ' R Repair provisioning C Load equipment catalog' -ForegroundColor White Write-Host ' 0 Exit' -ForegroundColor White Write-Host '' $c = Read-Host ' Choose' @@ -924,6 +969,8 @@ function Show-Menu { '4' { Show-Logs } '5' { Invoke-Check } '6' { Backup-Db $Path } '7' { Show-Sessions } '8' { Open-Site } 'v' { Invoke-Verify } 'V' { Invoke-Verify } + 'r' { Invoke-Repair } 'R' { Invoke-Repair } + 'c' { Invoke-Catalog } 'C' { Invoke-Catalog } '9' { Show-Plugins $add = Read-Host ' Name of a shipped plugin to add (Enter to skip)' if ($add) { Add-Plugin $add } } @@ -947,6 +994,7 @@ switch ($Command) { 'backup' { Backup-Db $Path } 'check' { Invoke-Check } 'repair' { Invoke-Repair } + 'catalog' { Invoke-Catalog } 'sessions' { Show-Sessions } 'plugins' { Show-Plugins } 'add-plugin'{ Add-Plugin $Path }