| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #!/usr/bin/env bash
- set -e
- if [ "$EUID" -ne 0 ]; then
- echo "Please run as root"
- exit 1
- fi
- SERVICE="/etc/systemd/system/rtsp_multi_view.service"
- TARGET="/usr/local/bin/rtsp_multi_view"
- CONFIG_DIR="/etc/rtsp_multi_view"
- echo "Building..."
- make -C "$(dirname "$0")/build" -j$(nproc)
- echo "Installing binary..."
- cp "$(dirname "$0")/build/rtsp_multi_view" "$TARGET"
- chmod +x "$TARGET"
- echo "Installing auto_reboot.sh..."
- cp "$(dirname "$0")/auto_reboot.sh" /usr/local/bin/auto_reboot.sh
- chmod +x /usr/local/bin/auto_reboot.sh
- echo "Creating config directory..."
- mkdir -p "$CONFIG_DIR"
- if [ ! -f "$CONFIG_DIR/channels.conf" ]; then
- cp "$(dirname "$0")/channels.conf" "$CONFIG_DIR/channels.conf" 2>/dev/null || true
- echo "Created default config at $CONFIG_DIR/channels.conf"
- fi
- echo "Creating systemd service..."
- cat > "$SERVICE" << 'UNIT'
- [Unit]
- Description=RTSP Multi-View Display
- After=network.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/rtsp_multi_view -c /etc/rtsp_multi_view/channels.conf
- Restart=always
- RestartSec=3
- Nice=-10
- [Install]
- WantedBy=multi-user.target
- UNIT
- echo "Creating auto-reboot service..."
- cat > /etc/systemd/system/auto-reboot.service << 'UNIT'
- [Unit]
- Description=Scheduled Auto Reboot
- After=network.target
- [Service]
- Type=simple
- ExecStart=/usr/local/bin/auto_reboot.sh -c /etc/rtsp_multi_view/channels.conf
- Restart=always
- RestartSec=5
- [Install]
- WantedBy=multi-user.target
- UNIT
- systemctl daemon-reload
- systemctl enable rtsp_multi_view auto-reboot
- systemctl restart rtsp_multi_view
- systemctl restart auto-reboot
- echo "Installed and started rtsp_multi_view + auto-reboot services."
- echo "Status: systemctl status rtsp_multi_view"
- echo "Reboot: systemctl status auto-reboot"
- echo "Logs: journalctl -u rtsp_multi_view -f"
|