#!/bin/sh # Installs agentcloudctl and agentcloud-mcp from GitHub releases (Linux/macOS). # Env overrides: AGENTCLOUD_VERSION (e.g. v0.1.0), AGENTCLOUD_INSTALL_DIR, AGENTCLOUD_BINARIES. set -eu REPO="omid-zaman/agentcloud" VERSION="${AGENTCLOUD_VERSION:-latest}" INSTALL_DIR="${AGENTCLOUD_INSTALL_DIR:-$HOME/.local/bin}" BINARIES="${AGENTCLOUD_BINARIES:-agentcloudctl agentcloud-mcp}" fail() { echo "agentcloud install: $*" >&2; exit 1; } os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in linux|darwin) ;; *) fail "unsupported OS '$os' (on Windows use install.ps1)" ;; esac case "$(uname -m)" in x86_64|amd64) arch=amd64 ;; aarch64|arm64) arch=arm64 ;; *) fail "unsupported architecture '$(uname -m)'" ;; esac command -v curl >/dev/null 2>&1 || fail "curl is required" if command -v sha256sum >/dev/null 2>&1; then sha="sha256sum" elif command -v shasum >/dev/null 2>&1; then sha="shasum -a 256" else fail "sha256sum or shasum is required" fi if [ "$VERSION" = latest ]; then base="https://github.com/$REPO/releases/latest/download" else base="https://github.com/$REPO/releases/download/$VERSION" fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM curl -fsSL "$base/checksums.txt" -o "$tmp/checksums.txt" || fail "could not download checksums from $base" mkdir -p "$INSTALL_DIR" for bin in $BINARIES; do asset="$bin-$os-$arch" curl -fsSL "$base/$asset" -o "$tmp/$asset" || fail "could not download $asset" expected=$(awk -v f="$asset" '$2 == f || $2 == "*"f { print $1 }' "$tmp/checksums.txt") [ -n "$expected" ] || fail "no checksum listed for $asset" actual=$(cd "$tmp" && $sha "$asset" | awk '{ print $1 }') [ "$expected" = "$actual" ] || fail "checksum mismatch for $asset" chmod 0755 "$tmp/$asset" mv "$tmp/$asset" "$INSTALL_DIR/$bin" echo "installed $INSTALL_DIR/$bin" done case ":$PATH:" in *":$INSTALL_DIR:"*) ;; *) echo "note: add $INSTALL_DIR to your PATH, e.g. export PATH=\"$INSTALL_DIR:\$PATH\"" ;; esac