#!/usr/bin/env sh set -e # --------------------------------------------------------------------------- # Ankos CLI installer # # Usage: # curl -fsSL https://get.ankos.dev | sh # # Detects OS and architecture, downloads the latest binary from # releases.ankos.dev, and installs it to /usr/local/bin. # --------------------------------------------------------------------------- RELEASES_URL="https://releases.ankos.dev/cli/latest" INSTALL_DIR="/usr/local/bin" BINARY="ankos" main() { os="$(detect_os)" arch="$(detect_arch)" if [ -z "$os" ] || [ -z "$arch" ]; then echo "Error: Unsupported platform: $(uname -s)/$(uname -m)" >&2 exit 1 fi filename="${BINARY}-${os}-${arch}" url="${RELEASES_URL}/${filename}" echo "Installing Ankos CLI..." echo " Platform: ${os}/${arch}" echo " URL: ${url}" echo "" tmpdir="$(mktemp -d)" trap 'rm -rf "$tmpdir"' EXIT # Download if command -v curl >/dev/null 2>&1; then curl -fsSL "$url" -o "$tmpdir/$BINARY" elif command -v wget >/dev/null 2>&1; then wget -qO "$tmpdir/$BINARY" "$url" else echo "Error: curl or wget is required" >&2 exit 1 fi chmod +x "$tmpdir/$BINARY" # Install if [ -w "$INSTALL_DIR" ]; then mv "$tmpdir/$BINARY" "$INSTALL_DIR/$BINARY" else echo " Installing to $INSTALL_DIR (requires sudo)..." sudo mv "$tmpdir/$BINARY" "$INSTALL_DIR/$BINARY" fi echo "" echo "Ankos CLI installed to $INSTALL_DIR/$BINARY" "$INSTALL_DIR/$BINARY" version echo "" echo "Run 'hash -r' or open a new terminal, then get started:" echo " ankos auth set-key --key " echo " ankos scan --help" } detect_os() { case "$(uname -s)" in Linux*) echo "linux" ;; Darwin*) echo "darwin" ;; *) echo "" ;; esac } detect_arch() { case "$(uname -m)" in x86_64|amd64) echo "amd64" ;; arm64|aarch64) echo "arm64" ;; *) echo "" ;; esac } main