diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/etc/icecast2/icecast.xml.j2 (renamed from templates/icecast2/icecast.xml.j2) | 0 | ||||
-rw-r--r-- | templates/etc/icecast2/ices-playlist.xml.j2 (renamed from templates/icecast2/ices-playlist.xml.j2) | 0 | ||||
-rw-r--r-- | templates/etc/icecast2/mp3-to-ogg.sh.j2 (renamed from templates/icecast2/mp3-to-ogg.sh.j2) | 0 | ||||
-rw-r--r-- | templates/etc/nginx/nginx.conf.j2 (renamed from templates/nginx/nginx.conf.j2) | 0 | ||||
-rw-r--r-- | templates/etc/systemd/system/ices2.service (renamed from templates/systemd/system/ices2.service) | 0 | ||||
-rw-r--r-- | templates/etc/systemd/system/liquidsoap-radio.service | 17 | ||||
-rw-r--r-- | templates/srv/radio/create-playlist.sh.j2 | 22 | ||||
-rw-r--r-- | templates/srv/radio/radio.liq.j2 | 23 | ||||
-rw-r--r-- | templates/var/www/html/audio-controls.js | 5 |
9 files changed, 64 insertions, 3 deletions
diff --git a/templates/icecast2/icecast.xml.j2 b/templates/etc/icecast2/icecast.xml.j2 index ef6e539..ef6e539 100644 --- a/templates/icecast2/icecast.xml.j2 +++ b/templates/etc/icecast2/icecast.xml.j2 diff --git a/templates/icecast2/ices-playlist.xml.j2 b/templates/etc/icecast2/ices-playlist.xml.j2 index 89fc4c9..89fc4c9 100644 --- a/templates/icecast2/ices-playlist.xml.j2 +++ b/templates/etc/icecast2/ices-playlist.xml.j2 diff --git a/templates/icecast2/mp3-to-ogg.sh.j2 b/templates/etc/icecast2/mp3-to-ogg.sh.j2 index f475d36..f475d36 100644 --- a/templates/icecast2/mp3-to-ogg.sh.j2 +++ b/templates/etc/icecast2/mp3-to-ogg.sh.j2 diff --git a/templates/nginx/nginx.conf.j2 b/templates/etc/nginx/nginx.conf.j2 index bb0930e..bb0930e 100644 --- a/templates/nginx/nginx.conf.j2 +++ b/templates/etc/nginx/nginx.conf.j2 diff --git a/templates/systemd/system/ices2.service b/templates/etc/systemd/system/ices2.service index d3a4c2f..d3a4c2f 100644 --- a/templates/systemd/system/ices2.service +++ b/templates/etc/systemd/system/ices2.service diff --git a/templates/etc/systemd/system/liquidsoap-radio.service b/templates/etc/systemd/system/liquidsoap-radio.service new file mode 100644 index 0000000..c10983d --- /dev/null +++ b/templates/etc/systemd/system/liquidsoap-radio.service @@ -0,0 +1,17 @@ +[Unit] +Description=Liquidsoap Radio Streaming Service +After=network.target + +[Service] +Type=simple +User=icecast2 +#Group=icecast +ExecStart=/usr/bin/liquidsoap /srv/radio/radio.liq +Restart=on-failure +RestartSec=5 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=liquidsoap-radio + +[Install] +WantedBy=multi-user.target diff --git a/templates/srv/radio/create-playlist.sh.j2 b/templates/srv/radio/create-playlist.sh.j2 new file mode 100644 index 0000000..d596e8a --- /dev/null +++ b/templates/srv/radio/create-playlist.sh.j2 @@ -0,0 +1,22 @@ +#!/bin/bash + +DIR="{{ radio_music_dir }}" + +> "${DIR}/playlist.txt" +for i in "${DIR}"/tracks/*.mp3; do + title="$(basename "${i}" .mp3)" + printf "%s\n" "annotate:title=\"${title}\":${i}" >> "${DIR}/playlist.txt" +done + +if id -u icecast2 >/dev/null 2>&1 && getent group icecast >/dev/null 2>&1; then + chown -R icecast2:icecast "${DIR}" + printf "%s\n" "[inf] chowned ${DIR} with icecast2:icecast" +else + printf "%s\n" "[err] user or group icecast2:icecast does not exist, skipping chown" +fi + +if systemctl is-active liquidsoap-radio.service; then + systemctl restart liquidsoap-radio.service +else + printf "%s\n" "[err] liquidsoap-radio.service is not active, skipping restart" +fi diff --git a/templates/srv/radio/radio.liq.j2 b/templates/srv/radio/radio.liq.j2 new file mode 100644 index 0000000..0a070fe --- /dev/null +++ b/templates/srv/radio/radio.liq.j2 @@ -0,0 +1,23 @@ +#!/usr/bin/liquidsoap + +#settings.init.allow_root := true +set("log.file.path", "{{ radio_music_dir }}/logs/radio.log") + +music = playlist("{{ radio_music_dir }}/playlist.txt") +music = mksafe(music) + +def append_branding(m) = + title = m["title"] + [("title", "#{title}")] +end + +music = map_metadata(append_branding, music) + +output.icecast( + %mp3(bitrate=128), + music, + host="localhost", + port=8000, + password="{{ random_password }}", + mount="/stream", +) diff --git a/templates/var/www/html/audio-controls.js b/templates/var/www/html/audio-controls.js index 3b0a0c1..7f488f8 100644 --- a/templates/var/www/html/audio-controls.js +++ b/templates/var/www/html/audio-controls.js @@ -42,13 +42,12 @@ async function fetchCurrentTrack() { const data = await response.json(); const source = data.icestats.source; - const title = source.title || 'Unknown'; - const bitrate = source['ice-bitrate'] || 0; + const title = source.title || 'unknown'; const listeners = source.listeners || 0; const listenerLabel = listeners === 1 ? 'listener' : 'listeners'; stopSpinner(); - infoEl.textContent = `${title} | ${bitrate} kbps | ${listeners} ${listenerLabel}`; + infoEl.textContent = `${title} | ${listeners} ${listenerLabel}`; spinnerHasRun = true; |