Wednesday, June 10, 2009

Autostart JungleDisk in Ubuntu

JungleDisk (http://www.jungledisk.com) is a great data backup tool. It has Windows and Linux versions. The Windows version starts up on its own when Windows start, Here is the tutorial to auto start it in Ubuntu (kinda of):

Say after you download the src pkg from Jungledisk and unzip it to /path/to/jungledisk/.

Step one:
In /path/tojungledisk, write a wraper shell script, called junglediskstart

#!/bin/bash
ps aux | grep junglediskmonitor | grep -v grep
RET=$?
echo $RET
if [ $RET -ne 0 ]; then
export DISPLAY=:0.0
/path/to/jungledisk/junglediskmonitor &
fi

This wrapper script starts junglediskmonitor if junglediskmonitor is not running.

Step Two:
crontab -e
enter this line:
1 * * * * /path/to/jungledisk/junglediskstart

This crontab will call the wrapper script above every hour, attempting to start jungledisk.


NOTE: export DISPLAY=:0.0 in the wrapper script is super important. Junglediskmonitor needs $DISPLAY info, but crontab loses that. Without it, you wrapper will complain about "unable to initialize gtk".

I call it a "kinda of" autostart solution, because jungledisk does not start when Ubuntu boots up. It is a hack-ish solution.

But I do think you can make it real autostart by following the same idea, with a few tweaks in the junglediskstart script.