diff options
author | heqnx <root@heqnx.com> | 2025-07-05 12:21:29 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-07-05 12:21:29 +0300 |
commit | 9457306a881cfe476ee0abbdba4f6f1eaa80db9d (patch) | |
tree | a0051e68286eb93381a398d2681ec5a14f5c035e /templates/icecast2/mp3-to-ogg.sh.j2 | |
parent | 730705affa4407a9dee7c52e5deb825020da110d (diff) | |
download | ansible-icecast2-9457306a881cfe476ee0abbdba4f6f1eaa80db9d.tar.gz ansible-icecast2-9457306a881cfe476ee0abbdba4f6f1eaa80db9d.zip |
initial commit on a working icecast2 setup
Diffstat (limited to 'templates/icecast2/mp3-to-ogg.sh.j2')
-rw-r--r-- | templates/icecast2/mp3-to-ogg.sh.j2 | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/templates/icecast2/mp3-to-ogg.sh.j2 b/templates/icecast2/mp3-to-ogg.sh.j2 new file mode 100644 index 0000000..b37f5af --- /dev/null +++ b/templates/icecast2/mp3-to-ogg.sh.j2 @@ -0,0 +1,32 @@ +#!/bin/bash + +if ! command -v ffmpeg &>/dev/null; then + printf "%s\n" "[err] ffmpeg not found" + exit 1 +fi + +DIR="{{ radio_music_dir }}" + +shopt -s nullglob +for mp3file in "${DIR}"/*.mp3; do + oggfile="${mp3file%.mp3}.ogg" + + printf "%s\n" "[inf] converting ${mp3file} to ${oggfile}" + + if ffmpeg -loglevel error -y -i "${mp3file}" -acodec libvorbis -q:a 5 "${oggfile}"; then + printf "%s\n" "[inf] conversion successful, removing ${mp3file}" + rm -f "${mp3file}" + else + printf "%s\n" "[err] conversion failed for ${mp3file}" + fi +done + +ls "${DIR}"/*.ogg > "${DIR}/playlist.txt" + +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 + |