#!/bin/sh # Install the Atlarix CLI: curl -fsSL https://atlarix.dev/install | sh # # Downloads this machine's build from the latest Atlarix release on GitHub, # checks its SHA-256 against the release's SHA256SUMS-cli.txt, and puts # `atlarix` in ~/.atlarix/bin. No sudo, nothing outside your home folder. # # ATLARIX_VERSION=14.53.0 install that version instead of the latest # ATLARIX_INSTALL_DIR=... install somewhere other than ~/.atlarix/bin # ATLARIX_DOWNLOAD_BASE=... download from a mirror (it serves the release's files) set -eu REPO="AmariahAK/atlarix-releases" DIR="${ATLARIX_INSTALL_DIR:-$HOME/.atlarix/bin}" say() { printf '%s\n' "$*"; } die() { printf 'atlarix install: %s\n' "$*" >&2; exit 1; } os=$(uname -s) arch=$(uname -m) case "$os" in Darwin) os=darwin ;; Linux) os=linux ;; MINGW* | MSYS* | CYGWIN*) die "on Windows, use PowerShell: irm https://atlarix.dev/install.ps1 | iex" ;; *) die "no Atlarix CLI build for $os" ;; esac case "$arch" in x86_64 | amd64) arch=x64 ;; arm64 | aarch64) arch=arm64 ;; *) die "no Atlarix CLI build for $arch" ;; esac # Rosetta: an arm64 Mac running this shell as x86_64 should still get the native build. if [ "$os" = darwin ] && [ "$arch" = x64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 1 ]; then arch=arm64 fi libc="" if [ "$os" = linux ]; then if ldd --version 2>&1 | grep -qi musl || [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /lib/ld-musl-aarch64.so.1 ]; then libc="-musl" fi fi target="$os-$arch$libc" asset="atlarix-cli-$target.tar.gz" if [ -n "${ATLARIX_DOWNLOAD_BASE:-}" ]; then base="$ATLARIX_DOWNLOAD_BASE" elif [ -n "${ATLARIX_VERSION:-}" ]; then base="https://github.com/$REPO/releases/download/v${ATLARIX_VERSION#v}" else base="https://github.com/$REPO/releases/latest/download" fi if command -v curl >/dev/null 2>&1; then fetch() { curl -fsSL "$1" -o "$2"; } elif command -v wget >/dev/null 2>&1; then fetch() { wget -qO "$2" "$1"; } else die "needs curl or wget" fi if command -v sha256sum >/dev/null 2>&1; then sha() { sha256sum "$1" | cut -d' ' -f1; } elif command -v shasum >/dev/null 2>&1; then sha() { shasum -a 256 "$1" | cut -d' ' -f1; } else die "needs sha256sum or shasum to check the download" fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM say "Downloading the Atlarix CLI ($target)…" fetch "$base/$asset" "$tmp/$asset" || die "couldn't download $base/$asset" fetch "$base/SHA256SUMS-cli.txt" "$tmp/sums" || die "couldn't download the checksums" want=$(grep " \*\{0,1\}$asset\$" "$tmp/sums" | cut -d' ' -f1) [ -n "$want" ] || die "no checksum for $asset in the release" got=$(sha "$tmp/$asset") [ "$want" = "$got" ] || die "checksum mismatch for $asset (expected $want, got $got). Nothing was installed." tar -xzf "$tmp/$asset" -C "$tmp" mkdir -p "$DIR" mv -f "$tmp/atlarix" "$DIR/atlarix" chmod 755 "$DIR/atlarix" # The musl build needs the C++ runtime, which Alpine leaves out by default. if [ "$libc" = "-musl" ] && [ ! -e /usr/lib/libstdc++.so.6 ] && [ ! -e /lib/libstdc++.so.6 ]; then say "Atlarix needs the C++ runtime on this system. Install it, then run atlarix:" say " apk add libstdc++ libgcc" fi say "Installed: $DIR/atlarix ($("$DIR/atlarix" --version 2>/dev/null || echo "version unknown"))" case ":$PATH:" in *":$DIR:"*) say "Run \`atlarix\` in any project folder to start." ;; *) say "" say "Add it to your PATH, then open a new terminal:" case "${SHELL:-}" in */fish) say " fish_add_path $DIR" ;; */zsh) say " echo 'export PATH=\"$DIR:\$PATH\"' >> ~/.zshrc" ;; *) say " echo 'export PATH=\"$DIR:\$PATH\"' >> ~/.bashrc" ;; esac ;; esac