Setup iTunes Server mt-daapd
|
What is this?
mt-daapd (also known as FireFly) is an open-source implementation of the streaming protocol used by iTunes to serve music. Once you've got it running on your FSG, any PC (including Macs and Linux boxes) on the network can stream the music off. There are also several hardware players out there that support this stream type. Running mt-daapd on your FSG means you can keep all your music in one place, rather than having copies of it all over. Much easier to manage.Device Compatability
This is tested and working well on my WLAN FSG running v3.1.29, with the package downloaded from the ipkg repository. Your mileage may vary. UPDATE the same procedure now verified as working on firmware v3.3.14.
mt-daapd is widely supported and available as source code, so the chances of getting it working on the NDP and DTG are good, even if the ipkg package hasn't been published yet. If you'd like me to document the process on that hardware, no problem. Just send me samples to play with ;o)
Alternatively, if you've got it running on other versions/platforms, please update this page accordingly.
UPDATE Works fine on DTG with firmware v4.5.0.8
Prerequisites
- You've already got ipkg going, right? If not, you'll want to read Use the Custom ipkg installer first.
- And of course you're already running an SSH server. No? Then read Use the SSH Server as well.
Installation
SSH into your FSG and su to root. If you haven't done this before you should read Logging in as root before proceeding.
Now:
ipkg install mt-daapd
Configuration
Now you have two files to edit. Using your favourite editor, start with file /opt/etc/init.d/S60mt-daapd - this is the startup script, run every time the FSG boots. Unfortunately the one supplied has two problems:
- It uses pidof to find and kill existing mt-daapd threads, but pidof isn't supported on the FSG.
- The default firewall configuration of the FSG will prevent the multicast traffic from moving properly, stopping our music.
So you want to replace the supplied /opt/etc/init.d/S60mt-daapd with this one:
#/bin/sh echo "fixing iptables for daapd-multicast" iptables -I INPUT -p udp --dport 5353 -j ACCEPT iptables -I INPUT -d 224.0.0.251 -j ACCEPT iptables -A OUTPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT iptables -A INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT echo "killing off any old ones..." killall mt-daapd sleep 4 echo "executing /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd.conf" /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd.conf
For pain-free implementation, edit the existing file and simply replace the contents. That way you'll know your permissions are OK.
Notice the reference to the configuration file at the bottom? "/opt/etc/mt-daapd/mt-daapd.conf" - this is the second file you need to edit. The bits you want to change are the lines starting with:
admin_pw (only used by the web admin interface, so you can leave it for now if you like) mp3_dir (tells the server which directory holds the music) servername (not essential, but makes it a no-brainer in iTunes) runas (see "UPDATE" note below, may not always be necessary)
By all means browse the rest of the file and explore the options (with caution, obviously), but those are the only ones to worry about at this point.
UPDATE - you've done everything right but it's not working. Now what? I've never had this happen under 3.1.29, but saw a report in the forum about other versions and so tried it on 3.3.14. The service does not start, and logging didn't work either, which made it very difficult to debug. Eventual solution as posted by forum user marcus, was to look for the line in the .conf file starting with "runas" and change the value from "guest" to "nobody".
UPDATE for DTG in the conf file on the line starting with "runas" change value from "guest" to "nobody"
Start the Server
Run
/opt/etc/init.d/S60mt-daapd
then fire up iTunes on a PC... voila! Under the SHARED section (below STORE), your new music server should appear. Of course, it would be nice if there was some music there, so make sure your mp3_dir set as above has got some files in it.
Because the script starts with a capital S, and is in the /opt/etc/init.d folder, we should never need to start it again as the FSG will run the script for us on every boot.
If you get the error:
You are not root. This is almost certainly wrong. If you are sure you want to do this, use the -y command-line switch
then either su to root before running the S60 script, or simply reboot the FSG and let it sort itself out.
UPDATE for DTG rename the script as root
mv /opt/etc/init.d/S60mt-daapd /etc/init.d/S99mt-daapd
link the script to rc as root for starting the script at every boot
ln -s /etc/init.d/S99mt-daapd /etc/rc/S99mt-daapd
Now the script start when the system boot
Advanced - Running Multiple Servers
My son and I have (obviously) very different musical tastes and don't really share each other's music. There are two ways of handling this:
- Set up playlists
- Run multiple servers
of the two, playlists sounds better. But I already have my own set of playlists, and hate his getting in the way. So I ran another server, and it worked beautifully. Simply create another config file (something like "/opt/etc/mt-daapd/mt-daapd-dad.conf", with a different servername and mp3_dir, and tweak the port value to 3690, and add a bit to the end of /opt/etc/init.d/S60mt-daapd so that it now looks like this:
#/bin/sh echo "fixing iptables for daapd-multicast" iptables -I INPUT -p udp --dport 5353 -j ACCEPT iptables -I INPUT -d 224.0.0.251 -j ACCEPT iptables -A OUTPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT iptables -A INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT echo "killing off any old ones..." killall mt-daapd sleep 4 echo "executing /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd.conf" /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd.conf echo "executing /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd-dad.conf" /opt/sbin/mt-daapd -c /opt/etc/mt-daapd/mt-daapd-dad.conf
Make sure the music collection for the second service is in the directory referred to by mp3_dir in the second config file, and restart mt-daadp by running
/opt/etc/init.d/S60mt-daapd
again. iTunes should now show two servers.
Trouble-shooting
Sometimes things don't go as smoothly as we'd like. Enabling debugging is invaluable. Change the final line(s) of your S60-mtdaapd, and add "-d x" to the end, where x is a value between 1 and 9 - try 4 to start with. The higher the number, the more verbose the log data. You'll find the log file in /var/log, unless you've changed it in your mt-daapd.conf file.
Don't forget to switch the logging off again afterwards! Especially at the high values, this will eat up disk space at an alarming rate if you leave it active. Once you've resolved the problem, remove the -d switch and delete the log file.
iTunes displays songs but they don't play
There are two known reasons for this:
- Codec incompatabilities. This should not be a problem these days, make sure you have updated your installation: ipkg update mt-daapd.
- Corrupt database. This seems to happen frequently after firmware upgrades/re-installs. Stop the server, delete the file (probably songs.db or songs.gdb in /opt/var/mt-daapd), and re-start. This forces mt-daap to rebuild the database.
Server disappears from iTunes after a few minutes
STUB: to be added shortly.
Server does not show in iTunes at all
STUB: to be added shortly.