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
|
||||
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env sh
|
||||
# Deployr bootstrap for macOS and Linux.
|
||||
#
|
||||
# curl -fsSL https://git.starwarslab.us/ATOM_IT/Deployr/raw/branch/main/scripts/install.sh | sh
|
||||
#
|
||||
# With no arguments it installs deployr and opens the UI. To pass arguments
|
||||
# through, use `sh -s --`:
|
||||
#
|
||||
# curl -fsSL <url> | sh -s -- install @standard
|
||||
#
|
||||
# Environment:
|
||||
# DEPLOYR_VERSION release tag to install (default: latest)
|
||||
# DEPLOYR_PREFIX install directory (default: /usr/local/bin)
|
||||
# DEPLOYR_INSTALL_ONLY=1 install without running anything
|
||||
set -eu
|
||||
|
||||
REPO="https://git.starwarslab.us/ATOM_IT/Deployr"
|
||||
VERSION="${DEPLOYR_VERSION:-latest}"
|
||||
PREFIX="${DEPLOYR_PREFIX:-/usr/local/bin}"
|
||||
BIN="$PREFIX/deployr"
|
||||
|
||||
say() { printf ' %s\n' "$*"; }
|
||||
die() { printf ' error: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
# Only escalate when we actually need to write to the prefix, so a user-local
|
||||
# install never prompts for a password it does not need.
|
||||
SUDO=""
|
||||
if [ ! -w "$(dirname "$BIN")" ] 2>/dev/null || [ ! -d "$PREFIX" ]; then
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
command -v sudo >/dev/null 2>&1 || die "need root to write $PREFIX (set DEPLOYR_PREFIX to a writable directory)"
|
||||
SUDO="sudo"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '\n Deployr bootstrap\n ------------------------------------------------\n'
|
||||
|
||||
case "$(uname -s)" in
|
||||
Darwin) OS="darwin" ;;
|
||||
Linux) OS="linux" ;;
|
||||
*) die "unsupported operating system: $(uname -s)" ;;
|
||||
esac
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64|amd64) ARCH="amd64" ;;
|
||||
arm64|aarch64) ARCH="arm64" ;;
|
||||
*) die "unsupported architecture: $(uname -m)" ;;
|
||||
esac
|
||||
|
||||
ASSET="deployr_${OS}_${ARCH}"
|
||||
say "Platform: $OS/$ARCH"
|
||||
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
fetch() {
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fsSL --retry 3 --connect-timeout 20 -o "$2" "$1"
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q -O "$2" "$1"
|
||||
else
|
||||
die "neither curl nor wget is available"
|
||||
fi
|
||||
}
|
||||
|
||||
# "latest" is not a real download path in Gitea: resolve the release through the
|
||||
# API and use the asset URLs it publishes.
|
||||
API="$(printf '%s' "$REPO" | sed -E 's#/([^/]+)/([^/]+)$#/api/v1/repos/\1/\2#')"
|
||||
if [ "$VERSION" = "latest" ]; then
|
||||
RELEASE_URL="$API/releases/latest"
|
||||
else
|
||||
RELEASE_URL="$API/releases/tags/$VERSION"
|
||||
fi
|
||||
|
||||
say "Resolving release ($VERSION) ..."
|
||||
fetch "$RELEASE_URL" "$TMP/release.json" || die "could not reach $RELEASE_URL"
|
||||
|
||||
# Pull one asset's download URL out of the release JSON without needing jq.
|
||||
asset_url() {
|
||||
tr ',' '\n' < "$TMP/release.json" \
|
||||
| grep -F "browser_download_url" \
|
||||
| sed -E 's/.*"browser_download_url" *: *"([^"]+)".*/\1/' \
|
||||
| grep -E "/$1\$" \
|
||||
| head -n 1
|
||||
}
|
||||
|
||||
ASSET_URL="$(asset_url "$ASSET")"
|
||||
SUMS_URL="$(asset_url 'SHA256SUMS')"
|
||||
[ -n "$ASSET_URL" ] || die "this release has no asset named $ASSET"
|
||||
|
||||
say "Downloading $ASSET ..."
|
||||
fetch "$ASSET_URL" "$TMP/deployr" || die "download failed"
|
||||
|
||||
# Verify against the release checksums when they are reachable.
|
||||
if [ -n "$SUMS_URL" ] && fetch "$SUMS_URL" "$TMP/SHA256SUMS" 2>/dev/null; then
|
||||
EXPECTED="$(awk -v a="$ASSET" '{ n=$NF; sub(/^[*.\/]+/,"",n); if (n==a) print $1 }' "$TMP/SHA256SUMS")"
|
||||
if [ -n "$EXPECTED" ]; then
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
ACTUAL="$(sha256sum "$TMP/deployr" | cut -d' ' -f1)"
|
||||
else
|
||||
ACTUAL="$(shasum -a 256 "$TMP/deployr" | cut -d' ' -f1)"
|
||||
fi
|
||||
[ "$ACTUAL" = "$EXPECTED" ] || die "checksum mismatch: expected $EXPECTED, got $ACTUAL"
|
||||
say "Checksum verified"
|
||||
fi
|
||||
else
|
||||
say "warning: could not fetch SHA256SUMS, skipping verification"
|
||||
fi
|
||||
|
||||
chmod 0755 "$TMP/deployr"
|
||||
$SUDO mkdir -p "$PREFIX"
|
||||
$SUDO install -m 0755 "$TMP/deployr" "$BIN"
|
||||
say "Installed to $BIN"
|
||||
|
||||
# macOS quarantines anything downloaded by a browser-facing tool; strip it so
|
||||
# Gatekeeper does not block the binary on first run.
|
||||
if [ "$OS" = "darwin" ] && command -v xattr >/dev/null 2>&1; then
|
||||
$SUDO xattr -d com.apple.quarantine "$BIN" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
printf ' ------------------------------------------------\n'
|
||||
"$BIN" version
|
||||
printf '\n'
|
||||
|
||||
[ "${DEPLOYR_INSTALL_ONLY:-}" = "1" ] && exit 0
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
exec $SUDO "$BIN" "$@"
|
||||
fi
|
||||
|
||||
# The UI needs root to install anything, but it must not run the browser as
|
||||
# root -- deployr opens that as the invoking user itself.
|
||||
exec $SUDO "$BIN" ui
|
||||
Reference in new issue
Block a user