Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions scripts/install_source.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,34 @@ function Install-WindowsVCRedistIfNeeded {
Write-Warning 'After installing, reopen PowerShell and restart OpenSquilla.'
}

function Assert-OpenSquillaNotRunning {
if (-not $script:isWindowsHost) {
return
}

try {
$running = @(Get-CimInstance Win32_Process -ErrorAction Stop | Where-Object {
$_.ProcessId -ne $PID -and
$_.CommandLine -and
$_.CommandLine -match '(?i)opensquilla' -and
$_.CommandLine -notmatch '(?i)install_source\.ps1'
})
} catch {
Write-Warning 'install_source.ps1: could not inspect running processes; continuing with the installer.'
return
}

if ($running.Count -eq 0) {
return
}

$details = @($running | ForEach-Object {
$name = if ($_.Name) { $_.Name } else { 'unknown process' }
"$name (PID $($_.ProcessId))"
}) -join ', '
Write-Error "install_source.ps1: OpenSquilla is running ($details). Stop it before upgrading so the existing CLI remains recoverable if installation cannot replace locked files."
}

# --- installer selection ----------------------------------------------------

$installer = $null
Expand Down Expand Up @@ -454,6 +482,7 @@ if ($dryRun) {

# --- execute ---------------------------------------------------------------

Assert-OpenSquillaNotRunning
Test-SquillaRouterAssets
Build-WebUI
Install-WindowsVCRedistIfNeeded
Expand Down
10 changes: 10 additions & 0 deletions tests/test_install_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def test_windows_installer_stops_when_native_install_command_fails() -> None:
assert "exit $installExitCode" in ps1


def test_windows_source_installer_preflights_running_opensquilla() -> None:
ps1 = SOURCE_PS1.read_text(encoding="utf-8")

assert "function Assert-OpenSquillaNotRunning" in ps1
assert "Get-CimInstance Win32_Process" in ps1
assert "install_source.ps1: OpenSquilla is running" in ps1
assert "Stop it before upgrading" in ps1
assert "Assert-OpenSquillaNotRunning" in ps1


def test_install_script_banners_are_ascii_for_windows_terminals() -> None:
scripts = [
RELEASE_PS1.read_text(encoding="utf-8"),
Expand Down
Loading