-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·77 lines (62 loc) · 1.92 KB
/
install.sh
File metadata and controls
executable file
·77 lines (62 loc) · 1.92 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
#!/bin/sh
# Install magic-code
# Usage: curl -fsSL https://raw.githubusercontent.com/kienbui1995/mc-code/main/install.sh | sh
set -e
REPO="kienbui1995/mc-code"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
# Detect platform
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$OS" in
linux) PLATFORM="linux" ;;
darwin) PLATFORM="macos" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
x86_64|amd64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
NAME="magic-code-${PLATFORM}-${ARCH}"
# Get latest release tag
if command -v curl >/dev/null 2>&1; then
LATEST=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | head -1 | cut -d'"' -f4)
elif command -v wget >/dev/null 2>&1; then
LATEST=$(wget -qO- "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | head -1 | cut -d'"' -f4)
else
echo "Error: curl or wget required"; exit 1
fi
if [ -z "$LATEST" ]; then
echo "Error: could not determine latest release"
exit 1
fi
URL="https://github.com/$REPO/releases/download/$LATEST/$NAME.tar.gz"
echo "Installing magic-code $LATEST ($PLATFORM/$ARCH)..."
echo " From: $URL"
echo " To: $INSTALL_DIR/magic-code"
# Download and extract
mkdir -p "$INSTALL_DIR"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$URL" -o "$TMPDIR/magic-code.tar.gz"
else
wget -q "$URL" -O "$TMPDIR/magic-code.tar.gz"
fi
tar xzf "$TMPDIR/magic-code.tar.gz" -C "$TMPDIR"
mv "$TMPDIR/magic-code" "$INSTALL_DIR/magic-code"
chmod +x "$INSTALL_DIR/magic-code"
echo ""
echo "✓ magic-code installed to $INSTALL_DIR/magic-code"
# Check PATH
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo ""
echo "Add to your PATH:"
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
;;
esac
echo ""
echo "Get started:"
echo " magic-code --help"