# toa installer for Windows. # # irm https://toa-switch.pages.dev/install.ps1 | iex # # Downloads toa for this CPU, verifies it against the published SHA-256 # checksums and runs 'toa install'. Nothing is installed if the check fails. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest is much faster without it. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = 'https://toa-switch.pages.dev' $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { 'arm64' } else { 'amd64' } $file = "windows-$arch/toa.exe" $tmp = Join-Path ([IO.Path]::GetTempPath()) ('toa-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { $exe = Join-Path $tmp 'toa.exe' Write-Host "Downloading toa ($file)..." Invoke-WebRequest -UseBasicParsing -Uri "$base/download/$file" -OutFile $exe $sums = (Invoke-WebRequest -UseBasicParsing -Uri "$base/download/SHA256SUMS.txt").Content $line = $sums -split "`n" | Where-Object { ($_ -split '\s+')[1] -eq $file } | Select-Object -First 1 if (-not $line) { throw "No checksum is published for $file." } $expected = ($line -split '\s+')[0].ToLower() $actual = (Get-FileHash -Algorithm SHA256 -Path $exe).Hash.ToLower() if ($actual -ne $expected) { throw "Checksum mismatch for $file. The download was not installed." } Write-Host 'Checksum verified.' & $exe install if ($LASTEXITCODE -ne 0) { throw 'toa install failed.' } } finally { Remove-Item -Recurse -Force -Path $tmp -ErrorAction SilentlyContinue } }