1
0

install-service.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Install Dune Weaver Touch as a systemd service
  3. # Check if running as root
  4. if [ "$EUID" -ne 0 ]; then
  5. echo "Please run as root (use sudo)"
  6. exit 1
  7. fi
  8. # Get the current directory
  9. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  10. APP_DIR="$SCRIPT_DIR"
  11. # Get the current user (the one who called sudo)
  12. ACTUAL_USER="${SUDO_USER:-$USER}"
  13. USER_HOME=$(eval echo ~$ACTUAL_USER)
  14. echo "Installing Dune Weaver Touch service..."
  15. echo "App directory: $APP_DIR"
  16. echo "User: $ACTUAL_USER"
  17. echo "User home: $USER_HOME"
  18. # Update paths in the service file
  19. sed "s|/home/pi/dune-weaver-touch|$APP_DIR|g" "$SCRIPT_DIR/dune-weaver-touch.service" > /tmp/dune-weaver-touch.service
  20. sed -i "s|User=pi|User=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
  21. sed -i "s|Group=pi|Group=$ACTUAL_USER|g" /tmp/dune-weaver-touch.service
  22. # Copy service file to systemd directory
  23. cp /tmp/dune-weaver-touch.service /etc/systemd/system/
  24. # Reload systemd
  25. systemctl daemon-reload
  26. # Enable the service
  27. systemctl enable dune-weaver-touch.service
  28. echo "✅ Service installed and enabled!"
  29. echo ""
  30. echo "Commands to manage the service:"
  31. echo " Start: sudo systemctl start dune-weaver-touch"
  32. echo " Stop: sudo systemctl stop dune-weaver-touch"
  33. echo " Status: sudo systemctl status dune-weaver-touch"
  34. echo " Logs: sudo journalctl -u dune-weaver-touch -f"
  35. echo ""
  36. echo "The app will now start automatically on boot."