#!/usr/bin/env bash # Installa slate + relay-agent su un CPX giĆ  provisionato (una tantum, non per ogni diretta). # STREAM_NODE_HOST=116.203.217.194 bash scripts/deploy/bootstrap_stream_node.sh set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" HOST="${STREAM_NODE_HOST:?Imposta STREAM_NODE_HOST (IPv4 pubblico del CPX)}" SSH_KEY="${STREAM_NODE_SSH_KEY_HOST:-$HOME/.ssh/matchlivetv_stream_hetzner}" SECRET="${STREAM_NODE_AGENT_SECRET:-mediamtx_webhook_dev_secret}" SSH=(ssh -i "$SSH_KEY" -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o IdentitiesOnly=yes "root@$HOST") SCP=(scp -i "$SSH_KEY" -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o IdentitiesOnly=yes) if [[ ! -f "$ROOT/infra/slates/offline.mp4" ]]; then (cd "$ROOT/infra" && bash scripts/generate_slate.sh) fi "${SSH[@]}" "apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 fonts-dejavu-core ffmpeg >/dev/null" "${SSH[@]}" "mkdir -p /opt/stream-node /slates /var/log" "${SCP[@]}" "$ROOT/infra/stream-node/relay-agent.py" "root@$HOST:/opt/stream-node/relay-agent.py" "${SCP[@]}" "$ROOT/infra/slates/offline.mp4" "root@$HOST:/slates/offline.mp4" "${SSH[@]}" "chmod 755 /opt/stream-node/relay-agent.py" "${SSH[@]}" "cat >/opt/stream-node/agent.env </etc/systemd/system/mltv-relay-agent.service <<'EOF' [Unit] Description=Match Live TV YouTube relay agent After=network-online.target [Service] Type=simple EnvironmentFile=/opt/stream-node/agent.env ExecStart=/usr/bin/python3 /opt/stream-node/relay-agent.py Restart=always RestartSec=2 [Install] WantedBy=multi-user.target EOF pkill -f 'ffmpeg -nostdin' || true systemctl daemon-reload systemctl enable --now mltv-relay-agent.service systemctl restart mltv-relay-agent.service curl -fsS http://127.0.0.1:9100/health" echo "bootstrap ok host=${HOST}"