#!/bin/sh # HolaDB installer. curl -fsSL https://holadb.com/install.sh | sh # # Downloads the HolaDB developer beta for this computer, checks its SHA-256, # and unpacks it into ~/.holadb. It does not use sudo and changes nothing # outside ~/.holadb. To remove HolaDB: rm -rf ~/.holadb set -eu VERSION="${HOLADB_VERSION:-0.1.0-beta.1}" BASE="${HOLADB_BASE:-https://holadb.com}" DEST="${HOLADB_HOME:-$HOME/.holadb}" say() { printf '%s\n' "$*"; } fail() { printf 'holadb install: %s\n' "$*" >&2; exit 1; } os=$(uname -s); arch=$(uname -m) case "$os/$arch" in Darwin/arm64) target="aarch64-apple-darwin" ;; Darwin/x86_64) target="x86_64-apple-darwin" ;; Linux/x86_64) target="x86_64-unknown-linux-gnu" ;; Linux/aarch64|Linux/arm64) target="aarch64-unknown-linux-gnu" ;; *) fail "HolaDB has no build for $os on $arch. On Windows, use WSL (Linux). See $BASE/install/" ;; esac command -v curl >/dev/null 2>&1 || fail "curl is needed" command -v tar >/dev/null 2>&1 || fail "tar is needed" if command -v sha256sum >/dev/null 2>&1; then sum() { sha256sum "$1" | cut -d' ' -f1; } elif command -v shasum >/dev/null 2>&1; then sum() { shasum -a 256 "$1" | cut -d' ' -f1; } else fail "sha256sum or shasum is needed to check the download"; fi name="holadb-$VERSION-$target" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM say "Downloading HolaDB $VERSION for $target ..." if ! curl -fsSL "$BASE/download/$name.tar.gz" -o "$tmp/$name.tar.gz"; then fail "there is no HolaDB $VERSION build for $target yet. Available builds are listed at $BASE/install/" fi curl -fsSL "$BASE/download/$name.tar.gz.sha256" -o "$tmp/$name.tar.gz.sha256" || fail "could not download the checksum" want=$(cut -d' ' -f1 < "$tmp/$name.tar.gz.sha256") got=$(sum "$tmp/$name.tar.gz") [ -n "$want" ] && [ "$want" = "$got" ] || fail "checksum mismatch (expected $want, got $got). Nothing was installed." say "Checksum ok." mkdir -p "$DEST" rm -rf "$DEST/$name" tar -xzf "$tmp/$name.tar.gz" -C "$DEST" [ -x "$DEST/$name/bin/holadb" ] || fail "the download did not contain bin/holadb" rm -rf "$DEST/bin" ln -s "$DEST/$name/bin" "$DEST/bin" "$DEST/bin/holadb" version >/dev/null 2>&1 || fail "holadb was unpacked to $DEST/$name but does not run on this computer" say "" say "HolaDB $VERSION is installed in $DEST/$name" case ":$PATH:" in *":$DEST/bin:"*) say "Run: holadb version" ;; *) say "To use the 'holadb' command, add it to your PATH. Run this once:" case "${SHELL:-}" in */zsh) say " echo 'export PATH=\"$DEST/bin:\$PATH\"' >> ~/.zshrc && exec zsh" ;; */bash) say " echo 'export PATH=\"$DEST/bin:\$PATH\"' >> ~/.bashrc && exec bash" ;; *) say " export PATH=\"$DEST/bin:\$PATH\"" ;; esac ;; esac say "Then follow the first steps: $BASE/guide/"