From 930b48340d05ef34faa548e68fbdce7928431f82 Mon Sep 17 00:00:00 2001 From: legop3 Date: Fri, 14 Nov 2025 21:37:25 -0500 Subject: [PATCH] update server installer --- README.md | 11 ++--------- docs/pi-deployment.md | 5 +++-- server/install_server.sh | 28 ++++++---------------------- server/mediamtx/mediamtx.yml | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 server/mediamtx/mediamtx.yml diff --git a/README.md b/README.md index 7830467d..54f45d41 100644 --- a/README.md +++ b/README.md @@ -74,17 +74,10 @@ The script must be executed via `sudo` from the user that owns the repo. It will - run `npm install --production` - copy `config.example.yaml` to `config.yaml` if needed (edit the file afterwards for admins + `media.whepBaseUrl`) - download mediaMTX v1.15.3 and drop it into `/usr/local/bin` -- write `/etc/mediamtx/mediamtx.yml` that points to the Node server’s `/mediamtx/auth` webhook +- write `/etc/mediamtx/mediamtx.yml` from `server/mediamtx/mediamtx.yml` (SRT ingest on :9000, wildcard `rover-*` paths, auth webhook at `/mediamtx/auth`) - create + enable `mediamtx.service` and `multirover.service`, both running as your repo user and pointing at the clone directly -Publishing rovers lives on a trusted network, so the generated config skips HTTP auth for the `publish` action (only playback hits the Node webhook). If you already ran an older installer, edit `/etc/mediamtx/mediamtx.yml` and add: - -```yaml -authHTTPExclude: - - action: publish -``` - -Then restart `mediamtx.service` so WHIP pushes from the Pis stop getting rejected. +Publishing rovers lives on a trusted network, so the shipped config (tracked at `server/mediamtx/mediamtx.yml`) skips HTTP auth for SRT ingest and whitelists any path that matches `rover-*`. The installer overwrites `/etc/mediamtx/mediamtx.yml` every time you run it—if you need to tweak ports or add TURN servers, edit the template in the repo and rerun `install_server.sh` so every box stays in sync automatically. Once finished, update `server/config.yaml` with your admin passwords and `media.whepBaseUrl` (`http://192.168.0.86:8889/whep`). Restart `multirover.service` whenever you edit the config. To pull updates later, just `git pull`, re-run `npm install --production` inside `server/`, and restart the service—no need to rerun the installer. diff --git a/docs/pi-deployment.md b/docs/pi-deployment.md index 5355e981..b3ae32e9 100644 --- a/docs/pi-deployment.md +++ b/docs/pi-deployment.md @@ -62,6 +62,7 @@ Flags: If the script installs the sample config, it will remind you to edit `/etc/roverd.yaml` before manually restarting the service: set `name`, `serverUrl`, serial device, BRC pin, battery thresholds, and optionally override `media.publishUrl`. When left blank, roverd automatically publishes to `srt://:9000?streamid=#!::r=,m=publish…` (the host comes from `serverUrl`). +Re-run `pi/install_roverd.sh` any time you pull updates—the script overwrites the roverd + video-publisher binaries and drops the latest systemd units so the only configuration you ever touch manually is `/etc/roverd.yaml`. `roverd` rewrites `/var/lib/roverd/video.env` on startup, so no other files need editing. ## Manual installation 1. Copy the binary and config: @@ -70,7 +71,7 @@ If the script installs the sample config, it will remind you to edit `/etc/rover sudo install -o roverd -g roverd -m 0755 dist/roverd /usr/local/bin/roverd sudo install -o roverd -g roverd -m 0640 pi/roverd/roverd.sample.yaml /etc/roverd.yaml ``` - Adjust `/etc/roverd.yaml` for each rover: `name`, `serverUrl` (e.g. `ws://control-server:8080/rover`), serial port path, battery thresholds, GPIO pin for BRC, and (if needed) the media `whepUrl` override. Otherwise, roverd fills in `http://:8889/rovercam/whep` based on the DHCP-assigned address. + Adjust `/etc/roverd.yaml` for each rover: `name`, `serverUrl` (e.g. `ws://control-server:8080/rover`), serial port path, battery thresholds, GPIO pin for BRC, and (if needed) the media `publishUrl` override. Otherwise, roverd derives `srt://:9000?streamid=#!::r=,m=publish&latency=20&mode=caller&transtype=live&pkt_size=1316` based on the `serverUrl`. 2. Install the systemd unit: ```bash @@ -80,7 +81,7 @@ If the script installs the sample config, it will remind you to edit `/etc/rover ``` `roverd` requires access to `/dev/ttyAMA0` and `/dev/gpiochip*`; keeping it under its own user ensures the rest of the system stays isolated—just make sure the account belongs to the `dialout` and `gpio` groups so it can reach the UART and libgpiod. -The WHIP publisher needs read access to the camera devices (`/dev/media*`, `/dev/video*`), so the install script adds the `roverd` service account to the `video` group; if you created the user manually, make sure it belongs to `video`. +The video publisher needs read access to the camera devices (`/dev/media*`, `/dev/video*`), so the install script adds the `roverd` service account to the `video` group; if you created the user manually, make sure it belongs to `video`. **BRC note:** configure `brc.gpioPin` (and `brc.gpioChip` if you’re not using `gpiochip0`) and ensure the `roverd` user has permission to toggle that line—no root privileges are required anymore. If you set `media.manage: true` in `/etc/roverd.yaml`, make sure the `roverd` service account can invoke `systemctl ` (the installer wires `video-publisher.service` to run as `roverd`, so no sudo tweaks are required unless you rename it). diff --git a/server/install_server.sh b/server/install_server.sh index b2653cd2..cbccc8d1 100755 --- a/server/install_server.sh +++ b/server/install_server.sh @@ -23,6 +23,7 @@ TARGET_USER="$SUDO_USER" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) SERVER_DIR="$SCRIPT_DIR" CONFIG_PATH="$SERVER_DIR/config.yaml" +MEDIAMTX_TEMPLATE="$SERVER_DIR/mediamtx/mediamtx.yml" echo "[1/6] Installing dependencies..." dnf install -y nodejs npm curl tar >/dev/null @@ -63,28 +64,11 @@ tar -xzf "$tmpdir/mediamtx.tgz" -C "$tmpdir" mediamtx install -m 0755 "$tmpdir/mediamtx" "$MEDIAMTX_BIN" mkdir -p "$MEDIAMTX_CONF_DIR" -# if [[ ! -f "$MEDIAMTX_CONFIG" ]]; then -cat > "$MEDIAMTX_CONFIG" <<'CFG' -logLevel: info -api: yes -apiAddress: 0.0.0.0:9997 -webrtc: yes -webrtcLocalUDPAddress: :8189 -webrtcLocalTCPAddress: :8189 - -authMethod: http -authHTTPAddress: http://127.0.0.1:8080/mediamtx/auth -authHTTPExclude: - - action: publish - - action: api - - action: metrics - - action: pprof - -paths: - all: - source: publisher -CFG -# fi +if [[ ! -f "$MEDIAMTX_TEMPLATE" ]]; then + echo "mediaMTX template missing at $MEDIAMTX_TEMPLATE" >&2 + exit 1 +fi +install -m 0644 "$MEDIAMTX_TEMPLATE" "$MEDIAMTX_CONFIG" chown -R "$TARGET_USER":"$TARGET_USER" "$MEDIAMTX_CONF_DIR" echo "[4/6] Writing systemd units..." diff --git a/server/mediamtx/mediamtx.yml b/server/mediamtx/mediamtx.yml new file mode 100644 index 00000000..1cd6197e --- /dev/null +++ b/server/mediamtx/mediamtx.yml @@ -0,0 +1,31 @@ +logLevel: info + +api: yes +apiAddress: 0.0.0.0:9997 +metrics: yes +metricsAddress: 0.0.0.0:9998 +pprof: no +pprofAddress: 127.0.0.1:9999 + +rtsp: no +rtmp: no +hls: no + +webrtc: yes +webrtcLocalUDPAddress: :8189 +webrtcLocalTCPAddress: :8189 + +srt: yes +srtAddress: :9000 + +authMethod: http +authHTTPAddress: http://127.0.0.1:8080/mediamtx/auth +authHTTPExclude: + - action: publish + - action: api + - action: metrics + - action: pprof + +paths: + "~^rover-(?P[a-z0-9_-]+)$": + source: publisher