#!/bin/sh # Installs the crakit CLI on Linux or macOS and verifies its SHA-256 checksum. # curl -fsSL https://crakit.tewodros.me/install.sh | sh # Environment: CRAKIT_INSTALL_DIR (default ~/.local/bin), CRAKIT_VERSION (default latest). set -eu base="${CRAKIT_BASE_URL:-https://crakit.tewodros.me}" dir="${CRAKIT_INSTALL_DIR:-$HOME/.local/bin}" fail() { echo "crakit install: $*" >&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 "$(uname -s)" in Linux) os=linux ;; Darwin) os=darwin ;; *) fail "unsupported OS $(uname -s); download a release from $base/cli" ;; esac case "$(uname -m)" in x86_64 | amd64) arch=amd64 ;; aarch64 | arm64) arch=arm64 ;; *) fail "unsupported architecture $(uname -m)" ;; esac version="${CRAKIT_VERSION:-$(curl -fsSL "$base/dl-latest")}" case "$version" in [0-9]*.[0-9]*.[0-9]*) ;; *) fail "could not determine the latest version" ;; esac file="crakit_${version}_${os}_${arch}.tar.gz" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT INT TERM echo "Downloading crakit $version for $os/$arch" curl -fsSL -o "$tmp/$file" "$base/download/$version/$file" curl -fsSL -o "$tmp/SHA256SUMS" "$base/download/$version/SHA256SUMS" expected="$(grep " $file\$" "$tmp/SHA256SUMS" | cut -d' ' -f1)" [ -n "$expected" ] || fail "no checksum for $file" if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "$tmp/$file" | cut -d' ' -f1)" else actual="$(shasum -a 256 "$tmp/$file" | cut -d' ' -f1)" fi [ "$expected" = "$actual" ] || fail "checksum mismatch for $file" tar -xzf "$tmp/$file" -C "$tmp" crakit mkdir -p "$dir" mv "$tmp/crakit" "$dir/crakit" chmod 755 "$dir/crakit" echo "Installed $("$dir/crakit" --version) to $dir/crakit" case ":$PATH:" in *":$dir:"*) ;; *) echo "Add $dir to your PATH to run crakit from anywhere." ;; esac echo "This is a checklist and drafting aid, not legal advice and not a guarantee of compliance with Regulation (EU) 2024/2847."