AkurAI Build
Menu

Public repository / master

AkurAI-Framework / site/frontend/install.sh

Latest change 7e33e091765c7b6d039675b283b4f6d6396ffe57 - integrate: align install.sh asset naming with akurai update; changelog + updating docs nav by Ólafur Búi Ólafsson

#!/bin/sh
# AkurAI-Framework installer — POSIX sh, rustup/claude/codex style.
#
# Usage:  curl -fsSL https://akurai-framework.olibuijr.com/install.sh | sh
#
# REQUIRES A PUBLISHED GITHUB RELEASE. This script downloads the `akurai`
# binary from the `latest` GitHub release of olibuijr/AkurAI-Framework. The
# repository is currently PRIVATE, so the public installer is not yet live:
# activating it requires (1) making the repo public and (2) cutting a release
# whose assets are named per the `asset` mapping below. Until then the download
# step will 404 and this script will fail loudly — by design. It never fakes
# success.

set -eu

REPO="olibuijr/AkurAI-Framework"
BIN="akurai"
INSTALL_DIR="${AKURAI_INSTALL_DIR:-$HOME/.local/bin}"

err() {
  printf 'akurai-install: %s\n' "$1" >&2
  exit 1
}

# Detect OS + architecture and map to the release asset name. Asset names are
# `akurai-<os>-<arch>` with <os> in {linux,macos} and <arch> in {x86_64,aarch64}
# — the SAME convention as `akurai update`'s asset_name() (crates/cli/cmd_update.rs),
# so the installer and the CLI self-updater always resolve the same asset.
detect_asset() {
  os="$(uname -s)"
  arch="$(uname -m)"

  case "$arch" in
    x86_64 | amd64) arch="x86_64" ;;
    aarch64 | arm64) arch="aarch64" ;;
    *) err "unsupported architecture: $arch" ;;
  esac

  case "$os" in
    Linux) os="linux" ;;
    Darwin) os="macos" ;;
    *) err "unsupported OS: $os (Linux and macOS only)" ;;
  esac

  printf '%s-%s-%s' "$BIN" "$os" "$arch"
}

# Pick a downloader.
http_get() {
  url="$1"
  out="$2"
  if command -v curl >/dev/null 2>&1; then
    curl -fsSL "$url" -o "$out"
  elif command -v wget >/dev/null 2>&1; then
    wget -qO "$out" "$url"
  else
    err "need curl or wget to download the binary"
  fi
}

main() {
  asset="$(detect_asset)"
  url="https://github.com/${REPO}/releases/latest/download/${asset}"

  printf 'Installing %s from %s\n' "$BIN" "$url"

  tmp="$(mktemp)"
  trap 'rm -f "$tmp"' EXIT INT TERM

  if ! http_get "$url" "$tmp"; then
    err "download failed: $url
  (no published release yet, or the asset '$asset' does not exist —
   see the note at the top of this script)"
  fi

  # A GitHub 404 page is HTML, not a binary. Guard against silently installing it.
  if [ ! -s "$tmp" ]; then
    err "downloaded an empty file from $url"
  fi
  if head -c 16 "$tmp" | grep -qi '<!doctype\|<html'; then
    err "expected a binary but got an HTML page from $url
  (release asset '$asset' is probably missing)"
  fi

  mkdir -p "$INSTALL_DIR"
  install -m 0755 "$tmp" "$INSTALL_DIR/$BIN" 2>/dev/null || {
    cp "$tmp" "$INSTALL_DIR/$BIN"
    chmod +x "$INSTALL_DIR/$BIN"
  }

  printf '\nInstalled %s to %s/%s\n' "$BIN" "$INSTALL_DIR" "$BIN"

  case ":$PATH:" in
    *":$INSTALL_DIR:"*) ;;
    *) printf 'Note: add %s to your PATH:\n  export PATH="%s:$PATH"\n' "$INSTALL_DIR" "$INSTALL_DIR" ;;
  esac

  printf '\nNext step:\n  %s new myapp && cd myapp && %s dev\n' "$BIN" "$BIN"
}

main "$@"