# scrubadubber installer (Windows). # # irm https://scrubadubber.com/install.ps1 | iex # # Downloads the latest scrubadubber-setup.exe from GitHub Releases, verifies its # SHA-256 against checksums.txt, and runs it as a silent install. It does # nothing else — read it first; that is the whole point of this project. # # Override (optional): # SCRUBADUBBER_VERSION release tag to install (default: latest) $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest # GitHub requires TLS 1.2+ — force it for older Windows PowerShell. try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch {} $repo = 'salehkreiner/scrubadubber' $asset = 'scrubadubber-setup.exe' $version = if ($env:SCRUBADUBBER_VERSION) { $env:SCRUBADUBBER_VERSION } else { 'latest' } $base = if ($version -eq 'latest') { "https://github.com/$repo/releases/latest/download" } else { "https://github.com/$repo/releases/download/$version" } $tmp = Join-Path $env:TEMP ('scrubadubber-' + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Force -Path $tmp | Out-Null $exe = Join-Path $tmp $asset $sums = Join-Path $tmp 'checksums.txt' $savedProgress = $ProgressPreference $ProgressPreference = 'SilentlyContinue' # the progress bar makes downloads slow try { Write-Host "Downloading $asset ..." Invoke-WebRequest -Uri "$base/$asset" -OutFile $exe -UseBasicParsing Invoke-WebRequest -Uri "$base/checksums.txt" -OutFile $sums -UseBasicParsing # checksums.txt is sha256sum format: " " $line = Get-Content $sums | Where-Object { $_ -match ('\s\*?' + [regex]::Escape($asset) + '\s*$') } | Select-Object -First 1 if (-not $line) { throw "no checksum entry for $asset in checksums.txt" } $expected = (($line -split '\s+')[0]).ToLower() $actual = (Get-FileHash -Algorithm SHA256 -Path $exe).Hash.ToLower() if ($expected -ne $actual) { throw "checksum mismatch for $asset`n expected $expected`n got $actual" } Write-Host "Checksum verified." Write-Host "Installing (silent)..." # Redirect the installer's stdout/stderr to files rather than inheriting this # script's. The installer launches a long-lived tray app; if that tray shares # our stdout, a piped caller (`irm … | iex`) never sees end-of-stream and the # one-liner appears to hang. Redirecting breaks that handle chain. The output # is printed afterward so install progress is still visible. $outLog = Join-Path $tmp 'setup-out.log' $errLog = Join-Path $tmp 'setup-err.log' $proc = Start-Process -FilePath $exe -ArgumentList '--yes' -Wait -PassThru ` -RedirectStandardOutput $outLog -RedirectStandardError $errLog if (Test-Path $outLog) { Get-Content $outLog | ForEach-Object { Write-Host $_ } } if ((Test-Path $errLog) -and (Get-Item $errLog).Length -gt 0) { Get-Content $errLog | ForEach-Object { Write-Host $_ } } if ($proc.ExitCode -ne 0) { throw "installer exited with code $($proc.ExitCode)" } Write-Host "" Write-Host "Done. scrubadubber is installed." } finally { $ProgressPreference = $savedProgress Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }