feat: initial PSG Launcher scaffold
This commit is contained in:
54
scripts/_openssl.ps1
Normal file
54
scripts/_openssl.ps1
Normal file
@@ -0,0 +1,54 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Shared helper — locate OpenSSL and add its bin dir to the session PATH.
|
||||
Dot-source this at the top of any script that needs openssl:
|
||||
. "$PSScriptRoot\_openssl.ps1"
|
||||
#>
|
||||
|
||||
function Find-OpenSSL {
|
||||
# 1. Already on PATH?
|
||||
if (Get-Command openssl -ErrorAction SilentlyContinue) {
|
||||
return (Get-Command openssl).Source
|
||||
}
|
||||
|
||||
# 2. Probe well-known Windows install locations
|
||||
$candidates = @(
|
||||
"$env:ProgramFiles\OpenSSL-Win64\bin\openssl.exe"
|
||||
"$env:ProgramFiles\OpenSSL\bin\openssl.exe"
|
||||
"${env:ProgramFiles(x86)}\OpenSSL-Win32\bin\openssl.exe"
|
||||
"C:\Program Files\OpenSSL-Win64\bin\openssl.exe"
|
||||
"C:\Program Files\OpenSSL\bin\openssl.exe"
|
||||
"C:\tools\OpenSSL\bin\openssl.exe"
|
||||
"$env:ChocolateyInstall\bin\openssl.exe"
|
||||
"$env:ProgramFiles\Git\usr\bin\openssl.exe"
|
||||
"$env:LocalAppData\Programs\Git\usr\bin\openssl.exe"
|
||||
)
|
||||
|
||||
foreach ($candidate in $candidates) {
|
||||
if (Test-Path $candidate) {
|
||||
# Add the bin directory to the session PATH so subsequent
|
||||
# `& openssl ...` calls work without a full path.
|
||||
$binDir = Split-Path $candidate
|
||||
$env:PATH = "$binDir;$env:PATH"
|
||||
Write-Host "Found OpenSSL at: $candidate" -ForegroundColor Cyan
|
||||
return $candidate
|
||||
}
|
||||
}
|
||||
|
||||
# 3. Nothing found — give actionable guidance
|
||||
Write-Error @"
|
||||
OpenSSL not found in PATH or any of the standard install locations.
|
||||
|
||||
If it is installed somewhere else, add its bin directory to your PATH:
|
||||
`$env:PATH = 'C:\Path\To\OpenSSL\bin;' + `$env:PATH
|
||||
|
||||
Otherwise install it:
|
||||
winget install ShiningLight.OpenSSL.Light
|
||||
# — then restart this terminal —
|
||||
"@
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Run on dot-source — sets `$openssl` in the caller's scope
|
||||
$openssl = Find-OpenSSL
|
||||
Write-Host "OpenSSL ready: $(& $openssl version)" -ForegroundColor DarkGray
|
||||
Reference in New Issue
Block a user