#!/bin/sh # Shebaka CLI installer — hosted at get.shebaka.com (gateway /install.sh): # # curl -fsSL https://get.shebaka.com | sh # # Overrides: SHEBAKA_INSTALL_BASE (artifact origin, for testing/mirrors), # SHEBAKA_BIN_DIR (install target; default /usr/local/bin when writable, # else ~/.local/bin). POSIX sh — no bashisms. set -eu BASE="${SHEBAKA_INSTALL_BASE:-https://get.shebaka.com}" os="$(uname -s | tr '[:upper:]' '[:lower:]')" case "$os" in darwin|linux) ;; *) echo "unsupported OS: $os (darwin and linux builds are published)" >&2; exit 1 ;; esac arch="$(uname -m)" case "$arch" in x86_64|amd64) arch=amd64 ;; arm64|aarch64) arch=arm64 ;; *) echo "unsupported architecture: $arch (amd64 and arm64 builds are published)" >&2; exit 1 ;; esac artifact="shebaka-$os-$arch" dest="${SHEBAKA_BIN_DIR:-}" if [ -z "$dest" ]; then if [ -w /usr/local/bin ]; then dest=/usr/local/bin; else dest="$HOME/.local/bin"; fi fi mkdir -p "$dest" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT echo "downloading $BASE/dist/$artifact" curl -fsSL -o "$tmp/shebaka" "$BASE/dist/$artifact" # Verify against the published checksums when a tool is available — refuse on # mismatch, proceed with a note when SHA256SUMS is not published. if curl -fsSL -o "$tmp/SHA256SUMS" "$BASE/dist/SHA256SUMS" 2>/dev/null; then want="$(grep " $artifact\$" "$tmp/SHA256SUMS" | cut -d' ' -f1)" if command -v sha256sum >/dev/null 2>&1; then got="$(sha256sum "$tmp/shebaka" | cut -d' ' -f1)" elif command -v shasum >/dev/null 2>&1; then got="$(shasum -a 256 "$tmp/shebaka" | cut -d' ' -f1)" else got="" fi if [ -n "$got" ] && [ -n "$want" ] && [ "$got" != "$want" ]; then echo "checksum mismatch for $artifact — refusing to install" >&2 exit 1 fi else echo "note: no SHA256SUMS published at $BASE — skipping checksum verification" fi chmod +x "$tmp/shebaka" mv "$tmp/shebaka" "$dest/shebaka" echo "installed: $dest/shebaka" "$dest/shebaka" version || true case ":$PATH:" in *":$dest:"*) ;; *) echo "note: $dest is not on your PATH — add: export PATH=\"$dest:\$PATH\"" ;; esac echo "next: shebaka login --gateway https://console.shebaka.com --key "