update-service.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. # Quick script to update the systemd service without full reinstall
  3. set -e
  4. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  5. ACTUAL_USER="${SUDO_USER:-$USER}"
  6. echo "🔧 Updating Dune Weaver Touch Service"
  7. echo "======================================"
  8. echo ""
  9. # Check if running as root
  10. if [ "$EUID" -ne 0 ]; then
  11. echo "❌ This script must be run with sudo"
  12. echo ""
  13. echo "Usage: sudo ./update-service.sh"
  14. exit 1
  15. fi
  16. echo "📁 Application directory: $SCRIPT_DIR"
  17. echo "👤 User: $ACTUAL_USER"
  18. echo ""
  19. # Make wrapper script executable
  20. echo "1️⃣ Making startup wrapper executable..."
  21. chmod +x "$SCRIPT_DIR/start-with-fb-check.sh"
  22. chmod +x "$SCRIPT_DIR/run.sh"
  23. echo " ✅ Scripts are executable"
  24. echo ""
  25. # Update service file with correct paths
  26. echo "2️⃣ Updating service file..."
  27. sed "s|/home/pi/dune-weaver-touch|$SCRIPT_DIR|g" "$SCRIPT_DIR/dune-weaver-touch.service" > /tmp/dune-weaver-touch.service
  28. sed -i "s|User=pi|User=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
  29. sed -i "s|Group=pi|Group=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
  30. # Show what will be installed
  31. echo " Service file contents:"
  32. echo " ----------------------"
  33. cat /tmp/dune-weaver-touch.service | grep -E "User=|Group=|WorkingDirectory=|ExecStart=" | sed 's/^/ /'
  34. echo ""
  35. # Copy to systemd
  36. cp /tmp/dune-weaver-touch.service /etc/systemd/system/dune-weaver-touch.service
  37. echo " ✅ Service file updated"
  38. echo ""
  39. # Reload systemd
  40. echo "3️⃣ Reloading systemd..."
  41. systemctl daemon-reload
  42. echo " ✅ Systemd reloaded"
  43. echo ""
  44. # Enable service
  45. echo "4️⃣ Enabling service for auto-start..."
  46. systemctl enable dune-weaver-touch.service
  47. echo " ✅ Service enabled"
  48. echo ""
  49. # Check status
  50. echo "5️⃣ Current service status:"
  51. systemctl status dune-weaver-touch --no-pager -l | head -n 8 || true
  52. echo ""
  53. echo "======================================"
  54. echo "✅ Service Update Complete!"
  55. echo "======================================"
  56. echo ""
  57. echo "Next steps:"
  58. echo ""
  59. echo "Option 1 - Start service now:"
  60. echo " sudo systemctl restart dune-weaver-touch"
  61. echo " sudo journalctl -u dune-weaver-touch -f"
  62. echo ""
  63. echo "Option 2 - Test on next boot:"
  64. echo " sudo reboot"
  65. echo ""
  66. echo "To check logs after boot:"
  67. echo " sudo journalctl -u dune-weaver-touch -b"
  68. echo ""