summaryrefslogtreecommitdiff
path: root/templates/srv/radio/create-playlist.sh.j2
blob: d596e8a45db1e7ca9fae8f33728abd7c1c05a7a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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