I got this from http://www.ralph-moseley.co.uk/blog/?page_id=55∞
OpenBSD MP3 Server
Setup MP3 Server
These notes should help set up an mp3 server on an
OpenBSD system, I used version 41. The software used is icecast (the server) and ices (the source client, the thing that actually produces the audio stream from your mp3s).
The easy way to do this is to use pkg_add as root:
pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/icecast-2.3.1.tgz
and
pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/ices-0.4p1.tgz
The files for Icecast are placed in:
/usr/local/bin
/usr/local/share
/usr/local/doc
/usr/local/examples
The first thing to do is to create a new user for the server:
useradd -c "Icecast Server" -d /nonexistent -g =uid -s /sbin/nologin -u 400 _icecast
Now we need to create a directory for Icecast.
Copy the example configuration files into the new directory:
cp -R /usr/local/share/examples/icecast/* /var/icecast
Icecast needs to make several log files in specific locations which are accessible to the user that was just created:
cd /var/icecast
mkdir log
touch log/error.log log/access.log
chown _icecast:_icecast log/*.log
Next the chroot environment has to be made with additional system file, optional, but it allows YP directory listing to work and the log files will contain correct timestamps.
mkdir /var/icecast/etc
cp -p /etc/{hosts,localtime,resolv.conf} /var/icecast/etc
Find icecast.xml.dist in /var/icecast:
mv icecast.xml.dist icecast.xml
chmod 600 icecast.xml
(Mode 600 is highly recommended; icecast.xml contains plain-text passwords. At least keep it inaccessible to “others”.)
Edit icecast.xml in your favorite editor:
* CHANGE THE DEFAULT PASSWORDS FOR SOURCE CLIENTS, RELAYS AND
THE ADMIN INTERFACE
* Change to /var/icecast
* Change to /log
* Change to /web
* Change to /admin
* Change to 1
* Uncomment the directive, replace both “nobody” and
“nogroup” with “_icecast”.
Start Icecast and monitor error.log for errors and clues on how to solve any issues.
icecast -c /var/icecast/icecast.xml
If things look good, add the command line parameter `-b’ to send Icecast into daemon land.
Test the server: Use a source client to create a stream and listen to it with your favorite player that supports streaming. Also test Icecast’s web interface. Be aware that Icecast sends everything located in to those who request it like a regular (basic) web server. You can restrict this behavior to serve only .xsl files by setting to 0 in your icecast.xml, however, you should definitely take a closer look at what you actually want to show the world here. There is no reason for paranoia, it’s all safe, but you should spend some time thinking about it. Note that disabling will also prevent CSS stylesheets and images from being sent, making the web interface less pleasant to look at.
Setup Source Client
You now need to set up the source client such as ices for the mp3 audio stream.
When you have used the pkg_add above the files are placed in:
/usr/local/bin/ices
/usr/local/man/man1/ices.1
/usr/local/share/doc/ices/icesmanual.html
/usr/local/share/examples/ices/ices.conf.dist
/usr/local/share/ices/ices.pm.dist
/usr/local/share/ices/ices.py.dist
As before you can copy the example config file into /var/ices/ and make a log directory together with error.log and access.log.
Alter the configuration file you may have placed in /var/ices to correspond to your Icecast configuration changing the password you have set for the source.
The main thing is that ices can find the configuration file and a playlist when it starts up.
Setting up your playlist
if you have all your mp3s in one directory you could create a test playlist by:
find /path/to/files -name '*.mp3' > playlist.txt
To get it all going start Icecast as before under root (it changes to the new user itself!).
icecast -b -c /var/icecast/icecast.xml
You could then check it is running by checking the html server page, as before. Next start Ices:
ices -c /var/ices/ices.conf -F playlist.txt
When you are sure this is working you can move it into the background by adding a -B option (note: it’s uppercase, -b is an option for bitrate!).
On another machine try and plug into the stream with software such as
RealPlayer, Audion, iTunes, XMMS and point at:
http://machinename:8000/ices//∞
replacing machinename with the hostname of your computer, or its IP address. 8000 is the socket you specified and /ices is the mountpoint.
To make icecast run after boot add the following line to your /etc/rc.local:
/usr/local/bin/icecast -b -c /var/icecast/icecast.xml
If you want multiple streams running it’s just a matter of pointing ices at different configuration files with alternative mount points and, if you like, different stream details.
Hope this saves you some annoyance and time — Good Luck!
There are no comments on this page. [Add comment]