install.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env bash
  2. set -e
  3. if [ "$EUID" -ne 0 ]; then
  4. echo "Please run as root"
  5. exit 1
  6. fi
  7. SERVICE="/etc/systemd/system/rtsp_multi_view.service"
  8. TARGET="/usr/local/bin/rtsp_multi_view"
  9. CONFIG_DIR="/etc/rtsp_multi_view"
  10. echo "Building..."
  11. make -C "$(dirname "$0")/build" -j$(nproc)
  12. echo "Installing binary..."
  13. cp "$(dirname "$0")/build/rtsp_multi_view" "$TARGET"
  14. chmod +x "$TARGET"
  15. echo "Installing auto_reboot.sh..."
  16. cp "$(dirname "$0")/auto_reboot.sh" /usr/local/bin/auto_reboot.sh
  17. chmod +x /usr/local/bin/auto_reboot.sh
  18. echo "Creating config directory..."
  19. mkdir -p "$CONFIG_DIR"
  20. if [ ! -f "$CONFIG_DIR/channels.conf" ]; then
  21. cp "$(dirname "$0")/channels.conf" "$CONFIG_DIR/channels.conf" 2>/dev/null || true
  22. echo "Created default config at $CONFIG_DIR/channels.conf"
  23. fi
  24. echo "Creating systemd service..."
  25. cat > "$SERVICE" << 'UNIT'
  26. [Unit]
  27. Description=RTSP Multi-View Display
  28. After=network.target
  29. [Service]
  30. Type=simple
  31. ExecStart=/usr/local/bin/rtsp_multi_view -c /etc/rtsp_multi_view/channels.conf
  32. Restart=always
  33. RestartSec=3
  34. Nice=-10
  35. [Install]
  36. WantedBy=multi-user.target
  37. UNIT
  38. echo "Creating auto-reboot service..."
  39. cat > /etc/systemd/system/auto-reboot.service << 'UNIT'
  40. [Unit]
  41. Description=Scheduled Auto Reboot
  42. After=network.target
  43. [Service]
  44. Type=simple
  45. ExecStart=/usr/local/bin/auto_reboot.sh -c /etc/rtsp_multi_view/channels.conf
  46. Restart=always
  47. RestartSec=5
  48. [Install]
  49. WantedBy=multi-user.target
  50. UNIT
  51. systemctl daemon-reload
  52. systemctl enable rtsp_multi_view auto-reboot
  53. systemctl restart rtsp_multi_view
  54. systemctl restart auto-reboot
  55. echo "Installed and started rtsp_multi_view + auto-reboot services."
  56. echo "Status: systemctl status rtsp_multi_view"
  57. echo "Reboot: systemctl status auto-reboot"
  58. echo "Logs: journalctl -u rtsp_multi_view -f"