-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·136 lines (113 loc) · 2.98 KB
/
install.sh
File metadata and controls
executable file
·136 lines (113 loc) · 2.98 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
#
# MAP CLI Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/pmarsceill/mapcli/main/install.sh | bash
#
set -e
REPO="pmarsceill/mapcli"
INSTALL_DIR="${MAP_INSTALL_DIR:-$HOME/.local/bin}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Detect OS
detect_os() {
local os
os=$(uname -s)
case "$os" in
Linux)
echo "linux"
;;
Darwin)
echo "darwin"
;;
*)
error "Unsupported operating system: $os"
;;
esac
}
# Detect architecture
detect_arch() {
local arch
arch=$(uname -m)
case "$arch" in
x86_64|amd64)
echo "amd64"
;;
arm64|aarch64)
echo "arm64"
;;
*)
error "Unsupported architecture: $arch"
;;
esac
}
# Get latest release version from GitHub API
get_latest_version() {
local version
version=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$version" ]; then
error "Failed to fetch latest version"
fi
echo "$version"
}
main() {
info "Installing MAP CLI..."
# Detect platform
local os arch platform
os=$(detect_os)
arch=$(detect_arch)
platform="${os}-${arch}"
info "Detected platform: $platform"
# Get latest version
local version
version=$(get_latest_version)
info "Latest version: $version"
# Construct download URL
local download_url="https://github.com/${REPO}/releases/download/${version}/map-${platform}.tar.gz"
info "Downloading from: $download_url"
# Create install directory
mkdir -p "$INSTALL_DIR"
# Download and extract
local tmp_dir
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT
if ! curl -fsSL "$download_url" -o "$tmp_dir/map.tar.gz"; then
error "Failed to download release"
fi
if ! tar -xzf "$tmp_dir/map.tar.gz" -C "$tmp_dir"; then
error "Failed to extract archive"
fi
# Install binaries
mv "$tmp_dir/map" "$INSTALL_DIR/map"
mv "$tmp_dir/mapd" "$INSTALL_DIR/mapd"
chmod +x "$INSTALL_DIR/map" "$INSTALL_DIR/mapd"
info "Installed map and mapd to $INSTALL_DIR"
# Verify installation
if "$INSTALL_DIR/map" --version > /dev/null 2>&1; then
info "Installation verified: $("$INSTALL_DIR"/map --version)"
else
warn "Installation completed but verification failed"
fi
# Check if install dir is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
warn "$INSTALL_DIR is not in your PATH"
echo ""
echo "Add it to your shell profile:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
echo ""
fi
info "Installation complete!"
}
main "$@"