-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·89 lines (74 loc) · 2.38 KB
/
install.sh
File metadata and controls
executable file
·89 lines (74 loc) · 2.38 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
# Lattice installer
# Usage: curl -fsSL https://forkzero.ai/lattice/install.sh | sh
set -e
REPO="forkzero/lattice"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
# Detect OS
OS="$(uname -s)"
case "$OS" in
Linux) OS="unknown-linux-gnu" ;;
Darwin) OS="apple-darwin" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) ARCH="x86_64" ;;
arm64|aarch64) ARCH="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
TARGET="${ARCH}-${OS}"
# Get latest version
if [ -z "$VERSION" ]; then
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/')
fi
if [ -z "$VERSION" ]; then
echo "Failed to detect latest version"
exit 1
fi
ARCHIVE="lattice-${VERSION}-${TARGET}.tar.gz"
URL="https://github.com/${REPO}/releases/download/v${VERSION}/${ARCHIVE}"
CHECKSUM_URL="https://github.com/${REPO}/releases/download/v${VERSION}/checksums.txt"
echo "Installing lattice v${VERSION} for ${TARGET}..."
# Create temp directory
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
# Download archive
echo "Downloading ${URL}..."
curl -fsSL "$URL" -o "${TMP_DIR}/${ARCHIVE}"
# Download and verify checksum
echo "Verifying checksum..."
curl -fsSL "$CHECKSUM_URL" -o "${TMP_DIR}/checksums.txt"
cd "$TMP_DIR"
if command -v sha256sum > /dev/null 2>&1; then
grep "$ARCHIVE" checksums.txt | sha256sum -c - > /dev/null 2>&1
elif command -v shasum > /dev/null 2>&1; then
grep "$ARCHIVE" checksums.txt | shasum -a 256 -c - > /dev/null 2>&1
else
echo "Warning: Could not verify checksum (sha256sum/shasum not found)"
fi
# Extract
echo "Extracting..."
tar -xzf "$ARCHIVE"
# Install
BINARY_DIR="lattice-${VERSION}-${TARGET}"
if [ -w "$INSTALL_DIR" ]; then
mv "${BINARY_DIR}/lattice" "$INSTALL_DIR/"
else
echo "Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "${BINARY_DIR}/lattice" "$INSTALL_DIR/"
fi
# Verify
if command -v lattice > /dev/null 2>&1; then
echo ""
echo "Successfully installed lattice $(lattice --version)"
echo ""
echo "Get started:"
echo " lattice init # Initialize a lattice"
echo " lattice --help # Show all commands"
else
echo ""
echo "Installed to ${INSTALL_DIR}/lattice"
echo "Add ${INSTALL_DIR} to your PATH if not already present."
fi