How to: Compile and run Mediatomb as a daemon with Ubuntu 9.04

Since getting my PS3, then setting up my Ubuntu file server, I’ve really enjoyed watching movies on my TV. To get the media from computer to Playstation requires the use of software that employs the UPnP protocol, in the form of a DLNA server.

If there are too many acronyms in there, just remember the name Mediatomb. Mediatomb is an open-source, cross-platform DLNA server that streams a variety of media formats across a local network to whatever compatible device you happen to have running at the end. It can stream video, music, photos in numerous formats, and will even transcode others so that they can stream as well. All this tinkering comes at the expense of user-friendliness, though. In most cases, the regular binaries for each operating system will do most of the cool tricks I mention here. To get the most out of the system, however, requires you to compile from source.

As mentioned in my previous file server post, I’m running Ubuntu 9.04 Jaunty Jackolope on a “headless” Intel server, which I control via the terminal. Since the computer doesn’t restart, I wanted it to run as a daemon, which was where I ran into a problem. For some reason, Jaunty didn’t play nice with the standard daemon package, so I had do a little digging to find the solution.

Steps

  1. Create a temporary working directory by issuing this command
    $ mkdir temp
  2. Install the ffmpegthumbnailer libraries by installing libffmpegthumbnailer. Use the command sudo apt-get install libffmpegthumbnailer and enter your admin password when prompted.
  3. Compile ffmpeg using the tutorial at Juliensimon.blogspot.com but include the configure tag --enable-libffmpegthumbnailer. Don’t move on until the configuration confirms thumbnailer installation.
  4. Compile and install the Mediatomb binaries from source — again, I used the excellent tutorial at Juliensimon.blogspot.com
  5. Check the functionality of Mediatomb to issuing the command $ mediatomb then opening a web browser to http://ip_of_server:49152/
  6. To make the daemon work, first download the daemon package by issuing this command (one line)
    $ wget http://mirrors.kernel.org/ubuntu/pool/universe/m/mediatomb/mediatomb-daemon_0.11.0-3ubuntu2_all.deb
  7. Now extract the files in the package to the temporary directory created earlier
    $ dpkg-deb -x mediatomb-daemon_0.11.0-3ubuntu2_all.deb temp

    As you can see, the daemon package is just a collection of configuration files, so installing it properly is just a matter of copying the files back.

  8. Change to the temporary directory with the files by typing
    $ cd temp_directory_name
  9. Type these commands one line at a time to copy the files back to their rightful place. The commands with two lines should be printed as one single command.
    $ sudo cp etc/mediatomb/config.xml /etc/mediatomb/config.xml

    $ sudo cp etc/default/mediatomb /etc/default/mediatomb

    $ sudo cp etc/init.d/mediatomb /etc/init.d/mediatomb

    $ sudo cp etc/logrotate.d/mediatomb /etc/logrotate.d/mediatomb

    $ sudo cp usr/share/doc/mediatomb-daemon/README.Debian usr/share/doc/mediatomb-daemon/README.Debian

    $ sudo cp usr/share/doc/mediatomb-daemon/changelog.Debian.gz /usr/share/doc/mediatomb-daemon/changelog.Debian.gz

    $ sudo cp usr/share/doc/mediatomb-daemon/changelog.gz /usr/share/doc/mediatomb-daemon/changelog.gz

    $ sudo cp usr/share/doc/mediatomb-daemon/copyright /usr/share/doc/mediatomb-daemon/copyright

    If the copy comes back with errors about directories, you’ll likely have to use the mkdir to create the requested folders.

  10. Now the important step is setting the proper permissions of the folder /var/lib/mediatomb. Change into that directory by issuing
    $ cd /var/lib/
  11. The folder /var/lib/mediatomb should contain 3 files:
    $ ls mediatomb
    mediatomb.html
    sqlite3.db
    sqlite3.db-journal
  12. Change the ownership of the folder and its contents.
    $ chown -R mediatomb:mediatomb mediatomb
  13. Change the permissions of the HTML file.
    $ sudo chmod 666 mediatomb/mediatomb.html
  14. Change the permissions of the remaining two files:
    $ sudo chmod 644 mediatomb/sqlite3.db
    $ sudo chmod 644 mediatomb/sqlite3.db-journal
  15. Make the script run at startup.
    $ update-rc.d mediatomb defaults

To start the server, simply issue the command sudo /etc/init.d/mediatomb start. If the server doesn’t start, view the Mediatomb log file to see what else is happening.

$ vi /var/log/mediatomb.log

Exit with :q. I’ve been running this setup since I first built the server, and it has worked exceptionally well.


{ 4 comments… add one }

  • Bill Weswtrup March 27, 2010, 10:34 pm

    I know you mean well…but you have quite a few errors in your instructions

    sudo cp usr/share/doc/mediatomb-daemon/README.Debian usr/share/doc/mediatomb-daemon/README.Debian – fails
    $ sudo cp usr/share/doc/mediatomb-daemon/README.Debian usr/share/doc/mediatomb-daemon/README.Debian- fails

    $ sudo cp usr/share/doc/mediatomb-daemon/changelog.Debian.gz /usr/share/doc/mediatomb-daemon/changelog.Debian.gz – fails

    $ sudo cp usr/share/doc/mediatomb-daemon/changelog.gz /usr/share/doc/mediatomb-daemon/changelog.gz – fails

    $ sudo cp usr/share/doc/mediatomb-daemon/copyright /usr/share/doc/mediatomb-daemon/copyright – fails

    If your having to set this up manually, you will have to create directories…why not simply include that.

    also prependng every line with $ makes it very tedious to cut and past each line….

    why not a bash script for those already know how to copy files at the command line?…. :-)

  • Bill Weswtrup March 27, 2010, 10:42 pm

    “The folder /var/lib/mediatomb should contain 3 files:”

    If you compile from source, they won’t…

  • Bill Westrup March 27, 2010, 10:46 pm

    OK heres a start on the script…still has errors though

    #!/bin/bash
    wget http://mirrors.kernel.org/ubuntu/pool/universe/m/mediatomb/mediatomb-daemon_0.11.0-3ubuntu2_all.deb
    dpkg-deb -x mediatomb-daemon_0.11.0-3ubuntu2_all.deb temp
    cd temp
    sudo mkdir /usr/share/doc/mediatomb-daemon
    sudo cp etc/mediatomb/config.xml /etc/mediatomb/config.xml
    sudo cp etc/default/mediatomb /etc/default/mediatomb
    sudo cp etc/init.d/mediatomb /etc/init.d/mediatomb
    sudo cp etc/logrotate.d/mediatomb /etc/logrotate.d/mediatomb
    sudo cp usr/share/doc/mediatomb-daemon/README.Debian /usr/share/doc/mediatomb-daemon/README.Debian
    sudo cp usr/share/doc/mediatomb-daemon/changelog.Debian.gz /usr/share/doc/mediatomb-daemon/changelog.Debian.gz
    sudo cp usr/share/doc/mediatomb-daemon/changelog.gz /usr/share/doc/mediatomb-daemon/changelog.gz
    sudo cp usr/share/doc/mediatomb-daemon/copyright /usr/share/doc/mediatomb-daemon/copyright

    cd /var/lib/
    ls mediatomb
    chown -R mediatomb:mediatomb mediatomb
    sudo chmod 666 mediatomb/mediatomb.html
    sudo chmod 644 mediatomb/sqlite3.db
    sudo chmod 644 mediatomb/sqlite3.db-journal
    update-rc.d mediatomb defaults

  • wesg March 27, 2010, 11:07 pm

    @Bill Weswtrup: Thanks for the messages, Bill! I haven’t had the chance to try my solution from start to finish yet, but it sounds like your script can help out a lot. I will give it a try when I find some time.

Leave a Comment

Next Post:

Previous Post:

Twitter Feed