mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-15 10:03:31 +00:00
config_service.py: replace MD5 with SHA-256 for config change detection; same semantics (equality comparison), no stored hashes affected. Shell scripts — shellcheck warnings: - diagnose_web_interface.sh: remove useless cat (SC2002) - dev_plugin_setup.sh: restructure A&&B||C into if/then (SC2015) - fix_assets_permissions.sh: remove unused REAL_HOME block (SC2034) - install_web_service.sh: remove unused USER_HOME assignment (SC2034) - diagnose_web_ui.sh: remove unused SUDO assignments (SC2034) - diagnose_plugin_permissions.sh: remove unused BLUE color var (SC2034) - first_time_install.sh: remove unused CLEAR var, PACKAGE_NAME assignment, and replace loop variable with _ (SC2034) docs/PLUGIN_ARCHITECTURE_SPEC.md: fix 10 broken TOC anchor links to include section numbers matching the actual headings (MD051). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
192 lines
6.8 KiB
Bash
Executable File
192 lines
6.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# LEDMatrix Web UI Diagnostic Script
|
|
# Run this on your Raspberry Pi to diagnose web UI startup issues
|
|
|
|
set -e
|
|
|
|
echo "=========================================="
|
|
echo "LEDMatrix Web UI Diagnostic Report"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if running as root or with sudo
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo -e "${YELLOW}Warning: Some checks require sudo. Running what we can...${NC}"
|
|
fi
|
|
|
|
PROJECT_DIR="${HOME}/LEDMatrix"
|
|
|
|
echo "1. Checking service status..."
|
|
echo "------------------------------"
|
|
if systemctl is-active --quiet ledmatrix-web 2>/dev/null || sudo systemctl is-active --quiet ledmatrix-web 2>/dev/null; then
|
|
echo -e "${GREEN}✓ Service is ACTIVE${NC}"
|
|
STATUS=$(sudo systemctl status ledmatrix-web --no-pager -l | head -n 3)
|
|
echo "$STATUS"
|
|
else
|
|
echo -e "${RED}✗ Service is NOT running${NC}"
|
|
sudo systemctl status ledmatrix-web --no-pager -l | head -n 10 || echo "Service may not be installed"
|
|
fi
|
|
echo ""
|
|
|
|
echo "2. Checking if service is enabled..."
|
|
echo "------------------------------"
|
|
if systemctl is-enabled --quiet ledmatrix-web 2>/dev/null || sudo systemctl is-enabled --quiet ledmatrix-web 2>/dev/null; then
|
|
echo -e "${GREEN}✓ Service is enabled to start on boot${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ Service is NOT enabled (won't start on boot)${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "3. Checking configuration file..."
|
|
echo "------------------------------"
|
|
if [ -f "${PROJECT_DIR}/config/config.json" ]; then
|
|
echo -e "${GREEN}✓ Config file exists${NC}"
|
|
AUTOSTART=$(grep -o '"web_display_autostart":\s*\(true\|false\)' "${PROJECT_DIR}/config/config.json" | grep -o '\(true\|false\)' || echo "not found")
|
|
if [ "$AUTOSTART" = "true" ]; then
|
|
echo -e "${GREEN}✓ web_display_autostart is set to TRUE${NC}"
|
|
elif [ "$AUTOSTART" = "false" ]; then
|
|
echo -e "${RED}✗ web_display_autostart is set to FALSE (web UI won't start!)${NC}"
|
|
echo " Fix: Edit config.json and set 'web_display_autostart': true"
|
|
else
|
|
echo -e "${YELLOW}⚠ web_display_autostart setting not found (defaults to false)${NC}"
|
|
echo " Fix: Add 'web_display_autostart': true to config.json"
|
|
fi
|
|
else
|
|
echo -e "${RED}✗ Config file NOT FOUND at ${PROJECT_DIR}/config/config.json${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "4. Checking recent service logs..."
|
|
echo "------------------------------"
|
|
RECENT_LOGS=$(sudo journalctl -u ledmatrix-web -n 30 --no-pager 2>/dev/null || echo "No logs available")
|
|
if [ -n "$RECENT_LOGS" ] && [ "$RECENT_LOGS" != "No logs available" ]; then
|
|
echo "$RECENT_LOGS"
|
|
echo ""
|
|
echo "Key messages from logs:"
|
|
echo "$RECENT_LOGS" | grep -i "web_display_autostart\|Configuration\|Launching\|will not\|Failed\|Error\|Starting" || echo " (no key messages found)"
|
|
else
|
|
echo -e "${YELLOW}⚠ No recent logs found${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "5. Checking web interface files..."
|
|
echo "------------------------------"
|
|
FILES_TO_CHECK=(
|
|
"scripts/utils/start_web_conditionally.py"
|
|
"web_interface/start.py"
|
|
"web_interface/app.py"
|
|
"web_interface/requirements.txt"
|
|
"web_interface/blueprints/api_v3.py"
|
|
"web_interface/blueprints/pages_v3.py"
|
|
)
|
|
|
|
for file in "${FILES_TO_CHECK[@]}"; do
|
|
if [ -f "${PROJECT_DIR}/${file}" ]; then
|
|
echo -e "${GREEN}✓ ${file}${NC}"
|
|
else
|
|
echo -e "${RED}✗ ${file} MISSING${NC}"
|
|
fi
|
|
done
|
|
echo ""
|
|
|
|
echo "6. Checking Python import test..."
|
|
echo "------------------------------"
|
|
cd "${PROJECT_DIR}" 2>/dev/null || {
|
|
echo -e "${RED}✗ Cannot access project directory: ${PROJECT_DIR}${NC}"
|
|
echo ""
|
|
exit 1
|
|
}
|
|
|
|
if python3 -c "from web_interface.app import app; print('OK')" 2>&1; then
|
|
echo -e "${GREEN}✓ Flask app imports successfully${NC}"
|
|
else
|
|
echo -e "${RED}✗ Flask app import FAILED${NC}"
|
|
echo " Error details:"
|
|
python3 -c "from web_interface.app import app; print('OK')" 2>&1 | head -n 10
|
|
fi
|
|
echo ""
|
|
|
|
echo "7. Checking port 5000 availability..."
|
|
echo "------------------------------"
|
|
if command -v lsof &> /dev/null; then
|
|
PORT_CHECK=$(sudo lsof -i :5000 2>/dev/null || echo "")
|
|
if [ -z "$PORT_CHECK" ]; then
|
|
echo -e "${GREEN}✓ Port 5000 is available${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ Port 5000 is in use:${NC}"
|
|
echo "$PORT_CHECK"
|
|
fi
|
|
elif command -v ss &> /dev/null; then
|
|
PORT_CHECK=$(sudo ss -tlnp | grep :5000 || echo "")
|
|
if [ -z "$PORT_CHECK" ]; then
|
|
echo -e "${GREEN}✓ Port 5000 is available${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ Port 5000 is in use:${NC}"
|
|
echo "$PORT_CHECK"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠ Cannot check port (lsof/ss not available)${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "8. Checking service file..."
|
|
echo "------------------------------"
|
|
if [ -f "/etc/systemd/system/ledmatrix-web.service" ]; then
|
|
echo -e "${GREEN}✓ Service file exists${NC}"
|
|
echo " Location: /etc/systemd/system/ledmatrix-web.service"
|
|
echo " WorkingDirectory: $(grep WorkingDirectory /etc/systemd/system/ledmatrix-web.service | cut -d'=' -f2 || echo 'not found')"
|
|
echo " ExecStart: $(grep ExecStart /etc/systemd/system/ledmatrix-web.service | cut -d'=' -f2 || echo 'not found')"
|
|
else
|
|
echo -e "${RED}✗ Service file NOT FOUND${NC}"
|
|
echo " Run: sudo ./install_web_service.sh (if available)"
|
|
fi
|
|
echo ""
|
|
|
|
echo "9. Checking dependencies..."
|
|
echo "------------------------------"
|
|
if [ -f "${PROJECT_DIR}/web_interface/requirements.txt" ]; then
|
|
echo "Checking if Flask is installed..."
|
|
if python3 -c "import flask; print(f'Flask {flask.__version__}')" 2>/dev/null; then
|
|
echo -e "${GREEN}✓ Flask is installed${NC}"
|
|
else
|
|
echo -e "${RED}✗ Flask is NOT installed${NC}"
|
|
echo " Run: pip3 install --break-system-packages -r web_interface/requirements.txt"
|
|
fi
|
|
else
|
|
echo -e "${YELLOW}⚠ requirements.txt not found${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
echo "10. Manual startup test (dry run)..."
|
|
echo "------------------------------"
|
|
echo "To test manual startup, run:"
|
|
echo " cd ${PROJECT_DIR}"
|
|
echo " python3 web_interface/start.py"
|
|
echo ""
|
|
|
|
echo "=========================================="
|
|
echo "Diagnostic Summary"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Most common issues:"
|
|
echo " 1. web_display_autostart is false or missing in config.json"
|
|
echo " 2. Service not enabled or not started"
|
|
echo " 3. Missing dependencies (Flask, etc.)"
|
|
echo " 4. Import errors in web_interface/app.py"
|
|
echo " 5. Port 5000 already in use"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " - Review the checks above for any RED ✗ marks"
|
|
echo " - Check recent logs: sudo journalctl -u ledmatrix-web -n 50 --no-pager"
|
|
echo " - Follow logs in real-time: sudo journalctl -u ledmatrix-web -f"
|
|
echo " - Try manual start: cd ${PROJECT_DIR} && python3 web_interface/start.py"
|
|
echo ""
|
|
echo "=========================================="
|
|
|