tuanchris 4 ヶ月 前
コミット
4db2faecb8

+ 142 - 0
dune-weaver-touch/diagnose-boot.sh

@@ -0,0 +1,142 @@
+#!/bin/bash
+# Diagnostic script to check boot auto-start issues
+
+echo "=========================================="
+echo "Dune Weaver Touch Boot Diagnostics"
+echo "=========================================="
+echo ""
+
+# Check if service file is installed
+echo "1. Service Installation:"
+if [ -f /etc/systemd/system/dune-weaver-touch.service ]; then
+    echo "   ✅ Service file exists"
+    echo "   Path: /etc/systemd/system/dune-weaver-touch.service"
+else
+    echo "   ❌ Service file NOT found!"
+fi
+echo ""
+
+# Check if service is enabled
+echo "2. Service Enabled Status:"
+if systemctl is-enabled dune-weaver-touch >/dev/null 2>&1; then
+    echo "   ✅ Service is enabled for auto-start"
+else
+    echo "   ❌ Service is NOT enabled!"
+    echo "   Run: sudo systemctl enable dune-weaver-touch"
+fi
+echo ""
+
+# Check service status
+echo "3. Current Service Status:"
+systemctl status dune-weaver-touch --no-pager -l | head -n 10
+echo ""
+
+# Check framebuffer device
+echo "4. Framebuffer Device:"
+if [ -c /dev/fb0 ]; then
+    echo "   ✅ /dev/fb0 exists"
+    ls -la /dev/fb0
+    if command -v fbset >/dev/null 2>&1; then
+        echo ""
+        echo "   Framebuffer info:"
+        fbset -fb /dev/fb0 2>&1 | head -n 5
+    fi
+else
+    echo "   ❌ /dev/fb0 NOT found!"
+fi
+echo ""
+
+# Check wrapper script
+echo "5. Startup Wrapper Script:"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+if [ -f "$SCRIPT_DIR/start-with-fb-check.sh" ]; then
+    echo "   ✅ Wrapper script exists"
+    ls -la "$SCRIPT_DIR/start-with-fb-check.sh"
+    if [ -x "$SCRIPT_DIR/start-with-fb-check.sh" ]; then
+        echo "   ✅ Wrapper is executable"
+    else
+        echo "   ❌ Wrapper is NOT executable!"
+        echo "   Run: chmod +x $SCRIPT_DIR/start-with-fb-check.sh"
+    fi
+else
+    echo "   ❌ Wrapper script NOT found!"
+fi
+echo ""
+
+# Check service logs
+echo "6. Recent Service Logs (last 20 lines):"
+echo "   ----------------------------------------"
+sudo journalctl -u dune-weaver-touch -n 20 --no-pager
+echo ""
+
+# Check boot logs
+echo "7. Service Logs from Last Boot:"
+echo "   ----------------------------------------"
+sudo journalctl -u dune-weaver-touch -b --no-pager | tail -n 30
+echo ""
+
+# Check Python and venv
+echo "8. Python Virtual Environment:"
+if [ -d "$SCRIPT_DIR/venv" ]; then
+    echo "   ✅ Virtual environment exists"
+    if [ -f "$SCRIPT_DIR/venv/bin/python" ]; then
+        echo "   ✅ Python binary exists"
+        echo "   Version: $("$SCRIPT_DIR/venv/bin/python" --version)"
+    else
+        echo "   ❌ Python binary NOT found in venv!"
+    fi
+else
+    echo "   ❌ Virtual environment NOT found!"
+    echo "   Run: sudo ./install.sh"
+fi
+echo ""
+
+# Check main.py
+echo "9. Application Files:"
+if [ -f "$SCRIPT_DIR/main.py" ]; then
+    echo "   ✅ main.py exists"
+else
+    echo "   ❌ main.py NOT found!"
+fi
+echo ""
+
+# Recommendations
+echo "=========================================="
+echo "Recommendations:"
+echo "=========================================="
+
+# Check if any critical issues
+ISSUES=0
+
+if ! systemctl is-enabled dune-weaver-touch >/dev/null 2>&1; then
+    echo "❌ Enable the service: sudo systemctl enable dune-weaver-touch"
+    ISSUES=$((ISSUES + 1))
+fi
+
+if [ ! -x "$SCRIPT_DIR/start-with-fb-check.sh" ]; then
+    echo "❌ Make wrapper executable: chmod +x $SCRIPT_DIR/start-with-fb-check.sh"
+    ISSUES=$((ISSUES + 1))
+fi
+
+if [ ! -d "$SCRIPT_DIR/venv" ]; then
+    echo "❌ Reinstall: sudo ./install.sh"
+    ISSUES=$((ISSUES + 1))
+fi
+
+if systemctl is-failed dune-weaver-touch >/dev/null 2>&1; then
+    echo "⚠️  Service has failed - check logs above"
+    echo "   Try: sudo systemctl restart dune-weaver-touch"
+    ISSUES=$((ISSUES + 1))
+fi
+
+if [ $ISSUES -eq 0 ]; then
+    echo "✅ No critical issues detected"
+    echo ""
+    echo "If auto-start still doesn't work:"
+    echo "1. Check logs: sudo journalctl -u dune-weaver-touch -b"
+    echo "2. Try manual start: sudo systemctl start dune-weaver-touch"
+    echo "3. Check for errors in output above"
+fi
+
+echo ""
+echo "=========================================="

+ 7 - 4
dune-weaver-touch/dune-weaver-touch.service

@@ -16,11 +16,14 @@ Environment=QT_QPA_FB_DRM=1
 Environment=QT_QPA_FONTDIR=/usr/share/fonts
 # Use wrapper script that checks for framebuffer availability
 ExecStart=/home/pi/dune-weaver-touch/start-with-fb-check.sh
-Restart=always
-RestartSec=5
+Restart=on-failure
+RestartSec=10
 # Limit restart attempts on boot
-StartLimitBurst=5
-StartLimitIntervalSec=60
+StartLimitBurst=3
+StartLimitIntervalSec=120
+# Add detailed logging
+StandardOutput=journal
+StandardError=journal
 
 [Install]
 WantedBy=graphical.target

+ 81 - 0
dune-weaver-touch/update-service.sh

@@ -0,0 +1,81 @@
+#!/bin/bash
+# Quick script to update the systemd service without full reinstall
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ACTUAL_USER="${SUDO_USER:-$USER}"
+
+echo "🔧 Updating Dune Weaver Touch Service"
+echo "======================================"
+echo ""
+
+# Check if running as root
+if [ "$EUID" -ne 0 ]; then
+    echo "❌ This script must be run with sudo"
+    echo ""
+    echo "Usage: sudo ./update-service.sh"
+    exit 1
+fi
+
+echo "📁 Application directory: $SCRIPT_DIR"
+echo "👤 User: $ACTUAL_USER"
+echo ""
+
+# Make wrapper script executable
+echo "1️⃣  Making startup wrapper executable..."
+chmod +x "$SCRIPT_DIR/start-with-fb-check.sh"
+chmod +x "$SCRIPT_DIR/run.sh"
+echo "   ✅ Scripts are executable"
+echo ""
+
+# Update service file with correct paths
+echo "2️⃣  Updating service file..."
+sed "s|/home/pi/dune-weaver-touch|$SCRIPT_DIR|g" "$SCRIPT_DIR/dune-weaver-touch.service" > /tmp/dune-weaver-touch.service
+sed -i "s|User=pi|User=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
+sed -i "s|Group=pi|Group=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
+
+# Show what will be installed
+echo "   Service file contents:"
+echo "   ----------------------"
+cat /tmp/dune-weaver-touch.service | grep -E "User=|Group=|WorkingDirectory=|ExecStart=" | sed 's/^/   /'
+echo ""
+
+# Copy to systemd
+cp /tmp/dune-weaver-touch.service /etc/systemd/system/dune-weaver-touch.service
+echo "   ✅ Service file updated"
+echo ""
+
+# Reload systemd
+echo "3️⃣  Reloading systemd..."
+systemctl daemon-reload
+echo "   ✅ Systemd reloaded"
+echo ""
+
+# Enable service
+echo "4️⃣  Enabling service for auto-start..."
+systemctl enable dune-weaver-touch.service
+echo "   ✅ Service enabled"
+echo ""
+
+# Check status
+echo "5️⃣  Current service status:"
+systemctl status dune-weaver-touch --no-pager -l | head -n 8 || true
+echo ""
+
+echo "======================================"
+echo "✅ Service Update Complete!"
+echo "======================================"
+echo ""
+echo "Next steps:"
+echo ""
+echo "Option 1 - Start service now:"
+echo "  sudo systemctl restart dune-weaver-touch"
+echo "  sudo journalctl -u dune-weaver-touch -f"
+echo ""
+echo "Option 2 - Test on next boot:"
+echo "  sudo reboot"
+echo ""
+echo "To check logs after boot:"
+echo "  sudo journalctl -u dune-weaver-touch -b"
+echo ""