-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (59 loc) · 2.06 KB
/
install.sh
File metadata and controls
74 lines (59 loc) · 2.06 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
74
#!/usr/bin/env sh
# Supermodel CLI installer
# Usage: curl -fsSL https://supermodeltools.com/install.sh | sh
set -e
REPO="supermodeltools/cli"
BINARY="supermodel"
INSTALL_DIR="${SUPERMODEL_INSTALL_DIR:-/usr/local/bin}"
# Detect OS
OS="$(uname -s)"
case "$OS" in
Linux) OS="linux" ;;
Darwin) OS="darwin" ;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64 | amd64) ARCH="amd64" ;;
aarch64 | arm64) ARCH="arm64" ;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
# Resolve latest version if not pinned
if [ -z "$SUPERMODEL_VERSION" ]; then
SUPERMODEL_VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')"
fi
if [ -z "$SUPERMODEL_VERSION" ]; then
echo "Could not determine latest version. Set SUPERMODEL_VERSION to pin a release."
exit 1
fi
VERSION_BARE="${SUPERMODEL_VERSION#v}"
ARCHIVE="${BINARY}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${SUPERMODEL_VERSION}/${ARCHIVE}"
CHECKSUM_URL="https://github.com/${REPO}/releases/download/${SUPERMODEL_VERSION}/checksums.txt"
echo "Installing supermodel ${SUPERMODEL_VERSION} (${OS}/${ARCH})..."
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
curl -fsSL "$URL" -o "$TMP/$ARCHIVE"
curl -fsSL "$CHECKSUM_URL" -o "$TMP/checksums.txt"
# Verify checksum
(cd "$TMP" && grep "$ARCHIVE" checksums.txt | sha256sum --check --status 2>/dev/null \
|| shasum -a 256 --check --ignore-missing checksums.txt 2>/dev/null) \
|| { echo "Checksum verification failed"; exit 1; }
tar -xzf "$TMP/$ARCHIVE" -C "$TMP" "$BINARY"
# Install — fall back to user-local dir if /usr/local/bin isn't writable
if [ ! -w "$INSTALL_DIR" ]; then
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
echo "No write access to /usr/local/bin — installing to $INSTALL_DIR"
echo "Add $INSTALL_DIR to your PATH if it isn't already."
fi
install -m755 "$TMP/$BINARY" "$INSTALL_DIR/$BINARY"
echo "Installed: $INSTALL_DIR/$BINARY"
"$INSTALL_DIR/$BINARY" version