Webradio - Musikstream mit Icecast2 und Ices2 für Playlist stream


Vorwort



Icecast2

Installieren Sie icecast2 mit folgendem Befehl:
apt -y install icecast2

Passen Sie anschliessend die Konfigurationsdatei von icecast2 an :
nano /etc/icecast2/icecast.xml
<icecast>
<location>Earth</location>
<admin>hostmaster@4b42.com</admin>

<authentication>
<source-password>hackme</source-password>
<relay-password>hackme</relay-password>
<admin-user>admin</admin-user>
<admin-password>hackme</admin-password>
</authentication>
...
<security>
<chroot>0</chroot>
<changeowner>
<user>icecast2</user>
<group>icecast</group>
</changeowner>
</security>
</icecast>
Führen Sie zum Schluss folgenden Befehl aus, um das Init Script zu aktiveren:
sed -i -e 's/ENABLE=false/ENABLE=true/g' /etc/default/icecast2


Nun können Sie Ihren Icecast2 Server Testen:
/usr/bin/icecast2 -c /etc/icecast2/icecast.xml
Changed groupid to 110.
Changed supplementary groups based on user: icecast2.
Changed userid to 105.
Unter Debian hatte ich das Problem, das ich den Server nicht mit dem Init-Skript starten konnte. Dies kann wie folgt gelöst werden:
sed -i -e 's/--chuid $USERID:$GROUPID//g' /etc/init.d/icecast2
systemctl daemon-reload



Ices2

Installieren Sie nun ices2 wie folgt:
apt -y install ices2
Nach der Installation können Sie die Verzeichnisse für ices2 erstellen:
mkdir /var/log/ices
mkdir /etc/ices2
mkdir /etc/ices2/music
mkdir /etc/ices2/music/hiphop
Kopieren Sie die Beispielkonfiguration in das ices2 Verzeichnis:
cp /usr/share/doc/ices2/examples/ices-playlist.xml /etc/ices2
und bearbeiten Sie diese mit einem beliebigen Editor:
nano /etc/ices2/ices-playlist.xml



TODO: config here


find /etc/ices2/music/ -name "*.ogg" > /etc/ices2/hiphop.playlist



MP3


apt -y install g++ libshout-ocaml-dev make wget
cd /usr/src/
wget http://downloads.us.xiph.org/releases/ices/ices-0.4.tar.gz
tar xzf ices-0.4.tar.gz
cd ices-0.4
./configure
make
make install


/usr/local/bin/ices -h localhost -p 8000 -P 4b42 -m hiphop -n '4b42 Hip Hop Stream' -d 'Hip Hop and German Rap Stream' -g hiphop -B -r -F /tmp/hiphop.playlist
Into the land of the dreaded daemons we go... (pid: 195)

Nur PID ausgeben:
/usr/local/bin/ices -h localhost -p 80 -P 4b42 -m hiphop -n '4b42 Hip Hop Stream' -d 'Hip Hop and German Rap Stream' -g hiphop -B -r -F /tmp/hiphop.playlist|cut -d ':' -f2|sed 's/ //g; s/)//g;'
413


Start - Stop Script


mkdir /opt/ices
nano /opt/ices/hiphop.sh
#!/bin/bash
#-----------------------------------------------------------------------#
# Copyright 2006-2016 by Kevin Bühl <kevin@buehl.biz> #
#-----------------------------------------------------------------------#
# __ __ _____________ __ __ ______________ #
# | | 2006 | | | _______ \ | | | | |___________ | #
# | | 2016 | | | | \ | | | | | | | #
# | |___ ____| | | |_______/ / | |___ ____| | ___________| | #
# |______ ____ | | _______ | |______ ____ | | ___________| #
# by | | | | \ \ Content | | | | #
# Kevin | | | |_______/ | Management | | | |___________ #
# Bühl |__| |_____________/ System |__| |______________| #
# #
# No part of this website or any of its contents may be reproduced, #
# copied, modified or adapted, without the prior written consent of #
# the author, unless otherwise indicated for stand-alone materials. #
# For more Information visit www.4b42.com. #
# This notice must be untouched at all times. #
#-----------------------------------------------------------------------#

#-----------------------------------------------------------------------#
# 2016-10-18 Kevin Bühl created
#-----------------------------------------------------------------------#
DESC="Hip Hop and German Rap Stream"
GERNE="hiphop"
HOST="localhost"
NAME="4b42 Hip Hop Stream"
PASS="dQ2KPxoSl8iVcb5"
PORT=80
if [ -e /var/run/ices_${GERNE}.pid ]; then
kill $(cat /var/run/ices_${GERNE}.pid)
fi
/usr/local/bin/ices -h ${HOST} -p ${PORT} -P ${PASS} -m ${GERNE} -n ${NAME} -d ${DESC} -g ${GERNE} -B -r -F /opt/ices/${GERNE}.playlist|cut -d ':' -f2|sed 's/ //g; s/)//g;' > /var/run/ices_${GERNE}.pid