#!/bin/sh # Installs the program `dolton` from the latest release of Dolton. # # curl -fsSL https://raw.githubusercontent.com/dolton-hq/dolton/main/install.sh | sh # # It downloads the program for this computer (macOS on Apple silicon, or Linux on Intel # or ARM), checks its SHA-256 sum against the sum of the release, and puts it in # ~/.local/bin (DOLTON_INSTALL_DIR names another folder). It needs no sudo and changes # no setting of the computer. Then: `dolton open ~/dolton/my-team`. # # DOLTON_VERSION=v0.1.0 takes that release in place of the latest one. set -eu repo=${DOLTON_REPO:-dolton-hq/dolton} dir=${DOLTON_INSTALL_DIR:-$HOME/.local/bin} version=${DOLTON_VERSION:-latest} die() { echo "install: $*" >&2; exit 1; } case "$(uname -s)" in Darwin) os=apple-darwin ;; Linux) os=unknown-linux-gnu ;; *) die "no release for $(uname -s): build it from the code (see the README)" ;; esac case "$(uname -m)" in arm64 | aarch64) arch=aarch64 ;; x86_64 | amd64) arch=x86_64 ;; *) die "no release for $(uname -m): build it from the code (see the README)" ;; esac if [ "$os" = apple-darwin ] && [ "$arch" = x86_64 ]; then die "no release for a Mac with an Intel chip: the search model of Dolton (ONNX Runtime) has no build for it" fi name="dolton-$arch-$os.tar.gz" if [ -n "${DOLTON_DOWNLOAD:-}" ]; then base=$DOLTON_DOWNLOAD elif [ "$version" = latest ]; then base="https://github.com/$repo/releases/latest/download" else base="https://github.com/$repo/releases/download/$version" fi command -v curl >/dev/null 2>&1 || die "curl is needed" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "Downloading $name" curl -fsSL "$base/$name" -o "$tmp/$name" || die "the download of $base/$name failed" curl -fsSL "$base/$name.sha256" -o "$tmp/$name.sha256" || die "the download of the sum failed" want=$(cut -d' ' -f1 < "$tmp/$name.sha256") if command -v shasum >/dev/null 2>&1; then got=$(shasum -a 256 "$tmp/$name" | cut -d' ' -f1) else got=$(sha256sum "$tmp/$name" | cut -d' ' -f1) fi [ -n "$want" ] && [ "$got" = "$want" ] || die "the sum of the download is not the sum of the release: nothing was installed" tar xzf "$tmp/$name" -C "$tmp" mkdir -p "$dir" mv "$tmp/dolton" "$dir/dolton" chmod 755 "$dir/dolton" echo "Installed: $dir/dolton" case ":$PATH:" in *":$dir:"*) echo "Next: dolton open ~/dolton/my-team" ;; *) echo "Add $dir to your PATH, or use the full path." echo "Next: $dir/dolton open ~/dolton/my-team" ;; esac