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,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