# Prism runs inside WSL on Windows. This wrapper never enables Windows features, # requests elevation, changes profiles, or reads endpoint/SDK credentials. [CmdletBinding()] param( [string]$BaseUrl = $(if ($env:PRISM_RELEASE_BASE) { $env:PRISM_RELEASE_BASE } else { 'https://www.prismux.dev/releases/stable' }), [string]$BinDir = '', [string]$Distribution = '', [string]$InstallerUrl = 'https://www.prismux.dev/install.sh', [string]$SigningKey = '', [switch]$Help ) $ErrorActionPreference = 'Stop' if ($Help) { Write-Output @' Install Prism inside an existing WSL Linux distribution. .\install.ps1 [-Distribution Ubuntu] [-BaseUrl HTTPS_URL] [-BinDir LINUX_PATH] [-SigningKey LINUX_ED25519_PUBLIC_KEY_PATH] .\install.ps1 -Help Prism's Windows path currently uses WSL, not a native Windows executable. The Linux installer verifies signed v2 metadata with its pinned Ed25519 key and ssh-keygen (OpenSSH 8.2+), checks signed expiry, then verifies size and SHA-256 before running --version or replacing Prism. SigningKey explicitly trusts an OpenSSH Ed25519 public key file inside WSL. There is no unsigned fallback. No Windows features or shell profiles are changed here. If WSL is not set up, install it first with: wsl --install -d Ubuntu Then launch Ubuntu, complete its user setup, and run this installer again. '@ return } function Assert-HttpsUrl([string]$Value, [string]$Label) { $parsed = $null if (-not [Uri]::TryCreate($Value, [UriKind]::Absolute, [ref]$parsed) -or $parsed.Scheme -ne 'https' -or -not $parsed.Host -or $parsed.UserInfo -or $parsed.Query -or $parsed.Fragment -or $Value -notmatch '^https://[A-Za-z0-9.:/_-]+$' -or $Value -match '/\.{1,2}(/|$)') { throw "$Label must be an HTTPS URL without credentials, query, fragment or dot-segments." } } function ConvertTo-ShLiteral([string]$Value) { # The result travels over stdin, not a Windows native command line. return "'" + $Value.Replace("'", "'\''") + "'" } Assert-HttpsUrl $BaseUrl 'BaseUrl' Assert-HttpsUrl $InstallerUrl 'InstallerUrl' if ($BinDir -match "[\x00\r\n]") { throw 'BinDir cannot contain NUL or line breaks.' } if ($SigningKey -match "[\x00\r\n]") { throw 'SigningKey cannot contain NUL or line breaks.' } if ($Distribution -and $Distribution -notmatch '^[A-Za-z0-9._ -]+$') { throw 'Distribution must be a WSL distribution name.' } $wslCommand = Get-Command wsl.exe -CommandType Application -ErrorAction SilentlyContinue if (-not $wslCommand) { throw 'WSL is not installed. Run wsl --install -d Ubuntu, finish Ubuntu user setup, then run this installer again. No system changes were made.' } $wsl = $wslCommand.Source $wslArgs = @() if ($Distribution) { $wslArgs += @('--distribution', $Distribution) } # This only checks an existing distro; it does not install or enable WSL. $null = & $wsl @wslArgs --exec sh -c 'exit 0' 2>&1 if ($LASTEXITCODE -ne 0) { throw 'No ready WSL distribution was found. Run wsl --install -d Ubuntu if needed, launch Ubuntu and finish user setup, then rerun this installer.' } $adjacent = if ($PSScriptRoot) { Join-Path $PSScriptRoot 'install.sh' } else { '' } if ($adjacent -and (Test-Path -LiteralPath $adjacent -PathType Leaf)) { $script = [IO.File]::ReadAllText($adjacent) } else { # Refusing redirects prevents an HTTPS bootstrap from redirecting to HTTP. $response = Invoke-WebRequest -UseBasicParsing -Uri $InstallerUrl -TimeoutSec 30 -MaximumRedirection 0 $script = [string]$response.Content } if ($script.Length -gt 65536 -or -not $script.StartsWith('#!/bin/sh')) { throw 'The POSIX installer response was not a supported shell installer.' } $arguments = @('--base-url', $BaseUrl) if ($BinDir) { $arguments += @('--bin-dir', $BinDir) } if ($SigningKey) { $arguments += @('--signing-key', $SigningKey) } $quoted = @($arguments | ForEach-Object { ConvertTo-ShLiteral $_ }) $inputScript = "set -- " + ($quoted -join ' ') + "`n" + $script.Replace("`r`n", "`n") $previousEncoding = $OutputEncoding try { $OutputEncoding = New-Object System.Text.UTF8Encoding -ArgumentList $false Write-Output 'Installing Prism inside WSL (Linux).' $inputScript | & $wsl @wslArgs --exec sh -s -- $installExit = $LASTEXITCODE } finally { $OutputEncoding = $previousEncoding } if ($installExit -ne 0) { throw "Prism's WSL installer exited with code $installExit. Its existing executable was preserved if verification failed." } Write-Output 'Open your WSL distribution and run prism. From Windows, use wsl --exec sh -lc prism once its PATH is configured.'