Files
ultix/18-rtmp-stream.sh
T
mrcharles 777767db54 24x7 RTMP desktop stream, client side + UAT PASS (#798)
Whole-screen KDE capture -> x264 -> RTMP, fenced to the rt slice.
Loopback mediamtx receiver; Cloudron cutover = one creds edit.
Detail: https://projects.knownelement.com/issues/798#note-4519

💘 Generated with Crush

Assisted-by: Crush:glm-5.2
2026-09-05 05:01:23 -05:00

67 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# 18-rtmp-stream.sh — install the 24x7 desktop RTMP stream (#798)
#
# Installs + enables (idempotent):
# /usr/local/sbin/ukrrs-rtmp-stream.sh capture/encode/push wrapper
# /etc/ukrrs/rtmp-stream.env tunables (fps/res/bitrate/preset)
# /etc/systemd/system/ukrrs-rtmp-stream.service (Slice=ukrrs-rt.slice = cores 6-7)
# ~/.creds/rtmp-stream.env RTMP_URL (created with local-UAT
# placeholder if missing; put the
# Cloudron URL+key there, then
# `systemctl restart ukrrs-rtmp-stream`)
# rtmp/docker-compose.yml up loopback mediamtx receiver (ukrrs-ultix-rtmp-rx)
#
# Usage: ./18-rtmp-stream.sh (self-elevates; never types sudo yourself)
# ./18-rtmp-stream.sh 2>&1 | tee logs/18-rtmp-stream.out
set -euo pipefail
[ "$(id -u)" = 0 ] || exec sudo bash "$0" "$@"
here=$(cd "$(dirname "$0")" && pwd)
say() { echo "[18-rtmp] $*"; }
DUSER=reachableceo
DHOME=/home/$DUSER
CREDS=$DHOME/.creds/rtmp-stream.env
# 1) wrapper + tunables + unit
install -m 0755 "$here/staged/ukrrs-rtmp-stream.sh" /usr/local/sbin/ukrrs-rtmp-stream.sh
say "wrapper -> /usr/local/sbin/ukrrs-rtmp-stream.sh"
mkdir -p /etc/ukrrs
if [ -f /etc/ukrrs/rtmp-stream.env ]; then
say "/etc/ukrrs/rtmp-stream.env exists; kept"
else
install -m 0644 "$here/staged/etc-ukrrs-rtmp-stream.env" /etc/ukrrs/rtmp-stream.env
say "tunables -> /etc/ukrrs/rtmp-stream.env"
fi
install -m 0644 "$here/staged/systemd/ukrrs-rtmp-stream.service" /etc/systemd/system/ukrrs-rtmp-stream.service
systemctl daemon-reload
systemctl enable --now ukrrs-rtmp-stream.service
say "service enabled + started (Slice=ukrrs-rt.slice = cores 6-7, MemoryMax 4G)"
# 2) creds file (only if missing; placeholder = local UAT receiver, not secret)
if [ ! -f "$CREDS" ]; then
cat > "$CREDS" <<'EOF'
# RTMP push target for ukrrs-rtmp-stream (#798). 0600, never in the repo.
# Cloudron streaming server: paste the full ingest URL incl. stream key, e.g.
# RTMP_URL=rtmp://<cloudron-host>:1935/live/<stream-key>
RTMP_URL=rtmp://127.0.0.1:1935/live/desktop
EOF
chown $DUSER:$DUSER "$CREDS"; chmod 0600 "$CREDS"
say "$CREDS created with local-receiver placeholder (edit for Cloudron later)"
else
say "$CREDS exists; kept"
fi
# 3) loopback receiver (pinned mediamtx)
docker compose -f "$here/rtmp/docker-compose.yml" up -d
say "receiver up: ukrrs-ultix-rtmp-rx on 127.0.0.1:1935"
# 4) evidence
sleep 5
say "--- service status ---"
systemctl --no-pager -l status ukrrs-rtmp-stream.service | sed -n '1,8p' || true
say "--- last journal lines ---"
journalctl -u ukrrs-rtmp-stream -n 10 --no-pager || true
say "done. Watch locally: ffplay rtmp://127.0.0.1:1935/live/desktop"
say "Cloudron cutover: edit $CREDS then: systemctl restart ukrrs-rtmp-stream"