Politics and Technology.

Sunday, December 21, 2008

Edna on Mac OS X

While I am warming up to iTunes thanks to my new AppleTV, there are times that I think it is more than what I need to listen to my music collection. Call me old school, but there's a certain elegance to simply browsing a folder and clicking on a song and expecting it to just play without bells and whistles.

While Finder can do this locally on a mac, I want access to my home library of music remotely from work. Using iTunes and Mojo is an option for remotely using my iTunes library, but I somehow feel this combo is going a little overboard. It feels like I'm using a sports car to drive from my garage to my curbside mailbox to pick up the mail.

That's where Edna comes in. Made "back in the day", she's a simple Python script that serves up m3u's of your audio files just as you have them organized in directories and sub-directories. A subsequent hack made it possible to do simple searches on the directory trees (one word searches, apparently). Before it gave up the ghost, I used Edna on my Centos box and forwarded the port through my firewall.

Since my jump to AppleTV, I've come to rely more and more on my iTunes for storing my music. I decided to get Edna working on Mac OS X and point it to my iTunes collection.

So to share this experience with those interested, I have included my steps here. I put together a tarball with all of the necessary files for the reader's convenience. If the reader decides to use my tarball, they should read the readme files and understand how to edit the configuration file for edna, at least. For instance, I believe the conf file in the tarball points to "/Volumes/itunes/music", not "/Users/jason/Music/iTunes".

First I had to get the Edna package and patch it with the search patch.

Then I had to install it with make install ("make" comes with the Xcode package).

Without make from Xcode, run install by hand instead. I had a difficult time getting python to see the "/usr/lib/edna" directory, so I had to soft link the two include files (ezt.py and MP3Info.py). Oddly, as a side note, when I upgraded my Macbook from Tiger to Leopard, and python 2.5 replaced 2.3, these links went away, but edna still worked. When I did a fresh install of Edna on a Leopard box, I still had to make the soft links. Weird.

sudo install edna.py /usr/bin/edna
sudo install -d /usr/lib/edna /usr/lib/edna/templates /usr/lib/edna/resources
sudo install ezt.py /usr/lib/edna
sudo install MP3Info.py /usr/lib/edna
sudo install -m644 templates/* /usr/lib/edna/templates
sudo install -m644 resources/* /usr/lib/edna/resources
cd /usr/lib/python2.5
sudo ln -s /usr/lib/edna/MP3Info.py
sudo ln -s /usr/lib/edna/ezt.py

Then I had to configure the conf file. The conf file in my tarball uses port 8000 to serve out.

sudo cp edna.conf /etc

Test it.

sudo /usr/bin/edna -c /etc/edna.conf
telnet localhost 8000

Then I had to create a service to run it at boot up. Using the Property List Editor, I created a StarupParameters.plist file with the prerequisite entries. I hacked together the startup file using the typical rc.common entries.

sudo mkdir /Library/StartupItems/MyEdnaServer
sudo cp MyEdnaServer StartupParameters.plist /Library/StartupItems/MyEdnaServer

SystemStarter can be used to test functionality. Note: if you are going to roll your own start-up and plist file, be sure to use the same name of your service as the "Description" in your plist file. It turns out that SystemStarter is pretty moody when it comes to descriptions.

sudo SystemStarter start MyEdnaServer
telnet localhost 8000

Using the handy "defaults" command, I then changed the firewall rules to allow connections to this new daemon. You could use the GUI instead, but as it was I did this remotely from work when I realized WHY I was having so much trouble connecting to Edna when it worked well at home that morning. Duh.

sudo defaults write /Library/Preferences/com.apple.sharing.firewall firewall -dict-add 'MyEdnaServer' '<dict><key>editable</key><integer>1</integer><key>enable</key><integer>1</integer><key>port</key><array><string>8000</string></array><key>row</key><integer>100</integer></dict>'

And that was that!

No comments: