# SPDX-License-Identifier: Apache-2.0 # # Boom Box installer for Windows 10 (2004+) and 11. Downloads the newest # release's setup from GitHub, checks it against the release's SHA256SUMS and # installs it for the current user (no admin rights needed). # # irm https://raw.githubusercontent.com/aacronicer/boom-box/main/install.ps1 | iex # # A specific release, or a dry run (download and verify, don't install): # # & ([scriptblock]::Create((irm https://raw.githubusercontent.com/aacronicer/boom-box/main/install.ps1))) -Version 0.10.2 -DryRun # # Linux: curl -fsSL https://raw.githubusercontent.com/aacronicer/boom-box/main/install.sh | sh param( [string]$Version = $env:BOOMBOX_VERSION, [switch]$DryRun ) # In a child scope, so nothing (not even $ErrorActionPreference) is left # behind in the user's PowerShell session. & { $ErrorActionPreference = 'Stop' # Windows PowerShell 5.1 downloads very slowly while drawing a progress bar. $ProgressPreference = 'SilentlyContinue' # Windows PowerShell 5.1 may not offer TLS 1.2, which GitHub requires. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $repo = 'aacronicer/boom-box' $api = if ($env:BOOMBOX_API) { $env:BOOMBOX_API } else { "https://api.github.com/repos/$repo/releases" } $agent = 'boom-box-installer' # Seconds before a stalled request gives up, rather than hanging. $timeout = 60 function Step([string]$text) { Write-Host "==> $text" -ForegroundColor Cyan } function Say([string]$text) { Write-Host " $text" } function Warn([string]$text) { Write-Host "warning: $text" -ForegroundColor Yellow } if (-not [Environment]::Is64BitOperatingSystem) { throw 'Boom Box needs 64-bit Windows.' } $build = [Environment]::OSVersion.Version.Build if ($build -lt 19041) { throw "Boom Box needs Windows 10 version 2004 (build 19041) or later; this is build $build." } if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { Warn 'there is no ARM64 build yet; the x64 build runs under emulation.' } # Smart App Control blocks unsigned apps, and this beta isn't code-signed yet. $sac = $null try { $sac = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy' -Name VerifiedAndReputablePolicyState -ErrorAction Stop).VerifiedAndReputablePolicyState } catch { } if ($sac -eq 1) { Warn 'Smart App Control is on. It blocks apps that are not code-signed, which the Boom Box beta is not yet, so the install will probably be blocked.' } $versionLabel = if ($Version) { "v$($Version.TrimStart('v')) " } else { '' } Step "Finding the ${versionLabel}release" if ($Version) { $tag = 'v' + $Version.TrimStart('v') try { $release = Invoke-RestMethod -Uri "$api/tags/$tag" -UserAgent $agent -UseBasicParsing -TimeoutSec $timeout } catch { throw "There is no release $tag at https://github.com/$repo/releases" } } else { # The newest release, pre-releases included (Boom Box is in beta). $list = Invoke-RestMethod -Uri "$api`?per_page=1" -UserAgent $agent -UseBasicParsing -TimeoutSec $timeout $release = $list | Select-Object -First 1 } if (-not $release -or -not $release.tag_name) { throw "No Boom Box release has been published yet: https://github.com/$repo/releases" } $tag = $release.tag_name $setup = $release.assets | Where-Object { $_.name -like '*_x64-setup.exe' } | Select-Object -First 1 if (-not $setup) { throw "Release $tag has no Windows setup. See https://github.com/$repo/releases/tag/$tag" } $sums = $release.assets | Where-Object { $_.name -eq 'SHA256SUMS' } | Select-Object -First 1 $work = Join-Path ([IO.Path]::GetTempPath()) ('boom-box-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $work | Out-Null try { $file = Join-Path $work $setup.name Step "Downloading $($setup.name)" Invoke-WebRequest -Uri $setup.browser_download_url -OutFile $file -UserAgent $agent -UseBasicParsing if ($sums) { $sumsFile = Join-Path $work 'SHA256SUMS' Invoke-WebRequest -Uri $sums.browser_download_url -OutFile $sumsFile -UserAgent $agent -UseBasicParsing -TimeoutSec $timeout $want = $null foreach ($line in Get-Content $sumsFile) { $parts = $line.Trim() -split '\s+', 2 if ($parts.Count -eq 2 -and $parts[1].TrimStart('*') -eq $setup.name) { $want = $parts[0].ToLower() } } if (-not $want) { throw "SHA256SUMS of $tag doesn't list $($setup.name)" } $got = (Get-FileHash -Path $file -Algorithm SHA256).Hash.ToLower() if ($got -ne $want) { throw "The download is damaged or was tampered with (SHA-256 $got, expected $want)." } Say 'checksum OK' } else { Warn "release $tag has no SHA256SUMS; the download could not be checked" } $ver = $tag.TrimStart('v') Step "Installing Boom Box $ver" Say 'for your user only; no admin rights needed' if ($DryRun) { Say "would run: `"$file`" /S" Step 'Done' Write-Host 'Dry run: nothing was installed.' return } # /S: the setup's silent mode. It closes a running Boom Box to update it. $process = Start-Process -FilePath $file -ArgumentList '/S' -Wait -PassThru if ($process.ExitCode -ne 0) { throw "The setup failed (exit code $($process.ExitCode))." } } finally { Remove-Item -Recurse -Force -Path $work -ErrorAction SilentlyContinue } Step 'Done' $app = Get-ChildItem -Path (Join-Path $env:LOCALAPPDATA 'Boom Box') -Filter '*.exe' -ErrorAction SilentlyContinue | Where-Object { $_.Name -notlike 'uninstall*' } | Select-Object -First 1 if ($app) { Write-Host 'Starting Boom Box. Next time, open it from the Start menu.' Start-Process -FilePath $app.FullName } else { Write-Host 'Open Boom Box from the Start menu.' } Write-Host 'It keeps running in the tray when you close the window.' Write-Host "Phone remote and more: https://github.com/$repo#readme" }