-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
62 lines (51 loc) · 1.79 KB
/
Copy pathinstall.sh
File metadata and controls
62 lines (51 loc) · 1.79 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
#!/bin/sh
set -e
# Loon CLI Installation Script
# This script detects the OS and Architecture, downloads the appropriate standalone
# binary and the required tree-sitter.wasm from the latest GitHub release of gitprae/loon-cli.
# Ensure we're running with root privileges for /usr/local/bin
if [ "$(id -u)" -ne 0 ]; then
echo "This script requires root privileges to install the CLI to /usr/local/bin."
echo "Please run this script using sudo: sudo sh install.sh"
exit 1
fi
echo "Detecting operating system..."
OS="$(uname -s)"
case "${OS}" in
Linux*) OS="linux" ;;
Darwin*) OS="darwin" ;;
*) echo "Error: Unsupported operating system: ${OS}"; exit 1 ;;
esac
echo "Detecting system architecture..."
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64) ARCH="x64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Error: Unsupported architecture: ${ARCH}"; exit 1 ;;
esac
TARGET="${OS}-${ARCH}"
echo "Detected target: ${TARGET}"
# Construct download URLs
REPO="gitprae/loon-cli"
BASE_URL="https://github.com/${REPO}/releases/latest/download"
BINARY_URL="${BASE_URL}/loon-${TARGET}"
WASM_URL="${BASE_URL}/tree-sitter.wasm"
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
echo "Downloading Loon CLI (${TARGET})..."
curl -sL --fail "${BINARY_URL}" -o "${TMP_DIR}/loon" || {
echo "Error: Failed to download the Loon binary."
exit 1
}
echo "Downloading tree-sitter.wasm..."
curl -sL --fail "${WASM_URL}" -o "${TMP_DIR}/tree-sitter.wasm" || {
echo "Error: Failed to download tree-sitter.wasm."
exit 1
}
echo "Installing to /usr/local/bin..."
mkdir -p /usr/local/bin
chmod +x "${TMP_DIR}/loon"
mv "${TMP_DIR}/loon" /usr/local/bin/loon
mv "${TMP_DIR}/tree-sitter.wasm" /usr/local/bin/tree-sitter.wasm
echo "✅ Loon CLI successfully installed!"
echo "Run 'loon --help' to get started."