Running Mediatomb on CH3WNAS natively!

I managed to get MediaTomb running on the Grab'n'Go CH3WNAS without gentoo! There is no need to follow the gentoo steps in http://forum.dsmg600.info/t916-Installing-mediatomb.html since the MediaTomb project itself provides binaries for the PPC cpu with no dependencies. MediaTomb provides you a better uPnP Server than the original upnp in the firmware.

Since uPnP has no authentication, make sure you run the CH3WNAS behind a NAT router!

Those are the steps to setup MediaTomb on the CH3WNAS:
  • Download the mediatomb build for the ppc-platform:
    (or, to get the latest version, surf to http://mediatomb.cc/pages/download#static and then click on the latest mediatomb-static*-ppc*tar.gz file)

  • unzip the tar.gz and ftp (e.g. with gftp) the full mediatomb-directory to the CH3WNAS under HD_a2 (= /mnt/HD_a2/ on the device)

  • telnet to the device (scroll down in my previous post for fun_plug'in and enabling telnet)

  • make executable:
    chmod 775 /mnt/HD_a2/mediatomb/usr/bin/mediatomb

  • chmod mediatomb.sh for easier ftp(*):
    chmod 777 /mnt/HD_a2/mediatomb/mediatomb.sh

  • edit (e.g. with ftp mediatomb.sh to start mediatomb as daemon +fix LAUNCHDIR bug):

    # if you want to launch this script from a different directory (for example
    # from an another init script or similar, set the LAUNCHDIR variable below
    # to the absolute path of the mediatomb.sh script


    rm -f $LAUNCHDIR/mediatomb.log

    export MEDIATOMB_DATADIR="$LAUNCHDIR/usr/share/mediatomb"
    export MEDIATOMB_MAGIC_FILE="$LAUNCHDIR/usr/share/file/magic"
    $LAUNCHDIR/usr/bin/mediatomb -m $LAUNCHDIR -f config -d -l $LAUNCHDIR/mediatomb.log

    !! Remark: Make sure the script is Unix-encoded (single \n for line-breaks), otherwise you'll get a "-ash /mnt/hd_a2/mediatomb/mediatomb.sh" error. try this command to translate the linebreaks:
    /mnt/HD_a2/busybox dos2unix /mnt/HD_a2/mediatomb/mediatomb.sh > /mnt/HD_a2/mediatomb/mediatomb.sh.new
    mv /mnt/HD_a2/mediatomb/mediatomb.sh.new /mnt/HD_a2/mediatomb/mediatomb.sh
  • a first run will create the config.xml:
    then run kill `pidof mediatomb` to stop the daemon

  • for easier editing of the config.xml (*):
    chmod 666 /mnt/HD_a2/mediatomb/config/config.xml

  • now modify (ftp) the newly created /mnt/HD_a2/mediatomb/config/config.xml in order to add a fixed ipadres or interface and optional port.

    <name>Michael's MediaTomb</name>
    <!-- or define port <interface>br0</interface> -->
    <protocolInfo extend="yes"/>
    <!-- add extra mappings for jpeg / mpeg -->
    <map from="JPG" to="image/jpeg"/>
    <map from="jpg" to="image/jpeg"/>
    <map from="mpg" to="video/mpeg"/>
    <map from="m4a" to="audio/mpeg"/>
    The config.xml is well-documented at http://mediatomb.cc/pages/documentation#id2536421. Check out the docs in order to support for example PS3 connections.
  • for auto-startup, you can add the following lines your fun_plug:
    #kill legacy upnp
    kill -9 `pidof upnp`

    #start mediatomb

    As you can see, I still run firefly, because I couldn't get a uPnP client working in Ubuntu (Rhythmbox).

  • after startup, connect to MediaTomb for configuring the directories to watch: (e.g.)
I'm not 100% sure that my config is OK, because I couldn't get Rhythmbox (+python-coherence) connecting to MediaTomb. I can see the uPnP broadcast messages from MediaTomb in WireShark and the Cidero java client can connect to MediaTomb and show a tree of media files. Cidero has no playback capabilities, so it's still possible I'll have to tweak the config a bit.

update 9/7/2008: fixed the config for serving jpeg (see comments below) / using correct 'magic' files. If you used a previous version of this post, delete the bogus config.xml and mediatomb.db* files and follow the steps starting with fixing mediatomb.sh.

(*) Close this small security hole: revert to the original protection with a chmod 440 or 550 afterwards. Of course, with telnet and upnp enabled, you'd better keep the CH3WNAS behind a NAT router.
Post a Comment