-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·63 lines (50 loc) · 1.85 KB
/
install.sh
File metadata and controls
executable file
·63 lines (50 loc) · 1.85 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
#!/usr/bin/env bash
#
# mq installer - curl -fsSL https://raw.githubusercontent.com/bdelespierre/mq/master/install.sh | bash
#
set -euo pipefail
REPO="bdelespierre/mq"
PREFIX="${MQ_PREFIX:-$HOME/.local}"
TMP_DIR=""
info() { echo -e "\033[1;34m==>\033[0m $*"; }
error() { echo -e "\033[1;31mError:\033[0m $*" >&2; exit 1; }
cleanup() {
[[ -n "$TMP_DIR" && -d "$TMP_DIR" ]] && rm -rf "$TMP_DIR"
}
trap cleanup EXIT
# Check dependencies
command -v curl >/dev/null 2>&1 || error "curl is required but not installed"
command -v tar >/dev/null 2>&1 || error "tar is required but not installed"
command -v make >/dev/null 2>&1 || error "make is required but not installed"
# Get latest tag from GitHub API
info "Fetching latest version..."
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/$REPO/tags" | grep -m1 '"name":' | cut -d'"' -f4)
[[ -z "$LATEST_TAG" ]] && error "Failed to fetch latest version"
info "Latest version: $LATEST_TAG"
# Create temp directory
TMP_DIR=$(mktemp -d)
# Download and extract tarball
TARBALL_URL="https://github.com/$REPO/archive/refs/tags/$LATEST_TAG.tar.gz"
info "Downloading $TARBALL_URL..."
curl -fsSL "$TARBALL_URL" | tar -xz -C "$TMP_DIR"
# Find extracted directory (mq-{version} without 'v' prefix)
EXTRACT_DIR="$TMP_DIR/mq-${LATEST_TAG#v}"
[[ -d "$EXTRACT_DIR" ]] || error "Failed to extract archive"
# Install
info "Installing to $PREFIX..."
make -C "$EXTRACT_DIR" install PREFIX="$PREFIX" >/dev/null
# Verify installation
if [[ -x "$PREFIX/bin/mq" ]]; then
info "Successfully installed mq $LATEST_TAG to $PREFIX/bin/mq"
else
error "Installation failed"
fi
# Check if bin is in PATH
if [[ ":$PATH:" != *":$PREFIX/bin:"* ]]; then
echo ""
echo "Add this to your shell profile (~/.bashrc or ~/.zshrc):"
echo ""
echo " export PATH=\"\$PATH:$PREFIX/bin\""
echo ""
fi
info "Done! Run 'mq --help' to get started."