Quickstart FreeBSD

From MtdWiki

Table of contents

FreeBSD Quickstart

Contributors: Kevin Reiter, Jamie Wilkinson

This Quickstart guide was first written by Kevin Reiter. See the original here (http://unixfun.net/howto/bsd/itunes.html).

This was done on FreeBSD 6.0 with a current Ports tree as of 17May2006, and tested using iTunes v6.0.4.2 on a Windows XP Pro laptop. It has been updated to reflect FreeBSD 6.2 as of 2007 June 21, which does not require any mucking about with mDNSResponder


Overview

It is extremely easy to get mt-daapd running on FreeBSD, and fairly straightforward to then update it with the latest nightlies to keep things interesting.

Ports Required

  • audio/mt-daapd


Building from ports

Just build the port.

root@host# cd /usr/ports/audio/mt_daapd
root@host# make install

Add the following lines to your /etc/rc.conf file:

mt_daapd_enable="YES" 

Building the latest nightly from source

  • Download the latest nightly tarball & unpack
  • Requires sqlite and libid3tag ports (should be installed if you previously installed mt-daapd with ports)
  • Recommend installing the port first, which will automagically fetch dependencies and give you a nice rc.d script


 ./configure  --enable-sqlite --with-id3tag=/usr/local --with-gdbm-includes=/usr/local/include --prefix=/usr/local CFLAGS="-O2 -fno-strict-aliasing -pipe"   CPPFLAGS=" -I/usr/local/include"
 sudo make install


If you want to use sqlite3 simply install the databases/sqlite3 port and use '--enable-sqlite3'. You may need to delete your /var/db/mt-daapd or fanangle with directory ownerships -- watch the mt-daapd.log file for more info.

Configure mt-daapd

  • Normally you should already find the file mt-daapd.conf in /usr/local/etc, but if not, copy mt-daapd.conf.sample to mt-daapd.conf:
root@host# cd /usr/local/etc
root@host# cp mt-daapd.conf.sample mt-daapd.conf
  • Now edit mt-daapd.conf as appropriate. Here's mine with the comments removed for easier reading:
# $Id: mt-daapd.conf,v 1.9 2004/04/18 20:24:14 rpedde Exp $

web_root	/usr/local/share/mt-daapd/admin-root
port		3689
admin_pw	mypassword  # Admin password for the control panel
db_dir		/usr/local/var/mt-daapd/db
mp3_dir		/usr/local/music # Change this to wherever your music lives
servername	Chronos iTunes Server # Name this whatever you want it to show up in iTunes as
runas		daapd
playlist	/usr/local/etc/mt-daapd.playlist # Change as appropriate
password	mypassword # Change this to require users to enter a password
extensions	.mp3,.m4a,.m4p
logfile		/var/log/mt-daapd.log
# db_type	sqlite	# sqlite by default, can change to sqlite3
  • If you want to have playlists displayed within the server (in iTunes), then create the playlist

file (/usr/local/etc/mt-daapd.playlist) and add whatever genres you want. Here's mine as a sample:

 # Playlist for my iTunes server
"Celtic" {
genre includes "Celtic"
}

"Country" {
genre includes "Country"
}

"Soundtracks" {
genre includes "Soundtrack"
}

This will be displayed within iTunes like this: <to be filled>


Start mt-daapd

Now, start the mt-daapd and mDNSReponder servers:

root@host# /usr/local/etc/rc.d/mt-daapd.sh start

(this can be quite time-consuming, as it will first scan your mp3-directory, so it can take several minutes on big libraries (tenthousands of files))

In order for iTunes to see the server, you need to configure iTunes to look for shared music. This is done by checking a box within the Preferences menu under "Sharing", as shown here:

<to be filled>

If you remember when editing the mt-daapd.conf file, you were asked to provide a password for the web control panel. In order to access the panel, open a browser and point it to your iTunes server on port 3869:

http://myserver:3869

Login with the username "admin" and your password. From there you can view how many listeners are connected, which songs are being streamed, and even modify your server configuration (provided your mt-daapd.conf file is writable by the daapd user.)

(You don't have to modify any Apache settings, or even have Apache installed for this.)

For debugging

If you have any problem with mt-daapd (server not starting, not visible in iTunes) you can start it in foreground and watch the log in realtime. To do this, just type

root@host# mt-daapd -d <number> -f -c /usr/local/etc/mt-daapd.conf

where <number> is something between 0 and 9, the higher the number, the more verbose the output. The default is 4, but 5 can be useful to watch filenames while scanning the mp3-directory.

If you are running another mDNSResponder

The mDNSResponder is Apples way of zero config network. It tells clients what services can be found on a server, for example daap for iTunes, APF the Apple File Sharing or SSH. You need a mDNSResponder so shares pop up automatically in iTunes, the Finder and so on.

mt-daapd brings it's own mDNSResponder which is great for instant start. But if you already have another mDNSResponder service runnig (for example howl for netatalk (Apple File Sharing)) you have to disable the builtin one.

Disabling the builtin mDNSResponder

To do this, open the file /usr/local/etc/rc.d/mt-daapd and change the line

command_args="-c /usr/local/etc/mt-daapd.conf"

to

command_args="-c /usr/local/etc/mt-daapd.conf -m"

At the next start, mt-daapd won't start a mDNSResponder component.

Add mt-daapd to another mDNSResponder

If you have howl installed, you should find a file called mDNSResponder.conf in /usr/local/etc . Open it and add the following line:

YourServerName    _daap._tcp   local.    3689

Restart the mDNSResponder

root@host# /usr/local/etc/rc.d/mdnsresponder restart


Set up startup scripts (optional)

<to be filled>

Other resources

<to be filled>