-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·265 lines (222 loc) · 8.27 KB
/
install.sh
File metadata and controls
executable file
·265 lines (222 loc) · 8.27 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/bin/bash
set -e
# aimemo installation script
# Usage: curl -sSL https://raw.githubusercontent.com/MyAgentHubs/aimemo/main/install.sh | bash
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
GITHUB_REPO="MyAgentHubs/aimemo"
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="aimemo"
# Helper functions
error() {
echo -e "${RED}Error: $1${NC}" >&2
exit 1
}
info() {
echo -e "${BLUE}==>${NC} $1"
}
success() {
echo -e "${GREEN}✓${NC} $1"
}
warn() {
echo -e "${YELLOW}Warning: $1${NC}"
}
# Check if running as root
is_root() {
[ "$(id -u)" -eq 0 ]
}
# Detect OS
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "darwin" ;;
*) echo "unknown" ;;
esac
}
# Detect architecture
detect_arch() {
local arch
arch="$(uname -m)"
case "$arch" in
x86_64) echo "amd64" ;;
aarch64) echo "arm64" ;;
arm64) echo "arm64" ;;
*) echo "unknown" ;;
esac
}
# Get latest release version from GitHub
get_latest_version() {
local version
version=$(curl -sSL "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v?([^"]+)".*/\1/')
if [ -z "$version" ]; then
error "Failed to fetch latest version from GitHub"
fi
echo "$version"
}
# Download and install
install_aimemo() {
local os arch version download_url tmp_dir
info "Detecting system information..."
os=$(detect_os)
arch=$(detect_arch)
if [ "$os" = "unknown" ]; then
error "Unsupported operating system: $(uname -s)"
fi
if [ "$arch" = "unknown" ]; then
error "Unsupported architecture: $(uname -m)"
fi
success "Detected: ${os}/${arch}"
info "Fetching latest version..."
version=$(get_latest_version)
success "Latest version: v${version}"
# Construct download URL
local archive_name="aimemo_${version}_${os}_${arch}.tar.gz"
download_url="https://github.com/${GITHUB_REPO}/releases/download/v${version}/${archive_name}"
info "Downloading ${archive_name}..."
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT
if ! curl -sSL "$download_url" -o "${tmp_dir}/${archive_name}"; then
error "Failed to download from ${download_url}"
fi
success "Downloaded to ${tmp_dir}/${archive_name}"
# Verify checksum
info "Verifying checksum..."
local checksum_url="https://github.com/${GITHUB_REPO}/releases/download/v${version}/checksums.txt"
if ! curl -sSL "$checksum_url" -o "${tmp_dir}/checksums.txt"; then
warn "Failed to download checksums.txt, skipping verification"
else
# Change to tmp_dir for checksum verification
(
cd "$tmp_dir" || exit 1
if command -v sha256sum >/dev/null 2>&1; then
if grep "${archive_name}" checksums.txt | sha256sum -c --status; then
success "Checksum verification passed"
else
error "Checksum verification failed - file may be corrupted or tampered"
fi
elif command -v shasum >/dev/null 2>&1; then
if grep "${archive_name}" checksums.txt | shasum -a 256 -c --status; then
success "Checksum verification passed"
else
error "Checksum verification failed - file may be corrupted or tampered"
fi
else
warn "No checksum tool found (sha256sum or shasum), skipping verification"
fi
)
fi
info "Extracting archive..."
if ! tar -xzf "${tmp_dir}/${archive_name}" -C "$tmp_dir"; then
error "Failed to extract archive"
fi
success "Extracted successfully"
# Install binary
info "Installing aimemo to ${INSTALL_DIR}..."
if is_root; then
# Running as root, install directly
if ! mv "${tmp_dir}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"; then
error "Failed to install binary to ${INSTALL_DIR}"
fi
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
else
# Not root, try with sudo
if command -v sudo >/dev/null 2>&1; then
if ! sudo mv "${tmp_dir}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"; then
error "Failed to install binary to ${INSTALL_DIR} (sudo required)"
fi
sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
else
error "Installation to ${INSTALL_DIR} requires root privileges. Please run with sudo or as root."
fi
fi
success "Installed to ${INSTALL_DIR}/${BINARY_NAME}"
# Verify installation
info "Verifying installation..."
if ! command -v aimemo >/dev/null 2>&1; then
warn "${INSTALL_DIR} may not be in your PATH"
# Detect user's shell and suggest appropriate config file
local shell_config
if [ -n "$ZSH_VERSION" ] || [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ]; then
shell_config="~/.zshrc"
elif [ -n "$BASH_VERSION" ] || [ "$SHELL" = "/bin/bash" ] || [ "$SHELL" = "/usr/bin/bash" ]; then
shell_config="~/.bashrc"
else
shell_config="~/.profile"
fi
warn "Add this line to your ${shell_config}:"
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
echo ""
fi
local installed_version
installed_version=$(aimemo --version 2>&1 | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown")
if [ "$installed_version" = "v${version}" ] || [ "$installed_version" = "${version}" ]; then
success "Verification passed: aimemo ${installed_version}"
else
warn "Version mismatch: expected ${version}, got ${installed_version}"
fi
echo ""
success "aimemo installed successfully!"
echo ""
}
# Print next steps
print_next_steps() {
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN} Next Steps${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "1. Initialize memory for your project:"
echo -e " ${BLUE}cd your-project && aimemo init${NC}"
echo ""
echo "2. Register with your AI coding client:"
echo ""
echo " ${BLUE}# Claude Code${NC}"
echo " claude mcp add-json aimemo-memory '{\"command\":\"aimemo\",\"args\":[\"serve\"]}'"
echo ""
echo " ${BLUE}# OpenClaw${NC}"
echo " Add to ~/.openclaw/openclaw.json:"
echo " {"
echo " \"mcpServers\": {"
echo " \"aimemo-memory\": {"
echo " \"command\": \"${INSTALL_DIR}/aimemo\","
echo " \"args\": [\"serve\"]"
echo " }"
echo " }"
echo " }"
echo ""
echo " ${BLUE}# Cursor / Windsurf / Cline / Continue / Zed${NC}"
echo " See: https://github.com/MyAgentHubs/aimemo#client-support"
echo ""
echo "3. Restart your AI coding client"
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "Documentation:"
echo " • Main README: https://github.com/MyAgentHubs/aimemo"
echo " • OpenClaw Integration: https://github.com/MyAgentHubs/aimemo/blob/main/docs/openclaw-integration.md"
echo ""
echo "Need help? Open an issue: https://github.com/MyAgentHubs/aimemo/issues"
echo ""
}
# Main
main() {
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN} aimemo installer${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check dependencies
if ! command -v curl >/dev/null 2>&1; then
error "curl is required but not installed"
fi
if ! command -v tar >/dev/null 2>&1; then
error "tar is required but not installed"
fi
install_aimemo
print_next_steps
}
main "$@"