Pages

September 20, 2008

Music Playing Daemon: setup

I've been having way too much fun with MPD lately. It is now my default tool for music listening at home. I am using Music Player Minion, Ario, and QMPDClient on my Windows laptop to control the server, gmpc as a Linux GUI client (Etch doesn't have Ario or QMPDClient), mpc for terminal one-offs, and ncmpc for SSH sessions. Phew. I haven't gotten around to trying Bluetooth devices, etc. It's all quite cool.

As with many things Linux, setting up MPD can be a bit confusing. Below I describe my current setup, which was designed for a reasonable but not paranoid amount of security. It's all quite geeky. If you are not capable of this level of geek, you might want to stay away from MPD until you are.

I will assume that you have already installed MPD and (optionally) Samba. You can point MPD at any directory for it's source of music. Since it's a server and gets launched at system startup (at least in Debian Etch and therefore SkinnyDebbie), I decided the best place to store files is in a system directory rather than directory inside a user's home directory.

So here's what to do:

Make a group called music:

sudo groupadd music

Now create a directory to store your music collection -- I suggest /srv/media/music. Set the directory to be owned by mpd and of the music group:

sudo chown mpd:music /srv/media/music

Note: The group name created above does not need to match the directory name.

Set /srv/media/music so that members of the group music have write permission and all other have read permission:

sudo chmod 775 /srv/media/music

Note: /srv and /srv/music need to have their read and execute bits set for everyone. This will happen by default on most systems, but if this isn't the case in your case:

sudo chmod 755 /srv
sudo chmod 755 /srv/media


Edit /etc/mpd.conf so that MPD points to the new directory
music_directory         "/srv/media/music"
playlist_directory "/srv/media/music"
While you are in /etc/mpd.conf, to make MPD is reachable by clients outside the localhost, comment out the line:
bind_to_address    "localhost"
by placing a # in front of it. Now is also the time to set a MPD server password if you want one, change its port number, etc.

Add users you want to be able to manage the music collection to the "music" group

sudo usermod -a -G music <username>

Note: the user must logout and log back in for changes to take effect.

Optional: if you are using Samba to share files on the network, create a share called "Music" and make it fully public by adding to /etc/smb.conf:
[Music]
path = /srv/media/music
browseable = yes
read only = no
Linux's underlying permissions will keep members who are not in the "music" group from writing to the directory. Note that whatever you copy into this folder will be owned by the user who copied it in. Therefore permissions must allow MPD to read all files. This will happen by default on most systems, but if you have problems you can check this.

Be sure to update the MPD database when you add new music:

mpc update

You might consider is setting up a cron job to periodically update the database.

No comments: