HOWTO: Set Up daapd on Fedora Linux


The information on this page is outdated and may not be accurate anymore, since I no longer run Linux machines at home.

Update: This HOWTO was revised according to my brand new Fedora Core 3 install. Core 3 includes Howl and a few of the necessary libraries, so it streamlines the process considerably. If you find anything wrong with this, drop me a line.

Introduction

This is a set of notes pertaining to my experiments with daapd, an iTunes-compatible streaming server that implements the DAAP protocol. This was partly inspired by this item on Mac OS X Hints, but I wanted to have a complete, reproducible procedure that could be used as a reference by myself or others with no time to spare.

(If you don't run Fedora, Sandy McArthur has a Gentoo package that also uses Howl to announce itself, plus other notes on Rendezvous)

Please note that there is now a second DAAP server for UNIX platforms called mt-daapd, which has a Fedora package available. I have not tried it yet - it looked promising at first (it supports dynamic playlists, for one thing), but the project now seems to be dead (I've seen no updates for a long while). Then again, it might just be "stable", since I know it's been ported to the Linksys/NSLU2 recently.

Caveats and Disclaimer

All of the steps described here were done and tested on Fedora Core 3. Any similar Linux release should work fine, but I remember having trouble getting the exact same code to work properly in RedHat 9 due to i18n issues (the ID3 tag parsing would choke and die when handling accented characters). Your mileage may vary, and I'm not at all responsible for any data loss (or other damage) that you may incur by installing and using this stuff like I describe.

Getting the Code

daapd relies on several specific libraries. Most are now included in Fedora or available via apt from freshrpms.net, so I only needed the actual server:

  • daapd-0.2.4a.tgz
  • libid3tag and howl-devel can be installed via apt from freshrpms.net with a single command:
# apt-get install libid3tag libid3tag-devel howl-devel

I do not need MP4/AAC support, so I didn't compile mpeg4ip (which, by the way, is at least as complex to install on its own). Neverhteless, Jarrod Smith sent me a few notes I've tacked on to the bottom of this post.

Compiling it

Compiling everything is pretty straightforward. Assuming you like things tidy like me and set up Packages and Build directories for your workspace, things should work like this (steps expanded to make things as clear as possible for newbies).

(On previous Fedora versions, it was necessary to edit /etc/ld.so.conf to add /usr/local/lib to the library search path. With Fedora Core 3, that was no longer necessary.)

Note: Check the bottom of this page for Jarrod Smith's notes on AAC support

Since Fedora places Howl in /usr instead of /usr/local and I don't have need for AAC support (actually, I found mpeg4ip a lot more trouble than it's worth), I've had to edit the makefile a bit:

$ cd Build/
$ tar -zxvf ../Packages/daapd-0.2.4a.tgz
$ cd daapd-0.2.4a/
$ vi makefile

...edit to look like this:

MPEG4_ENABLE = 0
...
        HOWLDIRS := $(sort $(wildcard /usr/include/howl*) )

...and compile it:

$ make
$ su
Password:
# mkdir -p /usr/local/man/man8
# make install

Do note that this installs daapd as /usr/local/bin/daapd instead of /usr/local/sbin/daapd, which is where daemons should be. But hey, I'm a stickler for consistency. The mkdir is to ensure the man page gets installed correctly (/usr/local/man does not exist in a stock install)

If you're upgrading, make sure the build replaces any current version of libhttpd - when upgrading my server in previous builds, I had to go down into libhttp and do the ./configure; make; make install dance there before I got daapd to work.

Configuration

The configuration file format is fairly simple:

$ cat /etc/sysconfig/daap/daapd.conf
Port            3689
ServerName      Jukebox
DBName          daapd music
Password
Root            /mnt/storage/mp3
Cache           /var/spool/daapd/cache
Timescan        2
Rescan          0

The README file has more information, but basically this setup is a password-free server (iTunes does not have usernames, only per-server passwords), stores a database cache under /var/spool (do a mkdir -p /var/spool/daapd as root to ensure it exists before running the daemon) and does not rescan the library every time a client connects.

If you are upgrading, delete your cache file. Trust me, it saves you a lot of bother.

System Configuration

Making daapd run upon startup is a matter of installing the folloing init script (tested under Fedora only):

cat /etc/init.d/daapd
#!/bin/sh
#
# A startup script for the daapd DAAP server
#
# chkconfig: 345 98 2
# description: This script is used to start the daapd \
# server as a background process.\
#
# Usage /etc/init.d/daapd start|stop|reload|restart|status

# Source function library.
. /etc/rc.d/init.d/functions

DAAP_CONF=/etc/sysconfig/daapd/daapd.conf
DAAP_LOG=/var/log/daapd/access_log
prog=DAAP
exe=/usr/local/bin/daapd

start() {
        echo -n "Starting $prog: "
        if [ -f /var/lock/subsys/daapd ] ; then
                echo_failure
                echo
                exit 1;
        fi
        daemon $exe -c $DAAP_CONF >> $DAAP_LOG &
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/daapd && echo_success
        echo
        return $RETVAL
}

stop() {
        echo -n "Stopping $prog: "
        killproc $exe
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/daapd /var/run/daapd.pid
}

reload()
{
        echo -n $"Reloading $prog:"
        killproc $exe -HUP
        RETVAL=$?
        echo
}


case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $exe
        RETVAL=$?
        ;;
*)
        echo "Usage: daapd {start|stop|reload|restart|status}"
        exit 1
esac

(don't forget to create the log directory using mkdir -p /var/log/daapd)

...and running chkconfig to add it to the system services list and bind it to the proper runlevels:

# chkconfig --add daapd
# chkconfig --level 345 daapd on
# chkconfig --list  | grep daapd
daapd           0:off   1:off   2:off   3:on    4:on    5:on    6:off
# service daapd start
Starting DAAP:                                             [  OK  ]

Rendezvous Setup

With Fedora Core 3, publishing the DAAP server is simply a matter of adding the following line to mDNSResponder.conf:

# tail -1 /etc/howl/mDNSResponder.conf
"Music Jukebox" _daap._tcp.     local.  3689

If you've followed my Rendezvous HOWTO, making iTunes aware of your DAAP server is a simple matter of adding four lines to /etc/rendezvous.conf:

Music Jukebox
_daap._tcp.
none
3689

iTunes will then automagically display your server on its left-hand view.

Other methods exist, like using Network Beacon or invoking mDNSProxyResponderPosix by hand like so (taken from Mac OS X Hints):

mDNSProxyResponderPosix 10.0.1.201 squeal "Music Jukebox" _daap._tcp. 3689 &

Log Rotation

To make things really neat, drop into /etc/logrotate.d the following file:

# cat /etc/logrotate.d/daapd
/var/log/daapd/*log {
    missingok
    notifempty
    endscript
}

This wil ensure logrotate truncates the log file and removes old versions.

AAC Support

Jarrod Smith was kind enough to send along the following set of notes -

AAC support only requires a subset of the MPEG4IP package (just the mp4v2 library). As per the README.mpeg4ip file packaged with daapd 0.2.2b:

  tar xvfz mpeg4ip-x.x.tar.gz
  cd mpeg4ip-x.x/
  ./bootstrap --disable-server
  cp mpeg4ip_config.h /usr/local/include/
  cp include/mpeg4ip.h /usr/local/include/
  cd lib/mp4v2/
  edit Makefile:
      replace the line "SUBDIRS = . test util"
      with "SUBDIRS = ."
  make
  make install

Once that's done, you set MPEG4_ENABLE = 1 in the daapd makefile and rebuild as normal.

Known Bugs

There is a minor issue with the way the startup script is written - a bogus failure message is appended to the log file when you kill the DAAP server (this is due to some differences between Fedora and RedHat I'm not grokking yet, or sleep deprivation - not sure which, fixes welcome).


See Also: