#!/usr/bin/env bash # # OpenEng Git Engine - one-line installer (Linux & macOS; Windows via PowerShell / WSL). # # Downloads a prebuilt `openeng-git` engine binary from openeng.app and installs it. # This is the LOCAL engine that git.openeng.app drives over a sealed, end-to-end-encrypted channel. It runs all # git operations on your machine (your repositories, your git config, your credential # helper); its only cloud call is authenticating you. No source code, no Rust toolchain # - just the binary. The engine keeps itself up to date automatically after install. # # curl -fsSL https://openeng.app/engine/git/install.sh | bash # # Tunables (environment): # OPENENG_GIT_URL base URL for binaries (default: https://openeng.app/engine/git/bin) # OPENENG_BIN_DIR install directory (default: ~/.local/bin) # # NOTE: keep this script pure ASCII (macOS bash 3.2 + set -u). # set -eu if [ -t 1 ]; then esc=$(printf '\033') BLUE="${esc}[36m"; GRN="${esc}[32m"; RED="${esc}[31m"; DIM="${esc}[2m"; NC="${esc}[0m" else BLUE=''; GRN=''; RED=''; DIM=''; NC='' fi say() { printf "${BLUE}==>${NC} %s\n" "$1"; } ok() { printf "${GRN}ok:${NC} %s\n" "$1"; } warn() { printf "${RED}!${NC} %s\n" "$1" >&2; } die() { printf "${RED}error: %s${NC}\n" "$1" >&2; exit 1; } have() { command -v "$1" >/dev/null 2>&1; } OPENENG_GIT_URL="${OPENENG_GIT_URL:-https://openeng.app/engine/git/bin}" OPENENG_BIN_DIR="${OPENENG_BIN_DIR:-$HOME/.local/bin}" printf "${BLUE}+--- OpenEng Git Engine installer -------------+${NC}\n" # -- detect platform --------------------------------------------------------- os="$(uname -s 2>/dev/null || echo unknown)" arch="$(uname -m 2>/dev/null || echo unknown)" case "$os" in Linux) OS=linux ;; Darwin) OS=darwin ;; MINGW*|MSYS*|CYGWIN*) die "Windows shell detected. Use PowerShell (irm https://openeng.app/engine/git/install.ps1 | iex) or WSL." ;; *) die "unsupported OS '${os}'." ;; esac case "$arch" in x86_64|amd64) ARCH=x86_64 ;; arm64|aarch64) ARCH=aarch64 ;; *) die "unsupported architecture '${arch}'." ;; esac ASSET="openeng-git-${OS}-${ARCH}" URL="${OPENENG_GIT_URL}/${ASSET}" # -- prerequisites ----------------------------------------------------------- have curl || die "curl is required." # -- download ---------------------------------------------------------------- say "Downloading openeng-git (${OS}/${ARCH}) ..." TMP="$(mktemp 2>/dev/null || echo "${TMPDIR:-/tmp}/openeng-git.$$")" curl -fSL --proto '=https' --tlsv1.2 "$URL" -o "$TMP" \ || die "could not download ${URL} -- no git engine binary published for ${OS}/${ARCH} yet." # A static host may answer a missing file with its SPA/HTML page (HTTP 200). Real # binaries never start with '<', so reject an HTML page up front. if [ "$(head -c 1 "$TMP" 2>/dev/null)" = "<" ]; then rm -f "$TMP" die "no git engine binary published for ${OS}/${ARCH} yet (the URL returned a web page)." fi # -- verify checksum (enforced only if a real .sha256 is published) ---------- if curl -fsSL "${URL}.sha256" -o "${TMP}.sha256" 2>/dev/null; then WANT="$(cut -d' ' -f1 < "${TMP}.sha256" 2>/dev/null || echo)" rm -f "${TMP}.sha256" if printf '%s' "$WANT" | grep -Eq '^[0-9a-fA-F]{64}$'; then if have sha256sum; then GOT="$(sha256sum "$TMP" | cut -d' ' -f1)" elif have shasum; then GOT="$(shasum -a 256 "$TMP" | cut -d' ' -f1)" else GOT=""; fi if [ -n "$GOT" ] && [ "$GOT" != "$WANT" ]; then rm -f "$TMP"; die "checksum mismatch for ${ASSET} (got ${GOT}, want ${WANT})." fi [ -n "$GOT" ] && ok "checksum verified" fi fi chmod 0755 "$TMP" if [ "$OS" = "darwin" ]; then xattr -d com.apple.quarantine "$TMP" >/dev/null 2>&1 || true; fi # Sanity: the engine binary runs (it prints usage on --help). On Linux it links GTK 3 (the native # folder picker), which minimal and headless systems may lack -- name what is missing if so. if ! "$TMP" --help >/dev/null 2>&1; then MISSING="" if [ "$OS" = "linux" ] && have ldd; then MISSING="$(ldd "$TMP" 2>/dev/null | awk '/not found/ {print $1}' | tr '\n' ' ')" fi rm -f "$TMP" case "$MISSING" in *libgtk-3*|*libgdk-3*) die "the engine needs GTK 3, which is not installed (missing: ${MISSING% }). Install it, then re-run this installer: Debian/Ubuntu: sudo apt-get install -y libgtk-3-0 Fedora/RHEL: sudo dnf install -y gtk3 Arch: sudo pacman -S gtk3" ;; ?*) die "the engine needs system libraries that are not installed: ${MISSING% }. Install them, then re-run this installer." ;; *) die "the downloaded engine did not run (wrong platform or corrupt download)." ;; esac fi # -- install on PATH --------------------------------------------------------- mkdir -p "$OPENENG_BIN_DIR" mv -f "$TMP" "$OPENENG_BIN_DIR/openeng-git" chmod 0755 "$OPENENG_BIN_DIR/openeng-git" # The beta engine is UNSIGNED (ad-hoc on macOS). Strip the quarantine attribute from the installed # binary so macOS Gatekeeper runs it with no "unidentified developer" prompt (curl sets no quarantine, # but a proxy/AV might -- do it defensively so the user never has a permission problem). if [ "$OS" = "darwin" ]; then xattr -dr com.apple.quarantine "$OPENENG_BIN_DIR/openeng-git" >/dev/null 2>&1 || true; fi ok "installed ${OPENENG_BIN_DIR}/openeng-git" case ":$PATH:" in *":$OPENENG_BIN_DIR:"*) ;; *) LINE="export PATH=\"$OPENENG_BIN_DIR:\$PATH\"" ADDED=""; PRESENT="" for rc in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do [ -f "$rc" ] || continue if grep -qF "$OPENENG_BIN_DIR" "$rc" 2>/dev/null; then PRESENT="$rc" else printf '\n# OpenEng Git Engine\n%s\n' "$LINE" >> "$rc" ADDED="${ADDED}${ADDED:+, }${rc}" fi done if [ -n "$ADDED" ]; then warn "Added ${OPENENG_BIN_DIR} to your PATH in ${ADDED} - run \`${LINE}\` or open a new terminal." elif [ -n "$PRESENT" ]; then warn "${OPENENG_BIN_DIR} is already in ${PRESENT} - open a new terminal (or run \`${LINE}\`)." else warn "${OPENENG_BIN_DIR} is not on your PATH and no shell rc file was found - add this line to your shell profile: ${LINE}" fi ;; esac mkdir -p "$HOME/.openeng" ok "agent root at ${HOME}/.openeng" # The engine shells out to git for push, pull, fetch, merge and stash. if ! have git; then case "$OS" in darwin) warn "git is not installed - the engine needs it for push, pull and fetch. Install it: xcode-select --install" ;; *) warn "git is not installed - the engine needs it for push, pull and fetch. Debian/Ubuntu: sudo apt-get install -y git Fedora/RHEL: sudo dnf install -y git" ;; esac fi printf "\n" ok "Done. Start it: ${BLUE}openeng-git serve --oauth=${NC} ${DIM}(copy the one-time key from git.openeng.app)${NC}"