Running Linux as an iTunes music server

Last night I finally got around to consolidating the household music collection and making it available to all the personal computers on our network.

I had originally shared my music on the network from my Mac, but this only worked when I was logged in and when iTunes was running. When Cat was logged in on the same machine, she didn’t have access to our music collection in my home directory.

Even if we were able to somehow share a music folder, one of us would need to remain logged in with iTunes running for any other clients on the network to have access to the library.

Fortunately, my CentOS Linux server had already been configured to backup the Mac’s iTunes music collection nightly via rsync, so it had its own mirror of what was on the Mac. I just needed to find a way to make that library available to all the Mac and PC users on my network as an iTunes share.

I discovered several approaches on the Web, but came up with a solution with a bit of custom configuration based on several resources. Now, whatever is ripped to or bought via the iTunes Music Store on the Mac is made available to all users via Apple RendezVous/Bonjour using the DAAP protocol implemented by Firefly Media Server (mt-daapd) on the local subnet.

In the steps below, corresponds to the CentOS 4.4 x86_64 Linux server, is the Mac OS X 10.4.8 running iTunes 7.0.2.

  • First, here is the nightly rsync line configured to run on the Linux server. I use keys to run the script over SSH.
    [code lang=”bash”]
    [dan@]$ vi
    rsync -av -e “ssh -i /home/dan/rsync-key” \\”/Users/dan/Music/iTunes/iTunes Music/’\’ /home/dan/iTunes[/code]
  • Install the libid3tag RPMs so that the Linux server can interpret music file metadata.
    [code lang=”bash”]
    [root@]# rpm -i libid3tag-0.15.1b-3.2.el4.rf.x86_64.rpm
    [root@]# rpm -i libid3tag-devel-0.15.1b-3.2.el4.rf.x86_64.rpm[/code]
  • Build the mt-daapd daemon from source, since there was no RPM for my platform.
    [code lang=”bash”]
    [root@]# tar xvzf mt-daapd-0.2.4.tar.gz
    [root@]# cd mt-daapd-0.2.4
    [root@]# ./configure –prefix=/usr/local
    [root@]# make
    [root@]# make install[/code]
  • Copy some example configuration files from the distribution.
    [code lang=”bash”]
    [root@]# cp contrib/mt-daapd.conf /etc
    [root@]# cp contrib/mt-daapd.playlist /etc[/code]
  • Change the default configuration.
    [code lang=”bash”]
    [root@]# vi /etc/mt-daapd.conf
    web_root /usr/local/share/mt-daapd/admin-root
    port 3689
    admin_pw admin-pw
    db_dir /var/cache/mt-daapd
    mp3_dir /home/dan/iTunes/
    servername centos
    runas dan
    playlist /etc/mt-daapd.playlist
    extensions .mp3,.m4a,.m4p,.ogg
    logfile /var/log/mt-daapd.log
    rescan_interval 300
    compress 1[/code]
  • Perform some initial setup, which shouldn’t be necessary if you are installing mt-daapd from an RPM instead of source.
    [code lang=”bash”]
    [root@]# mkdir -p /var/cache/mt-daapd
    [root@]# cp contrib/mt-daapd /etc/init.d
    [root@]# vi /etc/init.d/mt-daapd # Make some path changes for my environment
    [root@]# chmod +x /etc/init.dmt-daapd
    [root@]# /sbin/chkconfig –add mt-daapd # Configure mt-daapd to run at startup
    [root@]# chmod o+r -R iTunes # Allow the daemon to read the audio files in my home directory, in case it’s not running as me.
    [root@]# /etc/init.d/mt-daapd start[/code]
  • With that, the share was now available to the PCs and Macs on my network. To debug any other issues, I tailed the log.
    [code lang=”bash”][root@]# tail -500f /var/log/mt-daapd.log[/code]

That was basically it. I’m still working on customizing things further, and I still keep a local copy of my music on the Mac to synchronize with my iPod.

Here’s a list of resources I consulted to get things going. Google Linux iTunes Server for more.

« Previous page