-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.ps1
More file actions
executable file
·48 lines (42 loc) · 1.85 KB
/
Copy pathinstall.ps1
File metadata and controls
executable file
·48 lines (42 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# secondwind installer for Windows.
#
# irm https://raw.githubusercontent.com/orchetron/secondwind/main/install.ps1 | iex
#
# Downloads a checksum-verified binary for this machine. Overrides via env:
# SECONDWIND_REPO, SECONDWIND_VERSION, INSTALL_DIR
$ErrorActionPreference = "Stop"
$repo = if ($env:SECONDWIND_REPO) { $env:SECONDWIND_REPO } else { "orchetron/secondwind" }
$version = if ($env:SECONDWIND_VERSION) { $env:SECONDWIND_VERSION } else { "latest" }
$dir = if ($env:INSTALL_DIR) { $env:INSTALL_DIR } else { "$env:LOCALAPPDATA\secondwind\bin" }
if (-not [Environment]::Is64BitOperatingSystem) { throw "secondwind: only 64-bit Windows is supported" }
$target = "x86_64-pc-windows-msvc"
$zip = "secondwind-$target.zip"
$base = if ($version -eq "latest") {
"https://github.com/$repo/releases/latest/download"
} else {
"https://github.com/$repo/releases/download/$version"
}
$tmp = New-Item -ItemType Directory -Path (Join-Path $env:TEMP ([guid]::NewGuid()))
$archive = Join-Path $tmp $zip
Invoke-WebRequest "$base/$zip" -OutFile $archive
try {
$sums = Join-Path $tmp "SHA256SUMS"
Invoke-WebRequest "$base/SHA256SUMS" -OutFile $sums
$line = Get-Content $sums | Where-Object { $_ -match [regex]::Escape($zip) } | Select-Object -First 1
if ($line) {
$want = ($line -split '\s+')[0].ToLower()
$got = (Get-FileHash $archive -Algorithm SHA256).Hash.ToLower()
if ($got -ne $want) { throw "secondwind: checksum mismatch" }
}
} catch {
if ($_.Exception.Message -like "*checksum*") { throw }
}
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Expand-Archive -Path $archive -DestinationPath $dir -Force
Write-Host "installed secondwind to $dir"
if (($env:PATH -split ';') -notcontains $dir) {
Write-Host "add it to your PATH:"
Write-Host " setx PATH `"$dir;`$env:PATH`""
}
Write-Host ""
Write-Host "next: secondwind check then secondwind proof"