Skip to content


Dual Location MPD File Stores

I run a mpd server on my laptop as I like the gmpc music client. I use my laptop both at work and home. When I am at home I have my laptop on the dock most of the time and my music is located on my file server under a directory /storage/music/. This is normally mounted to /mnt/storage/music. When I am at work I have a little media system that holds all my music in the folder /media/music. Up till today I was using to separate gmpc profiles and having to switch them manual. This created havoc if the mount point was not mounted when mpd started up.

Since both music directories on the servers contain the same music with the same file layout, I decided to write a quick little script to correct this and make playing music at home and work as simple as possible.

First I wanted to run my script on boot up of the system.

This use to be done with a bootmisc file located in /etc/… Not sure why this is gone in this day and age but I found a nice little howto and will break it down short for you.

as root:

touch /etc/init.d/bootmisc.sh

chmod +x /etc/init.d/bootmisc.sh

update-rc.d bootmisc.sh start 20 2 .

The above few lines will create a file called bootmisc.sh in /etc/init.d/ that you can put some handy bash commands in to run on startup. Good for more than just setting up mpd how you want auto magically.

Next we need to make our script to load mpd depending on our location


ifconfig | grep '172.16.10.'

if [ "$?" = "0" ]; then
mount 192.168.0.2:/storage/music /home/richard/Music
/etc/init.d/mpd restart
/etc/init.d/mpdscribble restart
fi

ifconfig | grep '192.168.0.'

if [ "$?" = "0" ]; then
mount 192.168.0.2:/storage/music /home/richard/Music
/etc/init.d/mpd restart
/etc/init.d/mpdscribble restart
fi

Paste the above in your bootmisc.sh file we created and setup mpd to load the music from the default ubuntu ~/Music folder on your system.

To explain the above a little I will just say that it will check for you ip address, and depending on which ip address you have issue the mount command for the server it needs. Anyone that knows basic Bash should be able to figure out how to change this to what they need, but if you stumble across this and really need it to work and have no clue what needs to be done just leave a comment and I will try to explain this a little more.

I am loving the boot up and play my tunes from a remote server with no mounting or restarting of mpd! :)

Posted in Computers.

Tagged with , , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Spam protection by WP Captcha-Free