summaryrefslogtreecommitdiff
path: root/templates/srv/radio/create-playlist.sh.j2
diff options
context:
space:
mode:
authorheqnx <root@heqnx.com>2025-07-06 14:57:39 +0300
committerheqnx <root@heqnx.com>2025-07-06 14:57:39 +0300
commita064cbda2086b79b6cc04111cb308a6b2d770aa6 (patch)
tree9b2c6aa08775aaae76420f9ad8d6baaf728bbe24 /templates/srv/radio/create-playlist.sh.j2
parent3559ca8a720086f080286e887a29b6fa68810fa9 (diff)
downloadansible-icecast2-a064cbda2086b79b6cc04111cb308a6b2d770aa6.tar.gz
ansible-icecast2-a064cbda2086b79b6cc04111cb308a6b2d770aa6.zip
replaced ices2 which only supports vorbis, with liquidsoap + creation of title metadata; reorganized templates
Diffstat (limited to 'templates/srv/radio/create-playlist.sh.j2')
-rw-r--r--templates/srv/radio/create-playlist.sh.j222
1 files changed, 22 insertions, 0 deletions
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