#!/bin/bash # MCP Bridge Quick Installer with Logging # Logs to /config/mcp_bridge_install.log # Configuration GITEA_URL="${GITEA_URL:-http://your-gitea.local:3000}" REPO="${REPO:-username/homeassistant-mcp-bridge}" BRANCH="${BRANCH:-main}" BASE_URL="$GITEA_URL/$REPO/raw/branch/$BRANCH/custom_components/mcp_bridge" # Logging LOG_FILE="/config/mcp_bridge_install.log" exec 1> >(tee -a "$LOG_FILE") exec 2>&1 echo "=== MCP Bridge Installation Started at $(date) ===" echo "Configuration:" echo " GITEA_URL: $GITEA_URL" echo " REPO: $REPO" echo " BRANCH: $BRANCH" echo " BASE_URL: $BASE_URL" echo "" # Determine config directory CONFIG_DIR="${CONFIG_DIR:-/config}" if [ ! -d "$CONFIG_DIR" ]; then CONFIG_DIR="${HOME}/.homeassistant" echo "Using alternate config dir: $CONFIG_DIR" fi DEST="$CONFIG_DIR/custom_components/mcp_bridge" echo "Installation directory: $DEST" echo "" # Create directory echo "Creating directory..." mkdir -p "$DEST" || { echo "ERROR: Failed to create directory $DEST" exit 1 } echo "Directory created: $DEST" echo "" # Download files echo "Downloading files..." cd "$DEST" || exit 1 for file in __init__.py manifest.json services.yaml; do echo " Downloading $file from $BASE_URL/$file" if curl -fsSL "$BASE_URL/$file" -o "$file"; then echo " ✓ $file downloaded successfully ($(wc -c < "$file") bytes)" else echo " ✗ FAILED to download $file" echo " URL attempted: $BASE_URL/$file" exit 1 fi done echo "" echo "=== Installation Summary ===" echo "Files installed in: $DEST" ls -lh "$DEST" echo "" echo "✅ MCP Bridge installed successfully!" echo "⚠️ IMPORTANT: Restart Home Assistant to activate" echo "" echo "Installation completed at $(date)" echo "=== End of Installation Log ==="