# Installs the latest XTermium release from GitHub on Windows (x64), for the current user: # # irm https://xtermium.com/install.ps1 | iex # # Runs the installer (.exe) silently; $env:XTERMIUM_PACKAGE = 'msi' takes the .msi instead, which # installs for every user and asks for admin. The download is checked against the sha256 GitHub # publishes for it before it runs. Everything sits in one script block, so nothing leaks into # the session that ran it. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest is far slower with its progress bar [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $repo = 'xtermium/xtermium' try { $release = Invoke-RestMethod "https://api.github.com/repos/$repo/releases/latest" -Headers @{ Accept = 'application/vnd.github+json' } } catch { throw 'xtermium: no public release yet; see https://xtermium.com/#downloads' } $msi = $env:XTERMIUM_PACKAGE -eq 'msi' $like = if ($msi) { '*_x64_*.msi' } else { '*_x64-setup.exe' } $asset = $release.assets | Where-Object { $_.name -like $like } | Select-Object -First 1 if (-not $asset) { throw "xtermium: this release has no $like" } if ($asset.digest -notlike 'sha256:*') { throw "xtermium: GitHub publishes no sha256 for $($asset.name); not installing it unchecked" } $file = Join-Path ([IO.Path]::GetTempPath()) $asset.name Write-Host "xtermium: downloading $($asset.name)" Invoke-WebRequest $asset.browser_download_url -OutFile $file -UseBasicParsing if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $asset.digest.Substring(7)) { Remove-Item $file throw "xtermium: sha256 mismatch for $($asset.name); not installing it" } Write-Host 'xtermium: sha256 checked; installing' $run = if ($msi) { Start-Process msiexec.exe -ArgumentList '/i', "`"$file`"", '/passive' -Wait -PassThru } else { Start-Process $file -ArgumentList '/S' -Wait -PassThru } Remove-Item $file -ErrorAction SilentlyContinue if ($run.ExitCode -ne 0) { throw "xtermium: the installer stopped with code $($run.ExitCode)" } Write-Host 'xtermium: done; open XTermium from the Start menu' }