Remote Power off the CH3WNAS

In my previous post, I found out that the CH3WNAS is shutdown by touching a /tmp/shutdown file. It is possible to use the existing web admin pages to trigger a remote shutdown from a script by using 2 wget-commands. One major drawback of this solution is that your admin-password is stored in cleartext in the script.

In this post I show how you can do a remote shutdown via the LAN, without hard coding your admin password. Since this tweak could be misused for a remote DOS attack, make sure you put the CH3WNAS behind a NAT router.

Busybox (activated with the fun_plug script) provides a powerful nc (netcat) command that also has a -l listen mode. This listen-mode is ideal for simple lightweight client/server communication.

Steps for enabling remote shutdown from a script:
  • make sure telnet (through busybox) is enabled: http://www.aroundmyroom.com/2008/01/03/ch3wnas-enabling-telnet/

  • create a shutdown_listener.sh script (e.g. with ftp) on the root of HD_a2 with following contents:
    while true
      /mnt/HD_a2/busybox nc -l -p 1234 | while read line
         if [ "$line" -eq "0" ]
           touch /tmp/shutdown
    This scripts on the NAS listens in a loop on port 1234. When it reads a "0" it puts a /tmp/shutdown file that triggers the immediate poweroff.

  • add the following line to the fun_plug script and restart the CH3WNAS:
    /mnt/HD_a2/shutdown_listener.sh &

  • from the client-side it's enough to create a nc-script that sends a "0" to the NAS.
    on Ubuntu I created a Launcher on my desktop with following command :
    bash -c "echo 0 | nc 1234 -w 1"

    If you're stuck with Windows, look out for a Windows version of netcat (nc) and put similar commands in a shortcut (cmd /c "..."). Or better, upgrade to Ubuntu :-)
I finally have a script that I can put on all my laptops to trigger a remote shutdown of the NAS. Unfortunately, for powering the device back ON again, you still have to push the powerbutton.


Getting Compiz to run on Ubuntu 8.04 with an ATI X700 chipset

One of my laptops, a Medion md96500, I couldn't start Compiz after I upgraded it from Ubuntu Gutsy to Hardy (8.04). I remember that when I installed 7.04, I had to do some tweaking to get the video working. Luckily, since Ubuntu 7.10, the display configuration goes really well 'out of the box', but maybe some of my tweaks of last year did survive in my current Hardy install (8.04). This is the video chipset in my MD96500:
$ lspci | grep VGA
01:00.0 VGA compatible controller: ATI Technologies Inc M26 [Radeon Mobility X700 XL (PCIE)]

I tried to play with the "Hardware Drivers" dialog-box, but this didn't help. Luckily, fixing was rather easy:
  • I removed the proprietary fglrx-driver of ATI and switched back to the open-source driver. This is well documented in: https://help.ubuntu.com/community/RadeonDriver. The switch went rather smoothly, but compiz still failed when trying to activate it.
  • Next, I ran the excellent compiz-check script http://forlong.blogage.de/article/pages/Compiz-Check. As you can see in the output, compiz-check not only detects that my x700 is blacklisted, but it also fixes it by letting Compiz ignore the blacklist:
$ ./compiz-check

Gathering information about your system...

Distribution: Ubuntu 8.04
Desktop environment: GNOME
Graphics chip: ATI Technologies Inc M26 [Radeon Mobility X700 XL (PCIE)]
Driver in use: radeon
Rendering method: AIGLX

Checking if it's possible to run Compiz on your system...

Checking for texture_from_pixmap... [ OK ]
Checking for non power of two support... [
OK ]
Checking for composite extension... [
OK ]
Checking for FBConfig... [
OK ]
Checking for hardware/setup problems... [FAIL]

There has been (at least) one error detected with your setup:
Error: Laptop using radeon driver.

Would you like to know more? (Y/n) Y

It has been detected, that you are running a laptop with an ATI chip.
The radeon driver supports Compiz out-of-the-box but because of a nasty bug
in the driver that causes X to freeze on some cards, this particular
combination had to be blacklisted in Ubuntu "Hardy Heron".

In case you already used Compiz successfully on Ubuntu 7.10 (Gutsy), it is
safe to skip the blacklist.

Do you want to skip blacklist checks by Compiz? (y/N) y

$ ./compiz-check

Gathering information about your system...

Distribution: Ubuntu 8.04
Desktop environment: GNOME
Graphics chip: ATI Technologies Inc M26 [Radeon Mobility X700 XL (PCIE)]
Driver in use: radeon
Rendering method: AIGLX

Checking if it's possible to run Compiz on your system...

Checking for texture_from_pixmap... [
OK ]
Checking for non power of two support... [
OK ]
Checking for composite extension... [
OK ]
Checking for FBConfig... [
OK ]
Checking for hardware/setup problems... [
OK ]
Compiz is now fully functional on my laptop, and till now, it seems stable. gr8 :-)


Banshee 1 on Ubuntu

I listened to the recommendations of the Linux Action Show and installed Banshee v1 on my Ubuntu laptop. I simply followed the steps in http://www.simplehelp.net/linux/how-to-install-banshee-10-in-ubuntu/. If you hate the command-line, use Synaptic Package Manager for installing the banshee-1 package and it's dependencies.

I'm not a big fan of the mono environment and its Microsoft origin, but I must admit: starting banshee V1 gives the 'wow'-effect. It looks like a rhythmbox on steroids:

As you can see, my muvo v100 is recognized and it shows a nice "memory available" graph. Generic USB devices like the v100 must define a .is_audio_player file in the root to be automatically recognized by banshee or rhythmbox. Banshee also has a user-friendly "eject media device" option in the context-menu.

And there is built-in podcast support. You cannot import a list of podcasts, but the "add podcast" automatically pastes the url that you copied from another window. You cannot remove older podcast from the list, but you have to "mark them as old". When copy/pasting to the media device, it uses the (usually) bogus "artist" data of the podcast. I couldn't find a way to "autosync" podcasts to my mp3 player yet.

I didn't try to connect to my firefly daap or mediatomb upnp server, but mediatomb should work through djmount at least. But maybe I'll use samba for read & write access.

I noticed a few minor problems:
  • the banshee icon is enlarged when you put the menu-bar on the left (or right) side of the screen (see screenshot above)
  • when the usb media player is already mounted, banshee hangs at startup:

I suppose those problems will be fixed soon. And perhaps Ubuntu should update the banshee package in their distro and why not, consider replacing Rhythmbox.

update 27/6/2008: Unfortunatly banshee hangs / crashes quite often once you use it more. I'm still using Rhythmbox for my 'normal' media player stuff, surviving with Rhythmbox's limitations: single threaded (and buggy) podcast retrieval, picky when media drive is unmounted, too simple media device support, almost no configuration options... But at least Rhythmbox doesn't crash that often.

update 22/1/2009: Banshee is much more stable now and really usable as a music player, more 'finished' than rhythmbox. Unfortunately, the podcast retriever still has a bug: when the download speed is too low, the download stops; retrying will download the full podcast again and fails again when the bandwidth is still too low (I experience this with e.g. 'Buzz out Loud'). It seems like a core Mono bug since no stacktrace is logged. I reverted to gPodder as my podcast client.

Restaging the CH3WNAS

Suddenly, after a reboot, my CH3WNAS couldn't start the wireless. It connected to a different ip address than the fixed I assigned it, and the admin-pages didn't react correctly to my actions: e.g. you couldn't see the existing users, but when adding a user I got a "User already exists" error message. Even the ftp server wasn't reacting. Through telnet, I could disable the fun_plug script, but that didn't solve the problem either.

Finally, I reset the firmware in the admin-pages, and the setup my wireless/ftp again. I re-enabled the fun_plug and everything is OK now: telnet is available and I can connect to firefly and mediatomb to access my music...

As a first prevention measure, I edited the firefly.conf file to log onto the hard drive instead of filling up /var/log:
logfile = /mnt/HD_a2/firefly/mt-daapd.log
We'll see if this helps...


Tweaking the CH3WNAS Power Off

On the CH3WNAS, you have to press the power button for an endless 10s before it finally shuts down. Apparently this 10s delay is determined by the /usr/sbin/chkbutton daemon that polls the power button. There exists a replacement for this process for the dsm-g600 in http://forum.dsmg600.info/t955-chkbutton-replacement.html.
Unfortunately, I couldn't download the attachment to try it out on the CH3WNAS. I asked the author to resubmit his binaries. Maybe for a next post...

There is also shutdown-option in the web-admin pages. After logon, the shutdown is done by firing a POST /goform/sysShootDown request onto the CH3WNAS. After some searching in the sourcecode (download it from the conceptronics' site), I found out that CH3WNAS_GPL/goahead/LINUX/web_api.c handles the shutdown:
void sysShootDown(webs_t wp, char_t *path, char_t *query)
if( checkIdleTime(wp) == WEB_IDLE_TIMEOUT )
websRedirect(wp, T("web/login.asp"));
system("touch /tmp/shutdown");
websRedirect(wp, T("web/tools/shutdown.asp"));
--> A simple (but unconventional) touch /tmp/shutdown triggers the shutdown. I suppose it's the same chkbutton daemon process that monitors and picks up the /tmp/shutdown file.

If you need to do a fast remote shutdown, you can exercise the existing web-interface from command line (the wget is standard under linux; under windows, have a look at wget for windows):
wget -o /tmp/test ""
wget -o /tmp/test2 ""
Replace the ip & password according to your local setup. Put those commands in a script and you get a simple way to shutdown the unit remotely with a simple double-click. The problem with this code is that you have to put your admin-password in cleartext on your pc. I haven't figured out yet how to circumvent the logon page to remove this security-issue.


SpringOne 2008 - Inside SpringSource Application Platform by Rob Harrop

The S2AP builds on OSGI and enriches it with a lot of functionality: e.g. combining relating bundles in libraries.

See SpringSource for details.

SpringOne 2008 - What's new in Spring MVC 2.5 and beyond by Keith Donald

@MVC (=Spring MVC 2.5)
The @Controller is now the recommended way to build a controller in Spring-MVC. It allows any pojo to act as a MultiActionController, but without the need to extend any class. In a @Controller class you can group all logical actions together. The classes with the @Controller are found automatically through classpath scanning.

The @Controller maximally relies on naming-conventions for your classes and methods to intercept URL-patterns (e.g. "Hotels.index()" is accessible through "/hotels/index"). Of course, this is customizable. All action methods have plain java types, but can also, if needed, ask for special parameters like Request, Response,... etc. @MVC detects those parameter types and injects them automatically.

If the action-methods return a String, then this is assumed to be the view-identifier. If it's a non-string, the returned object is then made available for the view. The modelobject is named by using generics: e.g. List<hotel> will be called 'hotelList' in the view.

Spring JS
  • enhance or decorate existing elements
  • render subfragments --> uses Apache Tiles for composition
  • use dojo query() to decorate multiple elements on a page.
WebFlow 2 (+ 'Deep Dive' session)
  • lighter, more consise syntax: e.g. first state is start-state by default.
  • Ajax enabled through: ViewScope
  • extensive Expression Language use
  • abstract flows that can be extended
  • better JSF support
  • (new) best practice: put flow with associated template (e.g. jsp), messages and resources and in same directory --> relies on simpler defaults
  • Spring Security
WebFlow 3
Will add a site-definition language to mix non-webflow pages with webflows.

SpringOne 2008 - Using Spring Web Services 1.5 by Arjen Poutsma

Contract-first is considered best practice for designing a WebService:
  1. create a sample xml message
  2. generate the xsd based on the xml: use trang or XmlSpy
  3. tweak the xsd
Define your Spring-WS endpoints as a POJO with @EndPoint:
  • input message
  • start a business service
  • result message
Let Spring generate the WSDL-boilerplate around your existing xsd and @Endpoints. For the xml parsing/generation, you can use SAX, DOM or Trax or use a more advanced (un)marshaller with the Spring OXM module: e.g. Jaxb2 or XmlBeans.

For testing your WS, use soapUI.

Other Spring WS features are:
  • pluggable interceptors: logging, optional validating,...
  • client WS: WebServiceTemplate
  • WS over JMS or SMTP
  • OSGI Bundles
  • WS Security (see ws.apache.org/wss4j/)
  • WS-Addressing

SpringOne 2008 - Keynote 2 by Adrian Colyer and Rob Harrop

Spring Dynamic Modules (formerly called Spring OSGI) extensively builds on OSGI.
  • Bundles can be loaded/replaced dynamically at runtime
  • multiple versions of bundles can coexist
  • with the import-library extension, you can import a collection of bundles
  • most common OSGI bundles are available at http://springsource.com/repository
  • it provides IDE integration through Spring IDE
The SpringSource Application Platform builds further on the Dynamic Modules concept.
Through 'personalities', the platform only loads what you really need:
  • batch: no web / servlet api needed; only jar
  • online: servlet api , but perhaps no JMS etc...
--> startup time / footprint is minimized.

SpringOne 2008 - Decorating Web Pages with AJAX using Spring JavaScript by Jeremy Grelle

Spring JS provides a javascript layer above Dojo. The Dojo javascript files are provided by Spring JS in a gzipped format. The dojo-integration is pluggable and will be enhanced with other javascript tool sets (e.g. jQuery).

The basic idea is to start from a fully-functional 'classical' webapp and progressively enhance the application with AJAX. But: even with javascript disabled, the page must remain functional, degrading back to it's basic behavior - really interesting, since I'm a big noscript fan :-). The Ajax page-elements are defined with Apache Tiles and served as a whole or through fragments depending on the request-type. WebFlow support serving separate 'fragments' in one state to allow for example pagination without page-refresh.

Spring JS also provides a basic CSS from Mike Stenhouse that provides a good basic look and feel that can be easily overridden.

The Spring JS provides a JavaScript syntax to enhance existing page elements with e.g. client-side validation, tool tips or partial page-refreshes. Again, the idea is that even without Javascript, the page is still OK.

SpringOne 2008 - Spring Transaction choices for Performance by Jürgen Höller

Tune with the @Transactional annotation:
  • propagation: "requires", "requires-new" or, the spring-specific, "nested" (=uses save points)
  • isolation level: default: read committed
  • set the readonly flag --> hint for runtime optimization.
Prefer native JDBC transactions over XA transactions:
  • XA is difficult to setup
  • run a transaction coordinator
  • XA JDBC driver
  • XA Message Broker
  • put the XA recovery log to a reliable log storage
  • XA has a significant run time overhead
  • two phase commit
  • state tracking
  • recovery
  • on restart: complete pending commits/rollbacks --> read the "reliable recovery log"
Check if you really need XA! Prefer the use of a native transaction or combine two native transaction, with some small extra safety provisions. E. g. Usually the "exactly once" guarantee of an XA JMS can be relaxed --> use a native JMS transaction and detect duplicate messages. --> much higher throughput.

SpringOne 2008 - Using Spring Security 2 by Mike Wiesner

  • formerly Acegi security -- Acegi is an abbreviation for AbCdEfGhI :-)
  • Authentication: URL (coarsegrained) or method (finegrained) authentication
  • ACL
  • LDAP support
  • SSO
  • pluggable filters (through 1 delegating servletfilter); config in security.xml.
    Eg: LDAP, JAAS, OpenID plugins
  • repository for storing (e.g.) additional user details
    --> implemented in e.g. JDBC or LDAP
    --> combine multiple data sources
  • SecurityInterceptor (AOP) for method-based security
  • @RolesAllowed annotation (JSR-250)
gotcha: The RBAC pattern decouples users from permissions through roles: users >-<roles>-< permissions! Test on permissions and let the repository associate your user with the correct permissions through the assigned roles. Never test on roles in your code.

Spring security also provides a authz-taglib for querying security-permissions while building a web page. This is helpful, but you still have to secure the basic URLs and methods.

SpringOne 2008 - Persistence Tuning for the Spring Environments by Tomas Risberg

a few best practices:
  • get your DBA involved early
  • take time to design your db: tables, indexes, data types, normalize, partition,... all have impact on the performance
  • consider batch vs online. (consider native db-tools for loading)
  • limit the number of rows / columns per table -> normalize
  • avoid nulls in where clause (nulls are not indexed!)
  • avoid starting with a wildcard in "like '%xyz'" tests (not indexed)
  • select the proper transaction manager: JTA and XA is the slowest solution --> prefer plain JMS and native JDBC transactions
  • avoid 'SERIALIZABLE' transaction isolation
  • use the readonly-flag (JDBC) whenever possible.
  • use a proper connection pool: Apache DBCP or Oracle Datasource Connection Pool (never use the 'standard' DriverManagerDatasource!)
  • early test your connections at startup: JDBC 4: isValid() or "select 1 from dual;"
  • use prepared statements --> optimized by db
  • setFetchSize()
  • use a RowMapper of BatchJdbcTemplate
  • caching
  • sql tuning: run EXPLAIN and ANALYZE commands
  • tune Oracle memory: SGA (=global + sessions) and disk (blocks/files); put logs on separate volume

SpringOne 2008 - Spring 2.5 on the way to 3.0 by Jürgen Höller

Part of this talk overlapped with Rod's talk, but Jürgen could go in more detail.

Spring is aligning itself with modern standards / APIs:
  • JDK1.6 support: e.g. JDBC 1.4, with better LOB handling
  • support for JMX and MXBeans
  • AspectJ loadtime-weaving --> avoids proxy pitfalls; support "new" operator
  • JEE5: Servlet API 2.5 & JAX-WS
"Self-describing classes" with annotations, removing config. As a general rule, annotations should be descriptive; even if a compiler ignores them (e.g. in tests), they should add documentation to the class:
  • JSR 250 @PostConstruct & @PreDestroy: quick wins: explicit initializers
  • JSR250 @Resource on steroids: standard is JNDI-only, but spring also resolves spring-bean names.
  • @Autowired (& @Qualifier for more specific rules): elegant way to minimize xml-config, while keeping fine grained control over the DI. It's not an all-or-nothing: mix&match between xml and @autowired makes sense.
  • autodetectable components with: @Component. Without declaring a bean, the component automatically becomes available in the spring context.
  • @Configurable (AspectJ) --> use regular new operator and benefit from Spring config! (load-time weaving)
  • "@MVC": No need to extend a MultiActionController anymore: with @Controller and @RequestMapping, the multi-action controller is now the recommended MVC-way, using simple POJOs. It relies extensively on standard naming of classes and methods to interpret URL paths. But, of course, this can be tweaked to the extreme. Even method-parameter names can be used for auto-passing request params if you built your classes with debug-info enabled. Gr8!
  • decide what you prefer: 'externalized' xml config complemented with annotations or fully annotated components with embedded config. As usual Spring doesn't impose one view. The xml-config can, for example, be interesting for a service layer, while the MVC-layer could prefer the annotations.

Spring 3.0

  • Milestone 1: 8/2008 ???
  • Java5+: generics & varargs;
  • extensive use of Expression Language (cfr WebFlow)
  • remove deprecate stuff like commons attributes
  • WebSpere 6.1
  • Rest support

SpringOne 2008 - Keynote by Rod Johnson

Spring 2.5
  • With the new @autowired annotation (+ @qualifier) , auto wiring is now finally usable in real systems. This can help reducing the configuration-overhead to a minimum while keeping maximal control over your code. Looks really great - if you can use Java 5.
  • JSR-250 support: Rod is less enthusiastic about the @Resource, but the @PostConstruct and @Predestroy annotations are highly recommended --> no need to explicitly set the init-method in your spring configs anymore.
  • favor JUnit 4.4 or TestNG --> simple annotations; no need for the abstract testing hierarchies.

Spring WebMVC & WebFlow

  • less configuration, more sensible defaults.
  • annotations instead of extending MultiActionController --> controllers are less tied to Spring MVC
  • better integration with JSF (Spring Faces)

Ajax support

  • support for 'fragments' in a view state: with Apache Tiles all fragments are rendered as a whole (=classic refresh) or individually, triggered by Ajax events
  • introduction of a new ViewScope in WebFlow: objects in view-scope survive as long as you remain in the same state, surviving multiple Ajax requests.
  • Spring JavaScript is a new project that builds on Dojo to provide Ajax support. The accent is on 'clean degradation', where your webapp is fully functional, even with JavaScript turned off.

SpringSource products

  • the SpringSource platform builds on OSGI to provide a highly modular framework. Very interesting ideas, but maybe a bit too revolutionary?
  • SpringIDE is now bundled in the Spring Tool Suite. This is an Eclipse distribution that comes with all plugins needed for Spring development embedded. One of the plugins is Mylin for 'task-based' development. The idea is to deliver a development environment that just works out of the box.

SpringOne 2008 - Welcome by Stephan Janssen

I attended the SpringOne 2008 conference in Antwerp, Belgium. As a professional Java EE designer and developer, the Spring framework brings a refreshing look to enterprise java development. My interest started with these two, now classical, Rod Johnson books:
In this blog I'll summarize a few highlights of the first day of the conference.

As usual, Stephan Janssen promoted his new Parleys.com, completely written in Flash Air & Flex (GWT and JavaFX versions also exist). Very impressive, especially the tools for creating online web-presentations with synced video, slides an outlines. The business model of parleys will be the 'rent-a-space'-model: any company will be able to buy some 'space' to publish their presentations, benefiting from the extensive and appealing tool set and from using the reliable systems and the huge bandwidth that parleys has. Hopefully, they'll continue to serve the podcast feeds as well.

The JavaPolis conference is now rebranded into Javoxx. This is apparently to avoid trademark issues with Sun... Sad.


UPnP client under Ubuntu: djmount

While there are quite a few UPnP servers for Linux out there (MediaTomb, Rhythmbox Coherence Plugin,...), I couldn't find any serious UPnP client (or UPnP-renderer in UPnP-speak) for Linux. I did find some promising libraries like the C++ Platinum UPnP library (used in XBMC) or the Java UPnpLib., but as far as I know no Linux MediaPlayer (like Rhythmbox or Amarok) uses those. There is also a UPnP 'controller', Cidero written in Java, but it has no playback capabilities. Cidero is very useful for debugging your UPnP setup, however.

The only relevant linux UPnP-client is djmount, also used in GeexBox. It is quite primitive: the UPnP devices are mounted as a filesystem. There are no debian packages available for djmount; you have to build it from the sources. The best copy/paste scenario for installing djmount on ubuntu is http://linuxowns.wordpress.com/2008/06/05/accessing-upnp-server-from-ubuntu/.

Unfortunately the last step '6', ie. autorunning djmount at logon doesn't work -- at least under Ubuntu 8.04. If you have a wlan, djmount fails when no network is up. As a comment by 'anonymous' points out, the Ubuntu NetworkManager fires the /etc/NetworkManager/dispatcher.d/01ifupdown script that runs (with run-parts) all scripts in /etc/network/if-up.d under root.

The following steps do work for autostarting djmount under ubuntu:
cd /etc/network/if-up.d
gksudo gedit ./djmount
contents of script:

# Not for loopback!
[ "$IFACE" != "lo" ] || exit 0

modprobe fuse
fusermount -u /media/upnp
djmount -o allow_other /media/upnp

sudo chmod 755 ./djmount
sudo chown root ./djmount
sudo chgrp root ./djmount
Djmount is now (re)mounted whenever the network is up. As stated previously, djmount is a very rudimentary solution because Rhythmbox for example will parse and analyse all mp3s again. Maybe the linux mediaplayers will integrate some of the existing UPnP Libraries in the future. This would be a welcome addition. I'm still hesitating between using djmount or using regular samba-mounts on my laptop.

update 7/7/2008 : This fixed version runs djmount after the network is connected. No need for setuid or "sleep 30" anymore. (*)

(*) to remove the old version of the scripts this post in its first form suggested, you must:
  • remove the upnp action from the System/Preferences/Sessions
  • sudo rm -f /usr/local/bin/djmount.sh
  • sudo chmod u-s /usr/local/bin/djmount
  • sudo chmod g-s /usr/local/bin/djmount


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.


Sound in Ubuntu

On one of my laptops (Medion MD96290) I noticed that the sound wasn't working any more under Ubuntu 8.04. A while ago, I managed to get sound going in Ubuntu7.10 (http://forum.ubuntu-fr.org/viewtopic.php?pid=1290804)

After some research (http://ubuntuforums.org/archive/index.php/t-765671.html) I added the following line to /etc/modprobe.d/alsa_base:
options snd-hda-intel model=6stack-dig

This didn't help. In the same forum, they suggest to enable surround. In Edit/Preferences you can display the Surround slider.

And the magic happened: the sound workz :-). Setting up sound can be quite complex in Ubuntu...

update 15/11/2008: I had to repeat the same actions after upgrading to Ubuntu 8.10: add line to alsa-base file and enable the surround slider.


Rhythmbox meets MP3 players

As stated in my previous post, FireFly is now serving my personal music collection from the CH3WNAS. This is nice for live streaming songs to Rhythmbox, but I also want to put some mp3s on my mp3 player.

I have 2 USB mass storage mp3 player: the Creative Muvo 100 and the Samsung YP-S5 with Asiatic v1.50 firmware. Rhythmbox has very simple support for those USB devices: simply add a ".is_audio_player" file in the root of the mp3 player (see: http://live.gnome.org/Rhythmbox/FAQ). The mp3 player is now automatically detected by Rhythmbox, and filling the player with songs from the FireFly server is as simple as drag'n'drop. The transfer is terribly slow, but that's probably because I'm connecting through wifi.

For both the Muvo 100 and the YP-S5 I put the following file in the root: .is_audio_player
As the FAQ above mentions, this overrides the HAL. I didn't check (yet) if the default HAL settings are OK for the 2 devices. Anyway, this works fine for me.

Tip: with ctrl+H you can display the hidden files (=files that start with a dot '.') in Nautilus.

CH3WNAS and FireFly

I managed to get FireFly running om my CH3WNAS. It's fairly easy if you're not afraid of the command line :-). I was wrong in my post yesterday: you do NOT need Gentoo in order to run firefly! Gentoo is apparently only needed if you want to build FireFly from the sources.

The info in http://dsmg600.info/howto:firefly contains too much steps for the CH3WNAS.

This is the 'real' way to setup firefly on CH3WNAS:
  • enable telnet in fun_plug: http://www.aroundmyroom.com/2008/01/03/ch3wnas-enabling-telnet/
  • download the latest build of FireFly for the CH3WNAS: http://willie-wortel.nl/ch3wnas/ch3wnas-ff-1696.tgz. Unzip the build onto the NAS. (/mnt/HD_a2)
  • I renamed the main directory from /mnt/HD_a2/firefly-1696 to /mnt/HD_a2/firefly. This is consequent with the config.
  • edit the following line in /mnt/HD_a2/firefly/mtdaapd.conf file (e.g. with ftp):
    mp3_dir = /mnt/HD_a2/media
    --> replace media with the root-directory to your mp3s.
    --> check out the other options like default admin password if you wish.
  • add the following lines to your fun_plug:
    #kill legacy upnp (if you don't use the upnp ;-)
    kill -9 `pidof upnp`

    #start firefly
    rm -f /mnt/HD_a2/firefly/var/cache/mt-daapd/*
    /mnt/HD_a2/firefly/sbin/mt-daapd -c /mnt/HD_a2/firefly/mt-daapd.conf
    As you can see, I completely remove the DB before starting FireFly up. This is because while I was testing, the DB went corrupt after a reboot. The indexing at startup is very fast (4000 mp3s in 64 seconds) so this isn't really a problem, I think. Maybe there are more elegant ways to prevent corruption of the DB?
I tested it with Rhythmbox under Ubuntu 8.04 & it works like a charm :-). Make sure the "Multicast DNS service discovery" service (= mDNS) is running in Ubuntu (System/Administration/services) and that the "daap plugin" is checked in rhythmbox (edit/plugins). I'm seriously considering buying the Roku (Pinnacle) Soundbridge now...

Other tips:
  • check out the FireFly admin pages in your browser: go to port 3689 of your CH3WNAS:
    e.g. user: admin; password: mt-daapd (default)
  • you can follow the logs in /var/log/mt-daapd.log (maybe not the best location :-/):
    tail -f /var/log/mt-daapd.log
thanks to http://forums.fireflymediaserver.org/viewtopic.php?p=20282&sid=5b52a2902da3f5b3462bed5e1bc826fd and http://willie-wortel.nl/ch3wnas/!

(updated: 12/6/2008: corrected willie-wortel links)