From 1a07538253b49a1e12df144f2c005898d52be99f Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 24 Nov 2022 10:12:59 -0500 Subject: restream, go back to old mount structure --- roles/obs/templates/start-background-music | 5 +++++ roles/stream/tasks/main.yml | 15 +++++++++++++++ roles/stream/templates/icecast.xml | 8 ++++---- roles/stream/templates/restream.sh | 1 + roles/stream/templates/screen-restream.sh | 10 ++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 roles/obs/templates/start-background-music create mode 100755 roles/stream/templates/screen-restream.sh diff --git a/roles/obs/templates/start-background-music b/roles/obs/templates/start-background-music new file mode 100755 index 0000000..af28208 --- /dev/null +++ b/roles/obs/templates/start-background-music @@ -0,0 +1,5 @@ +if screen -list | grep -q background; then + echo "Already running in screen, attach with screen -x background" +else + screen -S background /bin/bash -c "mpv ~/stream/background.wav --loop=yes" +fi diff --git a/roles/stream/tasks/main.yml b/roles/stream/tasks/main.yml index 941ac92..b2bbc69 100644 --- a/roles/stream/tasks/main.yml +++ b/roles/stream/tasks/main.yml @@ -1,3 +1,8 @@ +- name: Install at for scheduling commands + become: true + package: + name: at + state: present - name: Install Icecast become: true package: @@ -62,3 +67,13 @@ owner: orga mode: 0755 loop: "{{ restreaming_platforms | subelements('streams') | list }}" + no_log: True +- name: Set up restream scripts + tags: restream + template: + src: screen-restream.sh + dest: /home/orga/screen-restream-{{ item[1].name }}-{{ item[0].name }}.sh + owner: orga + mode: 0755 + loop: "{{ restreaming_platforms | subelements('streams') | list }}" + no_log: True diff --git a/roles/stream/templates/icecast.xml b/roles/stream/templates/icecast.xml index cf6ec41..37e1a0a 100644 --- a/roles/stream/templates/icecast.xml +++ b/roles/stream/templates/icecast.xml @@ -169,7 +169,7 @@
- /home/icecast/bin/stream-start + /home/icecast/bin/stream-startg /home/icecast/bin/stream-stop --> @@ -189,7 +189,7 @@ --> {% for track in emacsconf_tracks %} - /{{ track.id }}.webm + /{{ emacsconf_id }}/{{ track.id }}.webm {{ icecast_emacsconf_user }} {{ icecast_emacsconf_password }} {% if icecast_save_dump %}/data/{{ emacsconf_id }}-{{ emacsconf_year }}-{{ track.id }}_%Y-%m-%d_%H-%M-%S.webm{% endif %} @@ -202,7 +202,7 @@ /usr/local/bin/{{ emacsconf_id }}-lowres-{{ track.id }}-on-disconnect - /{{ track.id }}-host.webm + /{{ emacsconf_id }}/{{ track.id }}-host.webm {{ icecast_emacsconf_user }} {{ icecast_emacsconf_password }} EmacsConf {{ emacsconf_year }} - {{ track.name }} track @@ -213,7 +213,7 @@ 1 - /{{ track.id }}-480p.webm + /{{ emacsconf_id }}/{{ track.id }}-480p.webm {{ icecast_emacsconf_user }} {{ icecast_emacsconf_password }} {{ emacsconf_name }} {{ emacsconf_year }} - {{ track.name }} track (480p) diff --git a/roles/stream/templates/restream.sh b/roles/stream/templates/restream.sh index e1d0a7f..81970c7 100755 --- a/roles/stream/templates/restream.sh +++ b/roles/stream/templates/restream.sh @@ -1,5 +1,6 @@ #!/bin/bash # {{ ansible_managed }} +# echo $$ > /tmp/restream-{{ item[1].key }}.pid MOUNT={{ item[0].stream_url }}/{{ item[1].key }} # rtmp://..../stream_key LOGLEVEL="${LOGLEVEL:-24}" for i in 1 2 3 4 5; do diff --git a/roles/stream/templates/screen-restream.sh b/roles/stream/templates/screen-restream.sh new file mode 100755 index 0000000..7466c48 --- /dev/null +++ b/roles/stream/templates/screen-restream.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# {{ ansible_managed }} + +SCREEN_NAME=restream-{{ item[1].name }}-{{ item[0].name }} +if screen -S $SCREEN_NAME -Q select ; then + echo "Already restreaming; screen -S $SCREEN_NAME -X quit if you need to restart" +else + screen -dmS $SCREEN_NAME /home/{{ emacsconf_user }}/restream-{{ item[1].name }}-{{ item[0].name }}e.sh + echo "Started screen; connect with screen -x $SCREEN_NAME" +fi -- cgit v1.2.3