130 lines
4.0 KiB
Bash
130 lines
4.0 KiB
Bash
#!/bin/bash
|
|
# MCP Bridge Installation Diagnostic Script
|
|
# Run this manually in HA terminal to see what's happening
|
|
|
|
echo "=== MCP Bridge Installation Diagnostic ==="
|
|
echo ""
|
|
|
|
# 1. Check network connectivity
|
|
echo "1. Testing Gitea connectivity..."
|
|
GITEA_URL="${GITEA_URL:-https://www.git.quarantinedstudio.com}"
|
|
REPO="${REPO:-mvezina/homeassistant-mcp-bridge}"
|
|
|
|
echo " Attempting to reach: $GITEA_URL/$REPO"
|
|
if curl -I "$GITEA_URL/$REPO" 2>&1 | head -n 1; then
|
|
echo " ✓ Can reach Gitea server"
|
|
else
|
|
echo " ✗ Cannot reach Gitea server"
|
|
echo " Please check:"
|
|
echo " - Is Gitea running?"
|
|
echo " - Is the URL correct?"
|
|
echo " - Can HA reach your Gitea server?"
|
|
fi
|
|
echo ""
|
|
|
|
# 2. Check if curl exists
|
|
echo "2. Checking for curl..."
|
|
if command -v curl &> /dev/null; then
|
|
echo " ✓ curl is available: $(which curl)"
|
|
curl --version | head -n 1
|
|
else
|
|
echo " ✗ curl is NOT available"
|
|
echo " Checking for wget..."
|
|
if command -v wget &> /dev/null; then
|
|
echo " ✓ wget is available: $(which wget)"
|
|
else
|
|
echo " ✗ Neither curl nor wget available!"
|
|
fi
|
|
fi
|
|
echo ""
|
|
|
|
# 3. Check config directory
|
|
echo "3. Checking config directory..."
|
|
CONFIG_DIR="/config"
|
|
if [ -d "$CONFIG_DIR" ]; then
|
|
echo " ✓ /config exists"
|
|
else
|
|
echo " ✗ /config does not exist, trying alternate..."
|
|
CONFIG_DIR="${HOME}/.homeassistant"
|
|
if [ -d "$CONFIG_DIR" ]; then
|
|
echo " ✓ Using $CONFIG_DIR"
|
|
else
|
|
echo " ✗ Cannot find config directory!"
|
|
fi
|
|
fi
|
|
echo ""
|
|
|
|
# 4. Check/create custom_components directory
|
|
echo "4. Checking custom_components directory..."
|
|
CUSTOM_DIR="$CONFIG_DIR/custom_components"
|
|
if [ -d "$CUSTOM_DIR" ]; then
|
|
echo " ✓ $CUSTOM_DIR exists"
|
|
else
|
|
echo " ! $CUSTOM_DIR does not exist, creating..."
|
|
mkdir -p "$CUSTOM_DIR" && echo " ✓ Created successfully" || echo " ✗ Failed to create"
|
|
fi
|
|
echo ""
|
|
|
|
# 5. Check write permissions
|
|
echo "5. Checking write permissions..."
|
|
TEST_FILE="$CUSTOM_DIR/test_write_$$"
|
|
if touch "$TEST_FILE" 2>/dev/null; then
|
|
echo " ✓ Can write to $CUSTOM_DIR"
|
|
rm "$TEST_FILE"
|
|
else
|
|
echo " ✗ Cannot write to $CUSTOM_DIR"
|
|
echo " Permission issue!"
|
|
fi
|
|
echo ""
|
|
|
|
# 6. Try downloading a test file
|
|
echo "6. Testing file download..."
|
|
BRANCH="${BRANCH:-main}"
|
|
TEST_URL="$GITEA_URL/$REPO/raw/branch/$BRANCH/custom_components/mcp_bridge/manifest.json"
|
|
echo " URL: $TEST_URL"
|
|
|
|
TEMP_FILE="/tmp/mcp_test_$$"
|
|
if curl -fsSL "$TEST_URL" -o "$TEMP_FILE" 2>/dev/null; then
|
|
echo " ✓ Successfully downloaded test file"
|
|
echo " File size: $(wc -c < "$TEMP_FILE") bytes"
|
|
echo " First line: $(head -n 1 "$TEMP_FILE")"
|
|
rm "$TEMP_FILE"
|
|
else
|
|
echo " ✗ Failed to download test file"
|
|
echo " Possible issues:"
|
|
echo " - Wrong repository name or path"
|
|
echo " - Wrong branch name"
|
|
echo " - File doesn't exist at that path"
|
|
echo " - Network/firewall blocking"
|
|
fi
|
|
echo ""
|
|
|
|
# 7. Check existing installation
|
|
echo "7. Checking for existing installation..."
|
|
INSTALL_DIR="$CONFIG_DIR/custom_components/mcp_bridge"
|
|
if [ -d "$INSTALL_DIR" ]; then
|
|
echo " ✓ Installation directory exists: $INSTALL_DIR"
|
|
echo " Files:"
|
|
ls -lh "$INSTALL_DIR" 2>/dev/null || echo " (empty or cannot list)"
|
|
|
|
if [ -f "$INSTALL_DIR/manifest.json" ]; then
|
|
VERSION=$(grep -oP '"version":\s*"\K[^"]+' "$INSTALL_DIR/manifest.json" 2>/dev/null || echo "unknown")
|
|
echo " Current version: $VERSION"
|
|
fi
|
|
else
|
|
echo " ! Installation directory does not exist yet"
|
|
fi
|
|
echo ""
|
|
|
|
# 8. Provide installation command
|
|
echo "8. Suggested installation command:"
|
|
echo ""
|
|
echo " export GITEA_URL=\"$GITEA_URL\""
|
|
echo " export REPO=\"$REPO\""
|
|
echo " export BRANCH=\"$BRANCH\""
|
|
echo " curl -fsSL \"\$GITEA_URL/\$REPO/raw/branch/\$BRANCH/quick_install.sh\" | bash"
|
|
echo ""
|
|
echo "=== Diagnostic Complete ==="
|
|
echo ""
|
|
echo "If all checks passed, run the installation command above."
|
|
echo "If checks failed, fix the issues indicated and try again." |