Add the browser UI, terminal menu, and one-liner bootstrap
Deployr is now installable and drivable the way winutil is: one PowerShell or
shell line, no prior setup on the machine.
irm .../scripts/install.ps1 | iex
curl -fsSL .../scripts/install.sh | sh
The bootstrap self-elevates, picks the right binary for the machine's
architecture, verifies it against the release SHA256SUMS, puts it on PATH and
opens the UI. Arguments pass through for unattended use.
`deployr ui` serves a point-and-click page on loopback and opens a browser at
it: apps grouped by category, profile bundles, a filter box, and per-app
progress streamed live over SSE as the engine runs. A browser page rather than a
native window because it is the only GUI that behaves the same on all three
platforms without a toolkit or cgo, so the binary stays one static file.
It is not a hole in the endpoint: loopback-only on an OS-assigned port, a
session token minted per run and required on every request, plus Origin and
Host checks so no other page can drive a tool that installs software as SYSTEM.
A run keeps going if the tab closes -- aborting mid-installer is worse than
finishing without a spectator.
`deployr menu` is the same thing as a numbered terminal picker, for a machine
reached over SSH or a recovery console where no browser exists.
Engine gains optional OnAppStart/OnResult hooks, which is what makes progress
streamable instead of a report that only shows up at the end.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
77f88afd7a
commit
af2a96e072
8 files changed
+1460
-3
No files matched your search
@@ -0,0 +1,160 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Deployr bootstrap. Downloads the right binary for this machine, verifies it,
|
||||
installs it, and opens the UI.
|
||||
|
||||
.DESCRIPTION
|
||||
Designed to be run straight off the web, the way winutil is:
|
||||
|
||||
irm https://git.starwarslab.us/ATOM_IT/Deployr/raw/branch/main/scripts/install.ps1 | iex
|
||||
|
||||
With no arguments it installs deployr and opens the point-and-click UI.
|
||||
To pass arguments through instead, create a scriptblock:
|
||||
|
||||
& ([scriptblock]::Create((irm <url>))) install @standard
|
||||
|
||||
Or set $env:DEPLOYR_ARGS before piping to iex:
|
||||
|
||||
$env:DEPLOYR_ARGS = 'install chrome 7zip'; irm <url> | iex
|
||||
|
||||
.PARAMETER DeployrArgs
|
||||
Arguments to pass to deployr. Defaults to opening the UI.
|
||||
|
||||
.PARAMETER Version
|
||||
Release tag to install. Defaults to the latest release.
|
||||
|
||||
.PARAMETER InstallOnly
|
||||
Install the binary and exit without running anything.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromRemainingArguments = $true)]
|
||||
[string[]]$DeployrArgs,
|
||||
[string]$Version = "latest",
|
||||
[switch]$InstallOnly
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue" # Invoke-WebRequest is ~10x faster without the progress bar
|
||||
|
||||
$Repo = "https://git.starwarslab.us/ATOM_IT/Deployr"
|
||||
$Dir = Join-Path $env:ProgramData "Deployr"
|
||||
$Exe = Join-Path $Dir "deployr.exe"
|
||||
|
||||
function Write-Step { param([string]$Message) Write-Host " $Message" -ForegroundColor Cyan }
|
||||
function Write-Ok { param([string]$Message) Write-Host " $Message" -ForegroundColor Green }
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " Deployr bootstrap" -ForegroundColor White
|
||||
Write-Host " ------------------------------------------------" -ForegroundColor DarkGray
|
||||
|
||||
# --- privileges ---------------------------------------------------------
|
||||
# Installing software machine-wide needs an elevated token. Relaunch rather
|
||||
# than failing halfway through a run.
|
||||
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
|
||||
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Step "Elevating..."
|
||||
$argLine = if ($DeployrArgs) { ($DeployrArgs -join ' ') } else { '' }
|
||||
# -File cannot be used here: this script may only exist in memory. Re-fetch
|
||||
# it in the elevated process instead. (-Verb RunAs with -File also fails
|
||||
# silently for a script on a mapped drive.)
|
||||
$bootstrap = "`$env:DEPLOYR_ARGS='$argLine'; irm $Repo/raw/branch/main/scripts/install.ps1 | iex"
|
||||
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($bootstrap))
|
||||
Start-Process -FilePath "powershell.exe" -Verb RunAs -ArgumentList @(
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-EncodedCommand", $encoded
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
# Arguments arrive through the environment when the script was piped to iex.
|
||||
if (-not $DeployrArgs -and $env:DEPLOYR_ARGS) {
|
||||
$DeployrArgs = $env:DEPLOYR_ARGS -split '\s+' | Where-Object { $_ }
|
||||
}
|
||||
|
||||
# --- architecture -------------------------------------------------------
|
||||
$arch = switch ($env:PROCESSOR_ARCHITECTURE) {
|
||||
"AMD64" { "amd64" }
|
||||
"ARM64" { "arm64" }
|
||||
"x86" { if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { throw "32-bit Windows is not supported" } }
|
||||
default { throw "unsupported architecture: $env:PROCESSOR_ARCHITECTURE" }
|
||||
}
|
||||
$asset = "deployr_windows_$arch.exe"
|
||||
Write-Step "Platform: windows/$arch"
|
||||
|
||||
# --- resolve the release ------------------------------------------------
|
||||
# "latest" is not a real download path in Gitea, so resolve it through the API
|
||||
# and take the asset URLs the release actually published.
|
||||
$apiRepo = "$($Repo -replace '/([^/]+)/([^/]+)$', '/api/v1/repos/$1/$2')"
|
||||
$releaseUrl = if ($Version -eq "latest") { "$apiRepo/releases/latest" } else { "$apiRepo/releases/tags/$Version" }
|
||||
|
||||
Write-Step "Resolving release ($Version) ..."
|
||||
$release = Invoke-RestMethod -Uri $releaseUrl -UseBasicParsing -TimeoutSec 60
|
||||
$assetUrl = ($release.assets | Where-Object { $_.name -eq $asset }).browser_download_url
|
||||
$sumsUrl = ($release.assets | Where-Object { $_.name -eq "SHA256SUMS" }).browser_download_url
|
||||
if (-not $assetUrl) { throw "release $($release.tag_name) has no asset named $asset" }
|
||||
Write-Ok "Release $($release.tag_name)"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $Dir | Out-Null
|
||||
|
||||
# --- download -----------------------------------------------------------
|
||||
$tmp = Join-Path $env:TEMP "deployr-$([guid]::NewGuid().ToString('N')).exe"
|
||||
try {
|
||||
Write-Step "Downloading $asset ..."
|
||||
Invoke-WebRequest -Uri $assetUrl -OutFile $tmp -UseBasicParsing -TimeoutSec 300
|
||||
|
||||
# Checksums ship with every release; verify when we can reach them, but do
|
||||
# not fail the whole bootstrap if only the sums file is missing.
|
||||
$expected = $null
|
||||
if ($sumsUrl) {
|
||||
try {
|
||||
$sums = (Invoke-WebRequest -Uri $sumsUrl -UseBasicParsing -TimeoutSec 60).Content
|
||||
foreach ($line in $sums -split "`n") {
|
||||
$parts = ($line.Trim() -split '\s+')
|
||||
if ($parts.Count -ge 2 -and ($parts[-1] -replace '^\*|^\./', '') -eq $asset) { $expected = $parts[0] }
|
||||
}
|
||||
} catch {
|
||||
Write-Warning " could not fetch SHA256SUMS: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($expected) {
|
||||
$actual = (Get-FileHash $tmp -Algorithm SHA256).Hash.ToLower()
|
||||
if ($actual -ne $expected.ToLower()) {
|
||||
throw "checksum mismatch for ${asset}: expected $expected, got $actual"
|
||||
}
|
||||
Write-Ok "Checksum verified"
|
||||
}
|
||||
|
||||
# A running deployr.exe cannot be overwritten; move it aside instead.
|
||||
if (Test-Path $Exe) {
|
||||
try { Remove-Item $Exe -Force }
|
||||
catch { Move-Item $Exe "$Exe.old" -Force -ErrorAction SilentlyContinue }
|
||||
}
|
||||
Move-Item $tmp $Exe -Force
|
||||
Write-Ok "Installed to $Exe"
|
||||
} finally {
|
||||
if (Test-Path $tmp) { Remove-Item $tmp -Force -ErrorAction SilentlyContinue }
|
||||
}
|
||||
|
||||
# --- PATH ---------------------------------------------------------------
|
||||
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
|
||||
if ($machinePath -notlike "*$Dir*") {
|
||||
[Environment]::SetEnvironmentVariable("Path", "$machinePath;$Dir", "Machine")
|
||||
Write-Ok "Added $Dir to the system PATH"
|
||||
}
|
||||
if ($env:Path -notlike "*$Dir*") { $env:Path = "$env:Path;$Dir" }
|
||||
|
||||
Write-Host " ------------------------------------------------" -ForegroundColor DarkGray
|
||||
& $Exe version
|
||||
Write-Host ""
|
||||
|
||||
if ($InstallOnly) {
|
||||
Write-Host " Run 'deployr ui' for the interface, or 'deployr --help' for commands." -ForegroundColor DarkGray
|
||||
return
|
||||
}
|
||||
|
||||
if (-not $DeployrArgs) { $DeployrArgs = @("ui") }
|
||||
|
||||
& $Exe @DeployrArgs
|
||||
exit $LASTEXITCODE
|
||||
Reference in new issue
Block a user