#!/bin/sh # Installs the AISDLC.DEV CLI for macOS and Linux: curl -fsSL https://aisdlc.dev/install.sh | sh # Downloads the archive for this machine from aisdlc.dev/cli, checks its SHA-256 and puts `aisdlc` in ~/.local/bin # (AISDLC_INSTALL_DIR to change it). No sudo. Windows: download https://aisdlc.dev/cli/aisdlc_windows_amd64.zip. set -eu main() { base="${AISDLC_DOWNLOAD_BASE:-https://aisdlc.dev/cli}" dir="${AISDLC_INSTALL_DIR:-$HOME/.local/bin}" case "$(uname -s)" in Darwin) os=darwin ;; Linux) os=linux ;; *) fail "this installer supports macOS and Linux; on Windows download https://aisdlc.dev/cli/aisdlc_windows_amd64.zip" ;; esac case "$(uname -m)" in x86_64 | amd64) arch=amd64 ;; arm64 | aarch64) arch=arm64 ;; *) fail "no build for $(uname -m); supported: x86_64, arm64" ;; esac command -v curl >/dev/null 2>&1 || fail "curl is required" name="aisdlc_${os}_${arch}.tar.gz" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "Downloading $base/$name" curl -fsSL "$base/$name" -o "$tmp/$name" || fail "download failed: $base/$name" curl -fsSL "$base/SHA256SUMS.txt" -o "$tmp/SHA256SUMS.txt" || fail "download failed: $base/SHA256SUMS.txt" want=$(awk -v n="$name" '$2 == n { print $1 }' "$tmp/SHA256SUMS.txt") if command -v sha256sum >/dev/null 2>&1; then got=$(sha256sum "$tmp/$name" | awk '{ print $1 }') else got=$(shasum -a 256 "$tmp/$name" | awk '{ print $1 }') fi [ -n "$want" ] && [ "$want" = "$got" ] || fail "checksum mismatch for $name; nothing was installed" tar -xzf "$tmp/$name" -C "$tmp" aisdlc mkdir -p "$dir" mv "$tmp/aisdlc" "$dir/aisdlc" chmod 755 "$dir/aisdlc" echo "Installed $("$dir/aisdlc" version) to $dir/aisdlc" case ":$PATH:" in *":$dir:"*) ;; *) echo "Add it to your PATH (e.g. in ~/.zshrc or ~/.bashrc): export PATH=\"$dir:\$PATH\"" ;; esac } fail() { echo "aisdlc install: $1" >&2 exit 1 } # Runs only once the whole script has arrived, so a cut-off download does nothing main "$@"