Prerequisites:
Although this howto is written for OpenBSD I’m sure it will work on any other BSD or Linux Operating System with a few modifications given to the instructions below.
Please keep in mind that these instructions are by no means complete, or even guaranteed to work. I’m writing this from memory, so I might mistake some steps, but there is excellent documentation available through the use of Google or the Icecast/Ices site.
What I did:
STEP.1:
Compile and install icecast and ices, I’m not going to explain the instructions for that here as there is abundant documentation available for that already on the web.
In my case, I did not use the OpenBSD ports, instead I opted to use the source (most current) directly from the website.
STEP.2:
I installed a seperate HDD for music to be stored on, but you don’t have to go that far.
You can also do the following:
As ‘root’ create a directory where you would store mp3 files that are to be served:
# mkdir -p /opt/music
STEP.3:
I shared the music directory with Samba and copied a bunch of mp3’s to it in nicely organized sub directories directories. I’m not going to go into detail about the samba setup, as you should be able to find abundant documentation about it on the website, or on google.
My Samba configuration is very insecure, but it serves my needs well, as anyone on the network can copy files to and from it, and can make their own directories. I also have only one other person on my network who is trusted and able to access this share. You may setup samba as insecure or securely as you wish.
SMB.CONF
[music]
comment = Radio Station Music
path = /music/all
read only = no
public = yes
guest ok = yes
Directory Listing
(/music/all)#ls -lt
total 440
drwxrwxrwx 3 iceuser iceuser 3584 May 6 19:35 punk
drwxrwxrwx 16 iceuser iceuser 3072 Feb 22 12:35 electronica
drwxrwxrwx 16 iceuser iceuser 1024 Feb 16 21:44 techno
drwxrwxrwx 13 iceuser iceuser 1024 Feb 16 17:22 chill
drwxrwxrwx 7 iceuser iceuser 2048 Feb 16 16:31 hiphop
drwxrwxrwx 5 iceuser iceuser 4608 Feb 15 20:57 rock
drwxrwxrwx 10 iceuser iceuser 1536 Feb 15 18:57 jungle
STEP.4:
I created a script in /usr/local/bin
to scan my mp3’s, and generate a playlist of each directory as well as all of the mp3’s into one big list. This script is by no means complete, or even good, but it works. If you modify this script please feel free to let me know so I can post any modifications on this page.
(/usr/local/bin)# touch icecast.run
(/usr/local/bin)# chmod +x icecast.run
(/usr/local/bin)# vi icecast.run
and this is what i entered in the script: (change pathnames as appropriate)
#!/bin/sh
if [ -d /music/all ]; then
clear
echo "looks like we have some mp3 directories to look at.."
echo "will proceed with playlist file creation"
echo -n "please be patient!"
sudo -u iceuser find /music/all/ -name *.mp3 -print > /music/all/all.txt
echo -n "."
sudo -u iceuser find /music/all/jungle/ -name *.mp3 -print > /music/all/jungle.txt
echo -n "."
sudo -u iceuser find /music/all/techno/ -name *.mp3 -print > /music/all/techno.txt
echo -n "."
sudo -u iceuser find /music/all/chill/ -name *.mp3 -print > /music/all/chill.txt
echo -n "."
sudo -u iceuser find /music/all/electronica/ -name *.mp3 -print > /music/all/electronica.txt
echo -n "."
sudo -u iceuser find /music/all/hiphop/ -name *.mp3 -print > /music/all/hiphop.txt
echo -n "."
sudo -u iceuser find /music/all/punk/ -name *.mp3 -print > /music/all/punk.txt
echo -n "."
sudo -u iceuser find /music/all/rock/ -name *.mp3 -print > /music/all/rock.txt
echo -n "."
echo -n "done"
else
clear
echo " ERROR ERROR ERROR ERROR"
echo ""
echo "the mp3 files don't exist"
echo ""
echo " ERROR ERROR ERROR ERROR"
fi
if [ -f /music/ice/log/icecast.pid ]; then
echo ""
echo "icecast process already running"
echo "assuming you wish to terminate.."
echo "killing process"
#insert kill process thing here
echo "deleting pid file (if any)"
rm -f /music/ice/log/icecast.pid
echo -n "Starting icecast.."
sudo -u iceuser -b /usr/local/bin/icecast -c /usr/local/etc/icecast.xml >/dev/null 2>&1
echo -n "Running!"
echo ""
else
echo ""
echo -n "Starting icecast.."
sudo -u iceuser -b /usr/local/bin/icecast -c /usr/local/etc/icecast.xml >/dev/null 2>&1
echo -n "running!"
echo ""
fi
if [ -x /usr/local/bin/ices ]; then
echo "Starting ices now"
echo -n "Source:"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/jungle.conf >/dev/null 2>&1
echo -n ", jungle"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/chill.conf >/dev/null 2>&1
echo -n ", chill"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/rock.conf >/dev/null 2>&1
echo -n ", rock"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/hiphop.conf >/dev/null 2>&1
echo -n ", hiphop"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/punk.conf >/dev/null 2>&1
echo -n ", punk"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/techno.conf >/dev/null 2>&1
echo -n ", techno"
sudo -u iceuser /usr/local/bin/ices -c /usr/local/etc/electronica.conf >/dev/null 2>&1
echo -n ", electronica"
echo ""
echo ""
else
echo ""
echo "main program file ices is missing"
echo "check your path to make sure"
echo "ices is resident somewhere!"
echo ""
fi
STEP.5:
I setup my /etc/rc.local
file to run my script once upon boot of the box. On other operating systems this might be in /etc/rc.d/
or /usr/local/etc/
.
echo "# for icecast /usr/local/bin/icecast.run" >> /etc/rc.local
Be sure to use >>
and not >
. As >>
is append, and >
is overwrite.
STEP.6:
Edit your icecast.xml and ices.conf files.
icecast.xml
<icecast>
<limits>
<clients>10</clients>
<sources>10</sources>
<threadpool>5</threadpool>
<queue-size>102400</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
</limits>
<authentication>
<source-password>PASSWORD</source-password>
<relay-password>PASSWORD</relay-password>
<admin-user>admin</admin-user>
<admin-password>PASSWORD</admin-password>
</authentication>
<hostname>radio.servers.spizzo.spazzo</hostname>
<listen-socket><port>8000</port></listen-socket>
<fileserve>1</fileserve>
<paths>
<basedir>/music/ice</basedir>
<logdir>/music/ice/log/icecast</logdir>
<webroot>/music/ice/web</webroot>
<adminroot>/music/ice/admin</adminroot>
<pidfile>/music/ice/log/icecast.pid</pidfile>
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<loglevel>1</loglevel> <!– 4 Debug, 3 Info, 2 Warn, 1 Error –>
</logging>
<security>
<chroot>0</chroot>
</security>
<mount>
<mount-name>/techno</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/electronica</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/punk</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/oldies</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/hiphop</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/rock</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/chill</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
<mount>
<mount-name>/jungle</mount-name>
<password>PASSWORD</password>
<max-listeners>2</max-listeners>
<fallback-mount>/all</fallback-mount>
</mount>
</icecast>
Edit ices.conf (or in this case the rock music stream)
<?xml version="1.0"?>
<ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices">
<Playlist>
<File>/music/all/rock.txt</File>
<Randomize>1</Randomize>
<Type>builtin</Type>
<Module>ices</Module>
</Playlist>
<Execution>
<Background>1</Background>
<Verbose>0</Verbose>
<BaseDirectory>/music/ice/log/rock</BaseDirectory>
</Execution>
<Stream>
<Server>
<Hostname>YOUR.HOST.NAME.HERE</Hostname>
<Port>8000</Port>
<Password>PASSWORD</Password>
<Protocol>http</Protocol>
</Server>
<Mountpoint>/rock</Mountpoint>
<Name>Spizzo Rock Radio!</Name>
<Genre>Rock / Alternative</Genre>
<Description>Rock and Alternative – sixties to today</Description>
<URL>http://localhost/rock</URL>
<Public>0</Public>
<Bitrate>128</Bitrate>
<Reencode>0</Reencode>
<Samplerate>44100</Samplerate>
<Channels>2</Channels>
</Stream>
</ices:Configuration>
STEP.7:
Reboot and test it out.
Output on Login
looks like we have some mp3 directories to look at..
will proceed with playlist file creation
please be patient!!! done
deleting pid file (if any)
Starting icecast..Running!
Starting ices now
Source: jungle, chill, rock, hiphop, punk, techno, electronica
You should see something like the previous when you login. If there is any errors, make sure you have the correct paths in your icecast config files and in your icecast.run script.
Web Test
You should now be able to access the icecast website. Make sure you check the paths, and set up the web site according to the icecast documentation before attempting this. It’s really quite easy to setup though.
http://ip.of.your.box:8000/status.xsl