-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (59 loc) · 2.05 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·73 lines (59 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# install.sh — Install the latest enola release.
# Usage: curl -fsSL https://raw.githubusercontent.com/enola-labs/enola/main/install.sh | sh
set -euo pipefail
# --- Detect OS ---
OS="$(uname -s)"
case "$OS" in
Linux) OS=linux ;;
Darwin) OS=darwin ;;
*) echo "Unsupported OS: $OS" >&2; exit 1 ;;
esac
# --- Detect arch ---
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH=amd64 ;;
arm64|aarch64) ARCH=arm64 ;;
*) echo "Unsupported arch: $ARCH" >&2; exit 1 ;;
esac
# --- Fetch latest version ---
VERSION="$(curl -fsSL https://api.github.com/repos/enola-labs/enola/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/')"
if [ -z "$VERSION" ]; then
echo "Failed to fetch latest version" >&2
exit 1
fi
BASE="enola-${VERSION}-${OS}-${ARCH}"
ASSET="${BASE}.tar.gz"
SHASUM="${BASE}.sha256"
URL="https://github.com/enola-labs/enola/releases/download/v${VERSION}/${ASSET}"
SUM_URL="https://github.com/enola-labs/enola/releases/download/v${VERSION}/${SHASUM}"
echo "==> Downloading enola v${VERSION} for ${OS}/${ARCH} ..."
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
if ! curl -fsSL -o "$TMPDIR/$ASSET" "$URL"; then
echo "No prebuilt binary for ${OS}/${ARCH} in enola v${VERSION}." >&2
echo "See the available downloads at:" >&2
echo " https://github.com/enola-labs/enola/releases/tag/v${VERSION}" >&2
exit 1
fi
curl -fsSL -o "$TMPDIR/$SHASUM" "$SUM_URL"
echo "==> Verifying checksum ..."
if command -v sha256sum >/dev/null 2>&1; then
(cd "$TMPDIR" && sha256sum -c "$SHASUM")
else
(cd "$TMPDIR" && shasum -a 256 -c "$SHASUM")
fi
echo "==> Extracting ..."
tar xzf "$TMPDIR/$ASSET" -C "$TMPDIR"
# --- Install ---
BIN_NAME="${BASE}"
if [ "$OS" = "windows" ]; then
BIN_NAME="${BIN_NAME}.exe"
fi
INSTALL_DIR="${ENOLA_INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$INSTALL_DIR"
install -m 755 "$TMPDIR/$BIN_NAME" "$INSTALL_DIR/enola"
echo "==> enola v${VERSION} installed to $INSTALL_DIR/enola"
echo ""
echo "If \$HOME/.local/bin is not in your PATH, add it:"
echo " export PATH=\"$HOME/.local/bin:\$PATH\""