forked from cartridge-gg/controller-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
94 lines (76 loc) · 2.13 KB
/
install.sh
File metadata and controls
94 lines (76 loc) · 2.13 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
90
91
92
93
94
#!/bin/bash
set -e
# Cartridge Controller CLI Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/cartridge-gg/controller/main/controller-cli/install.sh | bash
REPO="cartridge-gg/controller-cli"
BINARY_NAME="controller"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
# Detect platform
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Linux*)
PLATFORM="unknown-linux-gnu"
;;
Darwin*)
PLATFORM="apple-darwin"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
case "$ARCH" in
x86_64)
ARCH="x86_64"
;;
arm64|aarch64)
ARCH="aarch64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
TARGET="${ARCH}-${PLATFORM}"
echo "Detected platform: $TARGET"
# Get latest release
echo "Fetching latest release..."
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_RELEASE" ]; then
echo "Failed to fetch latest release"
exit 1
fi
echo "Latest release: $LATEST_RELEASE"
# Download URL
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/${BINARY_NAME}-${TARGET}.tar.gz"
echo "Downloading from: $DOWNLOAD_URL"
# Create temp directory
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
# Download and extract
cd "$TMP_DIR"
curl -fsSL "$DOWNLOAD_URL" | tar xz
# Create install directory if it doesn't exist
mkdir -p "$INSTALL_DIR"
# Install binary
mv "$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
echo ""
echo "✅ $BINARY_NAME installed successfully to $INSTALL_DIR"
echo ""
# Check if install dir is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "⚠️ Add $INSTALL_DIR to your PATH:"
echo ""
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
echo ""
echo "Add this line to your ~/.bashrc, ~/.zshrc, or ~/.profile"
echo ""
fi
# Verify installation
if command -v "$BINARY_NAME" &> /dev/null; then
echo "Run '$BINARY_NAME --help' to get started"
else
echo "Run '$INSTALL_DIR/$BINARY_NAME --help' to get started"
fi