#!/bin/sh set -e REPO="t8/memoryport" BINARIES="uc uc-mcp uc-proxy uc-server" # Detect OS OS="$(uname -s)" case "$OS" in Darwin) OS="macos" ;; Linux) OS="linux" ;; *) echo "Error: Unsupported operating system: $OS" echo "Memoryport supports macOS and Linux." exit 1 ;; esac # Detect architecture ARCH="$(uname -m)" case "$ARCH" in x86_64|amd64) ARCH="x64" ;; arm64|aarch64) ARCH="arm64" ;; *) echo "Error: Unsupported architecture: $ARCH" exit 1 ;; esac ASSET="memoryport-${OS}-${ARCH}.tar.gz" URL="https://github.com/${REPO}/releases/latest/download/${ASSET}" echo "Installing Memoryport (${OS}/${ARCH})..." echo "" # Create temp directory TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT # Download echo "Downloading $URL..." if command -v curl >/dev/null 2>&1; then curl -fsSL "$URL" -o "$TMP/$ASSET" elif command -v wget >/dev/null 2>&1; then wget -q "$URL" -O "$TMP/$ASSET" else echo "Error: curl or wget is required." exit 1 fi # Extract tar -xzf "$TMP/$ASSET" -C "$TMP" # Determine install directory if [ -w /usr/local/bin ]; then INSTALL_DIR="/usr/local/bin" NEEDS_SUDO=false elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then INSTALL_DIR="/usr/local/bin" NEEDS_SUDO=true else INSTALL_DIR="${HOME}/.local/bin" NEEDS_SUDO=false mkdir -p "$INSTALL_DIR" fi # Install all binaries for BIN_NAME in $BINARIES; do BIN="$(find "$TMP" -name "$BIN_NAME" -type f | head -1)" if [ -z "$BIN" ]; then echo "Warning: '$BIN_NAME' not found in archive, skipping." continue fi chmod +x "$BIN" if [ "$NEEDS_SUDO" = true ]; then sudo mv "$BIN" "$INSTALL_DIR/$BIN_NAME" else mv "$BIN" "$INSTALL_DIR/$BIN_NAME" fi done # Check if install dir is on PATH case ":$PATH:" in *":$INSTALL_DIR:"*) ;; *) echo "" echo "Note: $INSTALL_DIR is not in your PATH." echo "Add it by running:" echo "" if [ -n "$ZSH_VERSION" ] || [ "$(basename "$SHELL")" = "zsh" ]; then echo " echo 'export PATH="$INSTALL_DIR:\$PATH"' >> ~/.zshrc && source ~/.zshrc" else echo " echo 'export PATH="$INSTALL_DIR:\$PATH"' >> ~/.bashrc && source ~/.bashrc" fi echo "" ;; esac echo "" echo "Memoryport installed to $INSTALL_DIR" echo " uc — CLI" echo " uc-mcp — MCP server for Claude Code / Cursor" echo " uc-proxy — API proxy for auto-capture" echo " uc-server — Dashboard API server" echo "" echo "Get started:" echo " uc init" echo ""