#!/bin/sh # Copyright © 2026 Akyros Labs LLC. All rights reserved. # SPDX-License-Identifier: BUSL-1.1 # # PromptGate installer for Linux and macOS: # # curl -fsSL https://install.promptgate.dev/install.sh | sh # # Environment: # PROMPTGATE_VERSION tag to install, e.g. v0.1.0 (default: latest) # PROMPTGATE_INSTALL_DIR target directory (default: /usr/local/bin if # writable, else ~/.local/bin) # PROMPTGATE_BASE_URL download root (default: https://install.promptgate.dev) set -eu BASE_URL="${PROMPTGATE_BASE_URL:-https://install.promptgate.dev}" VERSION="${PROMPTGATE_VERSION:-latest}" say() { printf '%s\n' "$*"; } fail() { printf 'promptgate install: %s\n' "$*" >&2; exit 1; } detect_platform() { case "$(uname -s)" in Linux) os=linux ;; Darwin) os=darwin ;; *) fail "unsupported OS $(uname -s) — on Windows use install.ps1" ;; esac case "$(uname -m)" in x86_64 | amd64) arch=amd64 ;; aarch64 | arm64) arch=arm64 ;; *) fail "unsupported architecture $(uname -m)" ;; esac } download() { # url file if command -v curl >/dev/null 2>&1; then curl -fsSL --retry 3 -o "$2" "$1" elif command -v wget >/dev/null 2>&1; then wget -q -O "$2" "$1" else fail "need curl or wget" fi } sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1 elif command -v shasum >/dev/null 2>&1; then shasum -a 256 "$1" | cut -d' ' -f1 else fail "need sha256sum or shasum to verify the download" fi } choose_dir() { if [ -n "${PROMPTGATE_INSTALL_DIR:-}" ]; then dir="$PROMPTGATE_INSTALL_DIR" elif [ -w /usr/local/bin ]; then dir=/usr/local/bin else dir="$HOME/.local/bin" fi mkdir -p "$dir" } main() { detect_platform name="promptgate-$os-$arch" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT INT TERM say "Downloading PromptGate ($VERSION, $os/$arch)…" download "$BASE_URL/$VERSION/$name" "$tmp/promptgate" download "$BASE_URL/$VERSION/checksums.txt" "$tmp/checksums.txt" want="$(awk -v n="$name" '$2 == n { print $1 }' "$tmp/checksums.txt")" [ -n "$want" ] || fail "$name is not listed in checksums.txt" got="$(sha256_of "$tmp/promptgate")" [ "$want" = "$got" ] || fail "checksum mismatch for $name — refusing to install" choose_dir chmod 755 "$tmp/promptgate" mv "$tmp/promptgate" "$dir/promptgate" say "Installed $("$dir/promptgate" version) to $dir/promptgate" case ":$PATH:" in *":$dir:"*) ;; *) say "Note: $dir is not on your PATH — add: export PATH=\"$dir:\$PATH\"" ;; esac say "" say "Next steps:" say " promptgate setup # writes a config, creates your first pg_ key" say " promptgate start" } main "$@"