-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·69 lines (58 loc) · 1.73 KB
/
install.sh
File metadata and controls
executable file
·69 lines (58 loc) · 1.73 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
#!/bin/sh
set -eu
REPO="ClickHouse/clickhousectl"
INSTALL_DIR="$HOME/.local/bin"
BINARY_NAME="clickhousectl"
# Detect OS
OS="$(uname -s)"
case "$OS" in
Linux) OS_TARGET="unknown-linux-musl" ;;
Darwin) OS_TARGET="apple-darwin" ;;
*)
echo "Error: unsupported OS: $OS" >&2
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) ARCH_TARGET="x86_64" ;;
aarch64|arm64) ARCH_TARGET="aarch64" ;;
*)
echo "Error: unsupported architecture: $ARCH" >&2
exit 1
;;
esac
TARGET="${ARCH_TARGET}-${OS_TARGET}"
echo "Detected platform: $TARGET"
# Get latest release tag
echo "Fetching latest release..."
LATEST="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')"
if [ -z "$LATEST" ]; then
echo "Error: could not determine latest release" >&2
exit 1
fi
echo "Latest release: $LATEST"
# Download binary
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST}/clickhousectl-${TARGET}"
echo "Downloading ${DOWNLOAD_URL}..."
mkdir -p "$INSTALL_DIR"
curl -fsSL "$DOWNLOAD_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
echo "Installed ${BINARY_NAME} to ${INSTALL_DIR}/${BINARY_NAME}"
# Create chctl alias (symlink)
ln -sf "${INSTALL_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/chctl"
echo "Created alias: chctl -> ${BINARY_NAME}"
# Check if install dir is in PATH
case ":$PATH:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "NOTE: ${INSTALL_DIR} is not in your PATH."
echo "Add it by running:"
echo ""
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
echo ""
echo "You may want to add that line to your shell profile (~/.bashrc, ~/.zshrc, etc.)"
;;
esac