#!/usr/bin/env bash set -euo pipefail TARGET="${1:-all}" WHEEL_URL="https://tokenrobinhood.lat/downloads/token_robin_hood-0.1.4-py3-none-any.whl" WHEEL_SHA256="4908452a0e7023a6e6bc17f76defa012dae07f04dfc1c4f6ec251de7aba21a2e" PYTHON_BIN="${PYTHON_BIN:-}" TRH_HOME="${HOME}/.token-robin-hood" TRH_VENV="${TRH_HOME}/venv" TRH_BIN="${HOME}/.local/bin" WHEEL_FILE="${TRH_HOME}/token_robin_hood-0.1.4-py3-none-any.whl" INSTALL_LOG="${TRH_HOME}/install.log" GREEN='' GREEN_DIM='' WHITE='' RED='' RESET='' panel() { printf ' %b ' "${GREEN_DIM}┌──────────────────────────────────────────────────────────────┐${RESET}" printf ' %b %b ' "${WHITE}TOKEN ROBIN HOOD${RESET}" "${GREEN}>----->${RESET}" printf ' %b %b ' "${GREEN}\$${RESET}" "${WHITE}bootstrap${RESET}" } step() { printf ' %b %s ' "${GREEN}→${RESET}" "$1" } fail() { printf ' %b %s ' "${RED}×${RESET}" "$1" if [ -f "$INSTALL_LOG" ]; then printf ' %b %s%b ' "${GREEN_DIM}" "$INSTALL_LOG" "${RESET}" tail -n 40 "$INSTALL_LOG" fi exit 1 } if [ -z "$PYTHON_BIN" ]; then for candidate in python3.14 python3.13 python3.12 python3.11 python3; do if command -v "$candidate" >/dev/null 2>&1; then if "$candidate" - <<'PY' >/dev/null 2>&1 import sys raise SystemExit(0 if sys.version_info >= (3, 11) else 1) PY then PYTHON_BIN="$candidate" break fi fi done fi if [ -z "$PYTHON_BIN" ]; then echo "python 3.11+ not found" exit 1 fi panel step "stringing the bow // private runtime" mkdir -p "$TRH_HOME" "$TRH_BIN" if [ ! -x "$TRH_VENV/bin/python" ]; then "$PYTHON_BIN" -m venv "$TRH_VENV" fi export PIP_DISABLE_PIP_VERSION_CHECK=1 step "fletching the arrow // syncing package" if ! "$TRH_VENV/bin/python" -m pip install --upgrade pip 2>&1 | tee "$INSTALL_LOG"; then fail "pip bootstrap failed" fi if ! "$TRH_VENV/bin/python" - "$WHEEL_URL" "$WHEEL_FILE" "$WHEEL_SHA256" <<'PY' 2>&1 | tee -a "$INSTALL_LOG"; then import hashlib import sys from urllib.request import urlopen url, path, expected = sys.argv[1:] with urlopen(url, timeout=30) as response: payload = response.read() actual = hashlib.sha256(payload).hexdigest() if actual != expected: raise SystemExit(f"wheel hash mismatch: expected {expected}, got {actual}") with open(path, "wb") as fh: fh.write(payload) PY fail "package verification failed" fi if ! "$TRH_VENV/bin/python" -m pip install --upgrade "$WHEEL_FILE" 2>&1 | tee -a "$INSTALL_LOG"; then fail "package install failed" fi cat > "$TRH_BIN/trh" <<'SH' #!/usr/bin/env bash exec "$HOME/.token-robin-hood/venv/bin/trh" "$@" SH cat > "$TRH_BIN/token-robin-hood" <<'SH' #!/usr/bin/env bash exec "$HOME/.token-robin-hood/venv/bin/token-robin-hood" "$@" SH chmod +x "$TRH_BIN/trh" "$TRH_BIN/token-robin-hood" export PATH="$TRH_BIN:$PATH" rm -f "$INSTALL_LOG" step "linking commands" step "taking aim // arming $TARGET" if [ -n "${TRH_LICENSE_KEY:-}" ]; then trh connect "$TARGET" --license-key "$TRH_LICENSE_KEY" else trh connect "$TARGET" fi if [[ ":$PATH:" != *":$TRH_BIN:"* ]]; then echo echo 'add this to your shell profile: export PATH="$HOME/.local/bin:$PATH"' fi