#!/bin/sh # Installs ot on Linux and macOS. # # curl -fsSL https://otinstaller.com/install.sh | sh # # Environment: # OT_VERSION version to install, without a leading v (default: latest) # OT_INSTALL_DIR where to put the binary (default: ~/.local/bin) set -eu BASE="${OT_INSTALL_BASE_URL:-https://otinstaller.com/releases}" DIR="${OT_INSTALL_DIR:-$HOME/.local/bin}" VERSION="${OT_VERSION:-latest}" fail() { echo "install.sh: $*" >&2 exit 1 } command -v curl >/dev/null 2>&1 || fail "curl is required" command -v tar >/dev/null 2>&1 || fail "tar is required" case "${OT_OS:-$(uname -s)}" in Linux | linux) os=linux ;; Darwin | darwin) os=darwin ;; *) fail "unsupported system $(uname -s). On Windows use install.ps1." ;; esac case "${OT_ARCH:-$(uname -m)}" in x86_64 | amd64) arch=amd64 ;; arm64 | aarch64) arch=arm64 ;; *) fail "unsupported CPU $(uname -m)" ;; esac if [ "$VERSION" = latest ]; then VERSION=$(curl -fsSL "$BASE/latest.txt") || fail "could not reach $BASE/latest.txt" VERSION=$(printf '%s' "$VERSION" | tr -d '[:space:]') case "$VERSION" in "" | *[!0-9A-Za-z.-]*) fail "$BASE/latest.txt does not hold a version" ;; esac fi archive="ot_${VERSION}_${os}_${arch}.tar.gz" url="$BASE/v$VERSION" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "Downloading ot $VERSION for $os/$arch" curl -fsSL -o "$tmp/$archive" "$url/$archive" || fail "download failed: $url/$archive" curl -fsSL -o "$tmp/checksums.txt" "$url/checksums.txt" || fail "download failed: $url/checksums.txt" want=$(awk -v f="$archive" '$2 == f { print $1 }' "$tmp/checksums.txt") [ -n "$want" ] || fail "checksums.txt has no entry for $archive" if command -v sha256sum >/dev/null 2>&1; then got=$(sha256sum "$tmp/$archive" | awk '{ print $1 }') elif command -v shasum >/dev/null 2>&1; then got=$(shasum -a 256 "$tmp/$archive" | awk '{ print $1 }') else fail "need sha256sum or shasum to verify the download" fi [ "$got" = "$want" ] || fail "checksum mismatch for $archive: expected $want, got $got" tar -xzf "$tmp/$archive" -C "$tmp" ot mkdir -p "$DIR" mv "$tmp/ot" "$DIR/ot" chmod 755 "$DIR/ot" echo "Installed $DIR/ot" case ":$PATH:" in *":$DIR:"*) ;; *) echo "Add $DIR to your PATH to run it as 'ot'." ;; esac echo "Next: ot list" echo "Note: ot mcp reports anonymous usage counts, never targets. 'ot telemetry off' stops it: https://otinstaller.com/privacy/"