Initial import
authorkaliko <kaliko@azylum.org>
Thu, 22 Oct 2015 12:56:37 +0000 (14:56 +0200)
committerkaliko <kaliko@azylum.org>
Thu, 22 Oct 2015 12:56:37 +0000 (14:56 +0200)
README [new file with mode: 0644]
do [new file with mode: 0755]
sima/Dockerfile [new file with mode: 0644]
sima/mpd.conf [new file with mode: 0644]
sima/sima [new file with mode: 0644]
sima/start [new file with mode: 0644]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..1ff01de
--- /dev/null
+++ b/README
@@ -0,0 +1,23 @@
+Description
+===========
+
+This images contains MPD, icecast2 and MPD_sima in order to serve an audio stream over http.
+
+Configuration
+=============
+
+Running a container to play to content of your music library:
+
+  - Audio stream available from http://127.0.0.1:8001
+  - MPD available on 127.0.0.1:6601
+
+..code-block:: sh
+        LISTEN=127.0.0.1
+        MUSIC="/path/to/my/music/library"
+        OPTIONS="-p ${LISTEN}:8001:8000"
+        OPTIONS="${OPTIONS} -p ${LISTEN}:6601:6600"
+        OPTIONS="${OPTIONS} --volume ${MUSIC}:/var/lib/mpd/music:ro"
+        docker run ${OPTIONS} --detach=true --name sima kaliko/sima
+
+
+ vim: syntax=rst ft=rst
diff --git a/do b/do
new file mode 100755 (executable)
index 0000000..ce54532
--- /dev/null
+++ b/do
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+DIR=$(dirname $(readlink -f $0))
+
+ICE_PORT=${ICEPORT:-8001}
+MPD_PORT=${MPDPORT:-6601}
+LISTEN=${LISTEN:-127.0.0.1}
+
+# make output verbose
+set -o xtrace -o nounset
+
+_conf () {
+    # Get the latest icecast conf
+    docker run --rm sima -v ${DIR}:/tmp/ debian:latest cp -f /icecast/icecast.xml /tmp/current.icecast.conf.xml
+}
+
+log_icecast () {
+    # Monitor logs
+    docker exec -ti sima /usr/bin/tail -F /var/log/icecast2/access.log /var/log/icecast2/error.log
+}
+
+build () {
+    # Build image with icecast
+    docker build -t kaliko/sima ${DIR}/sima
+}
+
+run () {
+    # Start
+    test -z "${MUSIC}" && { echo "Need a music directory to mount please set MUSIC var"; exit 1; }
+    docker ps -a | grep 'sima'
+    if [ "$?" -ne 0 ]; then
+        echo 'launching a new sima container'
+        local options="-p ${LISTEN}:${ICE_PORT}:8000"
+        options="${options} -p ${LISTEN}:${MPD_PORT}:6600"
+        options="${options} --volume ${MUSIC}:/var/lib/mpd/music:ro"
+        docker run ${options} --detach=true --name sima kaliko/sima
+    else
+        echo 'running the current sima container'
+        docker start sima
+    fi
+}
+
+$@
diff --git a/sima/Dockerfile b/sima/Dockerfile
new file mode 100644 (file)
index 0000000..34f773b
--- /dev/null
@@ -0,0 +1,22 @@
+FROM debian:latest
+MAINTAINER Kaliko <kaliko@azylum.org>
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get -y update && apt-get -y upgrade && apt-get install -y --no-install-recommends icecast2 mpd mime-support virtualenv
+RUN apt-get clean
+RUN usermod --shell /bin/dash icecast2
+RUN usermod --shell /bin/dash mpd
+ADD mpd.conf /etc/mpd.conf
+
+RUN virtualenv -p python3 /var/lib/mpd-sima
+RUN bash -c "source /var/lib/mpd-sima/bin/activate && pip install MPD_sima"
+
+VOLUME /var/lib/mpd/music/
+
+# expose icecast and mpd
+EXPOSE 8000 6600
+
+ADD start /usr/bin/start-sima
+ADD sima /usr/bin/sima
+
+ENTRYPOINT ["/bin/sh", "/usr/bin/start-sima"]
diff --git a/sima/mpd.conf b/sima/mpd.conf
new file mode 100644 (file)
index 0000000..d711069
--- /dev/null
@@ -0,0 +1,39 @@
+music_directory                "/var/lib/mpd/music"\r
+playlist_directory     "/var/lib/mpd/playlists"\r
+db_file                                "/var/lib/mpd/tag_cache"\r
+log_file                       "/var/log/mpd/mpd.log"\r
+pid_file                       "/var/lib/mpd/pid"\r
+state_file                     "/var/lib/mpd/state"\r
+sticker_file           "/var/lib/mpd/sticker.sql"\r
+user                           "mpd"\r
+#group                         "nogroup"\r
+bind_to_address                "any"\r
+#bind_to_address       "/run/mpd/socket"\r
+#port                          "6600"\r
+#log_level                     "default"\r
+zeroconf_enabled       "no"\r
+#zeroconf_name         "Music Player"\r
+filesystem_charset     "UTF-8"\r
+id3v1_encoding         "UTF-8"\r
+\r
+# MPD_sima's icecast conf's\r
+audio_output {\r
+       enabled         "yes"\r
+       type            "shout"\r
+#      protocol        "icecast2"        # default to icecast2\r
+#      encoding        "vorbis"                # default is vorbis\r
+#      encoding        "flac"\r
+       name            "Sima Vorbis Stream"\r
+       host            "localhost"\r
+       port            "8000"\r
+       mount           "/sima.ogg"\r
+       format          "44100:16:2"\r
+       quality         "8.0"\r
+#      bitrate         "128"\r
+#      user            "source"                # default source\r
+       password        "hackme"\r
+       description     "MPD_sima's radio"   # optional\r
+#      genre           "jazz"            # optional\r
+#      public          "no"                    # optional\r
+#      timeout         "2"              # optional\r
+}\r
diff --git a/sima/sima b/sima/sima
new file mode 100644 (file)
index 0000000..2b03add
--- /dev/null
+++ b/sima/sima
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. /var/lib/mpd-sima/bin/activate
+mpd-sima $@
+
+# vim: fileencoding=utf8
diff --git a/sima/start b/sima/start
new file mode 100644 (file)
index 0000000..09c268d
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Hand over to icecast
+su -c "icecast2 -b -c /etc/icecast2/icecast.xml" icecast2
+
+su -c "mpd /etc/mpd.conf" mpd
+
+if [ -e /etc/mpd-sima.cfg ]; then
+    OPTIONS="${OPTIONS} --config /etc/mpd-sima.cfg"
+fi
+
+OPTIONS="${OPTIONS} --log /var/log/mpd/mpd-sima.log --daemon"
+su -c "sh /usr/bin/sima ${OPTIONS}" mpd
+
+tail -F /var/log/icecast2/access.log \
+        /var/log/icecast2/error.log \
+        /var/log/mpd/mpd.log \
+        /var/log/mpd/mpd-sima.log