|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +VERSION="${VERSION:-latest}" |
| 5 | + |
| 6 | +# Detect architecture |
| 7 | +ARCH="$(uname -m)" |
| 8 | +case "${ARCH}" in |
| 9 | + x86_64) ARCH="amd64" ;; |
| 10 | + aarch64) ARCH="arm64" ;; |
| 11 | + arm64) ARCH="arm64" ;; |
| 12 | + *) |
| 13 | + echo "Unsupported architecture: ${ARCH}" >&2 |
| 14 | + exit 1 |
| 15 | + ;; |
| 16 | +esac |
| 17 | + |
| 18 | +# Detect OS |
| 19 | +OS="$(uname -s | tr '[:upper:]' '[:lower:]')" |
| 20 | +case "${OS}" in |
| 21 | + linux) OS="linux" ;; |
| 22 | + darwin) OS="darwin" ;; |
| 23 | + *) |
| 24 | + echo "Unsupported OS: ${OS}" >&2 |
| 25 | + exit 1 |
| 26 | + ;; |
| 27 | +esac |
| 28 | + |
| 29 | +# Resolve latest version |
| 30 | +if [ "${VERSION}" = "latest" ]; then |
| 31 | + VERSION="$(curl -fsSL https://api.github.com/repos/entireio/cli/releases/latest | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/')" |
| 32 | +fi |
| 33 | + |
| 34 | +# Strip leading 'v' if present |
| 35 | +VERSION="${VERSION#v}" |
| 36 | + |
| 37 | +TARBALL="entire_${OS}_${ARCH}.tar.gz" |
| 38 | +DOWNLOAD_URL="https://github.com/entireio/cli/releases/download/v${VERSION}/${TARBALL}" |
| 39 | + |
| 40 | +echo "Installing Entire CLI v${VERSION} (${OS}/${ARCH})..." |
| 41 | + |
| 42 | +# Download and extract |
| 43 | +TMP_DIR="$(mktemp -d)" |
| 44 | +trap 'rm -rf "${TMP_DIR}"' EXIT |
| 45 | + |
| 46 | +curl -fsSL "${DOWNLOAD_URL}" -o "${TMP_DIR}/${TARBALL}" |
| 47 | +tar -xzf "${TMP_DIR}/${TARBALL}" -C "${TMP_DIR}" |
| 48 | + |
| 49 | +# Install binary |
| 50 | +install -m 755 "${TMP_DIR}/entire" /usr/local/bin/entire |
| 51 | + |
| 52 | +# Install shell completions if available |
| 53 | +if [ -d "${TMP_DIR}/completions" ]; then |
| 54 | + if [ -f "${TMP_DIR}/completions/entire.bash" ]; then |
| 55 | + mkdir -p /etc/bash_completion.d |
| 56 | + cp "${TMP_DIR}/completions/entire.bash" /etc/bash_completion.d/entire |
| 57 | + fi |
| 58 | + if [ -f "${TMP_DIR}/completions/entire.zsh" ]; then |
| 59 | + mkdir -p /usr/local/share/zsh/site-functions |
| 60 | + cp "${TMP_DIR}/completions/entire.zsh" /usr/local/share/zsh/site-functions/_entire |
| 61 | + fi |
| 62 | + if [ -f "${TMP_DIR}/completions/entire.fish" ]; then |
| 63 | + mkdir -p /usr/share/fish/vendor_completions.d |
| 64 | + cp "${TMP_DIR}/completions/entire.fish" /usr/share/fish/vendor_completions.d/entire.fish |
| 65 | + fi |
| 66 | +fi |
| 67 | + |
| 68 | +echo "Entire CLI v${VERSION} installed successfully." |
0 commit comments