#!/bin/sh # riz installer — fetches the latest release binary from GitHub and drops it on PATH. # # Usage: curl -fsSL https://riz.dev/install | sh # Or: curl -fsSL https://riz.dev/install | sh -s -- --version v0.1.0 # # Source: https://github.com/24X7/riz/blob/main/web/install # License: Apache-2.0 (same as riz) # # Release process: docs/release.md. Trigger is `git tag v0.X.Y && git push --tags`; # cargo-dist + GitHub Actions builds + uploads tarballs for all 4 targets. If a # tag is ever missing its uploaded assets, this script exits with a 404 from # GitHub — fall back to: `cargo install --git https://github.com/24X7/riz`. set -eu REPO="24X7/riz" VERSION="${RIZ_VERSION:-latest}" INSTALL_DIR="${RIZ_INSTALL_DIR:-${HOME}/.local/bin}" while [ $# -gt 0 ]; do case "$1" in --version) VERSION="$2"; shift 2 ;; --dir) INSTALL_DIR="$2"; shift 2 ;; -h|--help) cat < Install a specific release (default: latest) --dir Install to a different directory (default: \$HOME/.local/bin) Environment: RIZ_VERSION Same as --version RIZ_INSTALL_DIR Same as --dir EOF exit 0 ;; *) echo "unknown arg: $1" >&2; exit 1 ;; esac done # Platform detection — mirrors cargo-dist's release-naming convention. OS="$(uname -s)" ARCH="$(uname -m)" case "$OS" in Darwin) case "$ARCH" in arm64) TARGET="aarch64-apple-darwin" ;; *) echo "unsupported macOS arch: $ARCH (riz ships Apple Silicon only)" >&2; exit 1 ;; esac ;; Linux) case "$ARCH" in aarch64) TARGET="aarch64-unknown-linux-gnu" ;; x86_64) TARGET="x86_64-unknown-linux-gnu" ;; *) echo "unsupported Linux arch: $ARCH" >&2; exit 1 ;; esac ;; *) echo "unsupported OS: $OS" >&2; exit 1 ;; esac # Resolve version → release URL. if [ "$VERSION" = "latest" ]; then TARBALL_URL="https://github.com/${REPO}/releases/latest/download/riz-${TARGET}.tar.xz" else TARBALL_URL="https://github.com/${REPO}/releases/download/${VERSION}/riz-${TARGET}.tar.xz" fi # ─── anonymous install telemetry (fire-and-forget, best-effort) ───────────── # Reports OS / arch / target / version to https://riz.dev/api/install; the server # adds coarse geo (country / region / city, derived from your IP — never the raw # address) so the project can see where riz is installed. Non-blocking; never # fails or slows the install. Opt out entirely with: RIZ_NO_TELEMETRY=1 riz_ping() { if [ -n "${RIZ_NO_TELEMETRY:-}" ]; then return 0; fi if ! command -v curl >/dev/null 2>&1; then return 0; fi curl -fsS -m 3 -A "riz-install/${VERSION}" \ "https://riz.dev/api/install?stage=${1}&os=${OS}&arch=${ARCH}&target=${TARGET}&version=${VERSION}" \ >/dev/null 2>&1 & } riz_ping start echo "riz installer" echo " target: $TARGET" echo " version: $VERSION" echo " dir: $INSTALL_DIR" echo " url: $TARBALL_URL" echo # Fetch + extract into a temp dir. TMP="$(mktemp -d 2>/dev/null || mktemp -d -t riz)" trap 'rm -rf "$TMP"' EXIT if command -v curl >/dev/null 2>&1; then curl -fsSL "$TARBALL_URL" -o "$TMP/riz.tar.xz" elif command -v wget >/dev/null 2>&1; then wget -q "$TARBALL_URL" -O "$TMP/riz.tar.xz" else echo "need curl or wget on PATH" >&2; exit 1 fi tar -xJf "$TMP/riz.tar.xz" -C "$TMP" # Find the binary inside (cargo-dist nests it under a versioned dir). BIN="$(find "$TMP" -name riz -type f -perm -u+x | head -n 1)" if [ -z "$BIN" ]; then echo "could not find riz binary in tarball" >&2; exit 1 fi mkdir -p "$INSTALL_DIR" install -m 0755 "$BIN" "$INSTALL_DIR/riz" echo "installed: $INSTALL_DIR/riz" "$INSTALL_DIR/riz" --version 2>/dev/null || echo "(run '$INSTALL_DIR/riz --help' to verify)" riz_ping success case ":$PATH:" in *":$INSTALL_DIR:"*) ;; *) echo echo "NOTE: $INSTALL_DIR is not on your PATH. Add this to your shell rc:" echo " export PATH=\"$INSTALL_DIR:\$PATH\"" ;; esac