Code I/O

A topnotch site

Leave a comment

Building a simple home entertainment server …

The need: Enable consumption of media in the home network, yet keeping portability of media storage intact.

Having tons of photos, music and videos (various formats) makes it hard to organize them, as well discovering them becomes critical as time passes by.  I was evaluating various solutions that will enable me to organize,  stream and discover them such that it can be consumed in my home network.  Yet, provide me a flexibility to port content when needed (especially when I travel).

I had the following options

  1. NAS (Network storage): bulky and non-portable.  The storage sits in a centralized location and transporting the drive might be difficult.  Not all storage devices lets installation of customer software.
  2. Boxee: Pretty good at organizing content, fetching sub-titles, however, I do not like sharing my private information.
  3. UPnP media server: a little cumbersome to configure, and good ones aren’t free.
  4. iTunes: Requires format change, and works only with Apple products.  Perhaps I might end up buying more Apple tools and products (iPod, iPad, …); which changes too quickly and makes my investment look ridiculous.

However, none of the above gives me portability.

What did I finally come up with?

  • Used a portable drive – to dump all my resources
  • Used an old system that runs Ubuntu with my portable drive connected.
  • Used AutoIndex to index the drive.  This is simple, lightweight, runs as a PHP module in Apache.
  • I’ve customized AutoIndex to make MP3 audio and Video (AVI, MPEG, MP4, MKV) playable  in a browser.  No plugin is required for MP3, however, it depends on a browser plugin for Video.  I’ve also added icons for GNOME;  You can try out the updated code by downloading it from here.

I’ve also submitted the new changes to AutoIndex (in a discussion: )

When at home, use the media server, when on the go, just unplug the drive and take it along 🙂  Thus bringing in convenience and portability together.

The sandbox was built with:

  1. An old PC (a Pentium processor).
  2. Ubuntu Lucid Lynx
  3. Apache 2.0
  4. PHP 5.0
  5. AutoIndex
  6. Firefox 3.6.9 Browser

Leave a comment

5 Minutes on Linux: Automating app launch on boot

Adding corn jobs is a way to automate launching of apps. Another approach is to make those apps launch when a user logs in. Depending on how the app must be started up, one can make the right choice.

Add a wrapper to the binary to launched in /etc/init.d

echo "/home/tester/tools/apache-httpd/bin/apachectl $1" > /etc/init.d/start-apache
update-rc.d start-apache defaults 3
service start-apache start

Here is my experience: I wanted to index media on an external drive; one of the coolest indexing app I found is AutoIndex which is a PHP module (so runs under apache httpd); however this possessed a challenge. The external NTFS driver gets mounted by gvfs (fuseblk); Since I wanted to manage the drive via gvfs (and not via ntfs-3g mounting via fstab), I thought it was a good idea to leave it that way.

Now the challenge was to get apache running as a service (launched by user “daemon”) to access the gvfs mounted drive. The permissions cannot be changed (at least I have not found a resolution there).

Then, what’s the solution?

Install apache and php modules in a user account (user: tester)
Make the tester auto-login on boot
Add apache (user installed) to launch on login: (GNOME: System -> Preferences -> Startup Applications")
Add "gnome-screensaver-command -l" (Lock the screen): (GNOME: System -> Preferences -> Startup Applications")

You’ll have the user installed apache running on boot and have the screen locked for security purposes.

This is a hack I did at home to get media streaming work with drives mounted by gvfs.