#!/bin/bash set -euo pipefail # install.sh — Install the S7 CLI and optionally run striker install # Usage: # Install CLI only: curl -sL https://get.strike7.ai | bash # Install + striker: curl -sL https://get.strike7.ai | bash -s -- --token S3_BUCKET="s7-cli-releases" S3_REGION="us-east-1" INSTALL_DIR="/usr/local/bin" BINARY="s7" main() { local os arch url tmp="" token="" trap '[ -n "$tmp" ] && rm -rf "$tmp"' EXIT # Parse --token flag while [[ $# -gt 0 ]]; do case "$1" in --token) token="$2"; shift 2 ;; *) shift ;; esac done os=$(uname -s | tr '[:upper:]' '[:lower:]') arch=$(uname -m) case "$arch" in x86_64|amd64) arch="amd64" ;; aarch64|arm64) arch="arm64" ;; *) echo "Unsupported architecture: $arch" >&2; exit 1 ;; esac case "$os" in linux|darwin) ;; *) echo "Unsupported OS: $os" >&2; exit 1 ;; esac echo "==> Detecting platform: ${os}/${arch}" # Check if s7 is already installed and skip download if command -v s7 &>/dev/null; then echo "==> S7 CLI already installed: $(which s7)" else url="https://${S3_BUCKET}.s3.${S3_REGION}.amazonaws.com/latest/s7_${os}_${arch}" tmp=$(mktemp -d) echo "==> Downloading S7 CLI..." curl -sL "$url" -o "${tmp}/${BINARY}" chmod +x "${tmp}/${BINARY}" echo "==> Installing to ${INSTALL_DIR}/${BINARY}..." if [ -w "$INSTALL_DIR" ]; then mv "${tmp}/${BINARY}" "${INSTALL_DIR}/${BINARY}" else sudo mv "${tmp}/${BINARY}" "${INSTALL_DIR}/${BINARY}" fi echo "==> S7 CLI installed successfully!" fi # If token provided, run striker install if [ -n "$token" ]; then echo "" echo "==> Installing Striker..." s7 striker install --token "$token" else echo "" echo "Run 's7 --help' to get started." fi } main "$@"