[ rexroof.com ] [ biking ] [ blog ] [ work ] [ disposable ] [ crap ] [ code ] [ phone ] [ pictures ] [ yank ] [ url ] [ linklog ]

Wednesday, March 16, 2005

iTunes share on FreeBSD

With over 33,000 songs in my library, my iTunes share here at work is very popular. iTunes has a built in connection limit that people often complain to me about hitting. So this is why I started looking into running a duplicate share on my FreeBSD server.

first thing I did was set up nfs on my Mac OS X box to share to my mac, handily if you just write an /etc/exports file and reboot, the NFS server just starts. here's my /etc/exports file:

/Volumes/Music -mapall=rex shaolin

/Volumes/Music is where my music is, rex is my user's shortname, and shaolin is the machine hostname for my FreeBSD server that will want to mount the share.

then, on my FreeBSD box I put this in my /etc/fstab:


mogu:/Volumes/Music /music nfs ro,intr,noauto 0 0

intr is nice so that when nfs goes down my df commands don't hang. I'll probably take out the noauto once I figure out if this setup is working right.
after that I just did: mkdir /music ; mount /music , as root, of course.

all of this I did after I found this handy site:

Setting up an iTunes server in FreeBSD

This page was very helpful, but I found some of the info out of date and some dependancies broken. so here's my rundown (read that page before continuing)

First, install daapd. it's in /usr/ports/audio/daapd.

In the above instructions the info on daapd is correct, but I had many issues getting the port to build. The dependancies didn't seem to work out of the box, the error it gave me lead me to build multimedia/mpeg4ip manually. do this:

# cd /usr/ports/multimedia/mpeg4ip-libmp4v2
# make install clean
# cd /usr/ports/multimedia/mpeg4ip
# make install

then, it gets tedious. to get the mpeg4ip port to build, I had to edit some makefiles. I kept running that last command over and over, editing files as I went. The first errors were about mp4.h not found. this happened about 3 times; when it did, I noted from the error what directory it was in, then edited the Makefile in that directory and added
-I$(src_topdir)/lib/mp4v2
to the INCLUDES= line. for some reason this was omitted someplace. I'll e-mail the maintainer, hopefully it'll be fixed when you go to build the port.

After that I got some errors that were warnings treated as errors because -Wall was in the Makefile. The errors looked rather harmless, so I went into the directories in question and edited the Makefile to remove every instance of
-Wall

I think this only happened once.

The next batch of errors I had was some errors that said something along the lines of "undefined reference to `MP4IsIsmaCrypMediaTrack'", those were solved by manually rebuilding mpeg4ip-libmp4v2, which you already did, because I mentioned it above.

After mpeg4ip was installed, I went and built daapd, which rebuilt a bunch of stuff on my machine in my xlibraries. most of these things were upgrades, so I had to rebuild them by hand using cd /usr/port/dir ; make deinstall ; make reinstall. I had to do this for at least 3 ports; including pango, gtk and glib. I also got an error from /usr/ports/x11-fonts/XFree86-4-fontScalable that required me to build the port manually, that is, after manually installing a new version of make and imake. I did both of these with
portupgrade imake make
. Hopefully anyone reading this won't have ports as old as mine and won't have issues with these.

once daapd is installed you'll want to put daapd_enable="YES" in your /etc/rc.conf. and don't forget to edit your /usr/local/etc/daapd.conf, a sample is provided, and an example is shown on the page I linked above.

setting up mdnsresponder/rendezvous

the information on this in that above page is outdated. I found that I already had a mDNSResponder port, so I installed that. in fact, it's part of the dependancies of howl, which is part of the daapd dependancies. but I installed /usr/ports/net/mDNSResponder, and /usr/ports/net/howl by hand; I believe they went fairly painless. Finally I created /usr/local/etc/howl and created an mDNSResponder.conf there with these contents:

FREEBSD SERVERNAME
_daap._tcp.

3689

(note that blank line in there).

also, don't forget to add mdnsresponder_enable="YES" to your /etc/rc.conf

after that I ran

# /usr/local/etc/rc.d/mdnsresponder.sh start
# /usr/local/etc/rc.d/daapd.sh start

if you haven't changed your rc.conf these commands won't start the servers, so make sure you do that first.

this took over 10 minutes to start up the first time, I'm guessing because it had to parse my almost 160GB of music. but after that it started up rather quickly. you can watch /var/log/daapd.log to see what the server is doing.

one note, the first time I ran this, it crashed after I played with it a bit. hopefully this doesn't continue to happen.