I recently wanted to install Wuala on my brand new media center PC running Ubuntu on it. It was not that hard because there is an excellent tutorial on how to setup wuala on a headless machine.

Unfortunately there was no script to start and stop Wuala on system start-up and shutdown. So I decided to create one.

/etc/init.d/wuala (download)

#!/bin/bash
#!/bin/bash

### BEGIN INIT INFO
# Provides:          wuala
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start Wuala headless (wuala)
### END INIT INFO

WUALADIR=/home/wuala
WUALAUSR=wuala

WUALALOG=$WUALADIR/out.log
WUALAERR=$WUALADIR/error.log

uptest(){
if ps -u $WUALAUSR u|grep -v grep|grep loader3.jar >/dev/null;then
echo "Wuala is running"
return 0
else
echo "Wuala is not running"
return 1
fi
}

case "${1:-''}" in
  'start')
        # start commands here
        echo "Starting Wuala..."
        uptest || su $WUALAUSR -c "wualacmd > $WUALALOG 2> $WUALAERR &"
    ;;

  'stop')
        # stop commands here
        echo "Stopping Wuala..."
        uptest && su $WUALAUSR -c "wualacmd exit > $WUALALOG 2> $WUALAERR"
    ;;

  'restart')
        # restart commands here
        $0 stop
        sleep 1
        $0 start
    ;;

  'status')
        # status commands here
        uptest && su $WUALAUSR -c "wualacmd showStatus"
        uptest && su $WUALAUSR -c "wualacmd connectionInfo"
        uptest && su $WUALAUSR -c "wualacmd showSettings"
    ;;

  *)
        # no parameter specified
        echo "Usage: $SELF start|stop|restart|status"
        exit 1
    ;;
esac

It is a very early version with not much error checking, so use it at your own risk. I just posted it in case somebody might find it useful.

To use it just save the content to /etc/init.d/wuala and run

$ sudo update-rc.d wuala defaults

Update: Added the necessary LSB informations

Update 2: The file can now be downloaded: /etc/init.d/wuala.

Upadte 3: Use wualacmd instead of wuala. (Thanks to http://www.synergeek.fr/2010/06/wuala-sous-linux/ for the hint)

Upadte 4: The new version checks if wuala is already running for the given user.