*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1]
Print
Author Topic: Dropbox working with the Journal  (Read 2944 times)

Dropbox working with the Journal

anna
Master Contributor
***
Posts: 326


September 17, 2010, 08:17:49 PM

Tested and working on os852

If you've never heard of Dropbox, it's a crossplatform "cloud" storage service with 2 GB of free space.  It's an easy way to sync and share files across different computers.  You can also use the web interface to log in from any computer and download and upload files.

If you don't have a Dropbox account, go to http://www.dropbox.com and sign up.  If you're a heavy Dropbox user, I highly suggest creating another account just for the XO.

As with all things Linux, there are a few scenarios and use cases to consider.  Here's a distillation, from the easiest installation and on.

1.  Gnome Desktop only, keeping Dropbox on the nand.  No USB drive required.

You're looking for an easy way to transfer notes, small files, etc. between the XO and your "regular" computers without having to constantly mess with USB drives.

2.  Gnome Desktop and usage under Sugar in the Terminal.  No USB drive.

The above scenario applies to you, but you'd also like to be able to access /home/olpc/Dropbox under Sugar in the Terminal.

3.  Up to 2 GB of storage as well as Sugar Journal integration.  USB drive required.

You have an available 2 GB USB drive or SD card to dedicate to the XO.  Perhaps a small child uses the XO and wants to "email" pictures and documents back and forth.  If the child can drop stuff onto a drive from the Journal, then anyone with access to that Dropbox account can see it.  You can even send the child "emails" via the shared Dropbox account.  Simply create a text file, save it as Birthday_Wishes_From_Auntie.txt for example, and save it to the shared Dropbox.  It will "magically" show up in the child's Journal and he/she can open it in Write.


1.  Basic Installation for use only under Gnome - no USB drive required


Keep in mind the XO's space is very limited, so make sure not to put a lot of stuff into the Dropbox account.

Get into your Gnome desktop on the XO.  From the Dropbox homepage, click on the big "Download Dropbox" button at the bottom of the page, download the Fedora x86 rpm, and save the file.  The default save location is /home/olpc/Download

Installation is relatively simple.  In a terminal:

Code:
cd /home/olpc/Download
sudo rpm -ivh nautilus-dropbox-<version>.fedora.i386.rpm

Where <version> is the version you downloaded.

If it seems to hang during the install process, check the the taskbar to see if there's a tab called "Dropbox" or "Information," click that tab, then click OK.

Go to Applications -> Internet -> Dropbox

Click OK to finish the installation.  This will take a minute.  When it's done, a window will pop up so you can log in and set stuff up.

Since you've already set up a dropbox account, click the tickbox next to "I already have a Dropbox Account" and then the Forward button.  In the next window, enter your login credentials.  Then just keep clicking Forward and take the defaults.

After it finishes up, it'll be a minute or so while everything syncs.  The /home/olpc/Dropbox folder should open automatically.  If you're OK with using it like this, you can stop here.  Just remember the XO doesn't have much space.

From here, you can skip to step 3 if you want to use Dropbox on a USB drive.  Otherwise, proceed to the next step if you just want to use Dropbox in the Terminal in Sugar.

2.  Making Dropbox available under Terminal under Sugar

If you want to have your /home/olpc/Dropbox folder available under Sugar, run the Dropbox service as a daemon.  This is easier than it sounds.

Right click on the Dropbox icon on the system tray and go to Preferences.  Uncheck "Start Dropbox on System Startup."  Click close.  Right click on the Dropbox icon and "Stop Dropbox."  

Create /etc/init.d/dropbox

Code:
# chkconfig: 345 85 15
# description: Startup script for dropbox daemon
#
# processname: dropboxd
# pidfile: /var/run/dropbox.pid
#
# Source function library.
. /etc/rc.d/init.d/functions

DROPBOX_USERS="olpc"

prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/dropbox}
RETVAL=0

start() {
        echo -n $"Starting $prog"
        for dbuser in $DROPBOX_USERS; do
            daemon --user $dbuser /bin/sh -c "/home/$dbuser/.dropbox-dist/dropboxd&"
        done

        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog"
    for dbuser in $DROPBOX_USERS; do
        killproc /home/$dbuser/.dropbox-dist/dropboxd
    done
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart}"
        RETVAL=3
esac

exit $RETVAL

Make it executable

Code:
chmod +x /etc/init.d/dropbox

You can manage the Dropbox daemon from the terminal in any window manager, the console, or even remotely over ssh.

To simply start Dropbox:

Code:
sudo service dropbox start

Start Dropbox on boot:

Code:
sudo chkconfig dropbox on

Stop Dropbox from starting on boot:

Code:
sudo chkconfig dropbox off


3.  Moving your Dropbox folder to a USB drive for more storage and Sugar Journal integration

Follow the instructions in step 1, but do not use the dropbox daemon as detailed in step 2.  We're going to use a udev rule to start the service.

Using a dedicated USB drive lets you take full advantage of the 2 GB of space with a free Dropbox account.  You can also copy stuff onto the USB drive from the Journal and have it sync up with your account.  What's nice about using a udev rule is that the Dropbox service doesn't start until you insert the dedicated USB drive.

BEFORE YOU SET THIS UP, BACK UP YOUR DROPBOX FILES AS THEY WILL BE DELETED

First, get the dependency for the pyDropboxPath.py script.  If your yum install hangs, try the install under single user mode (Option 1 in this post:  http://www.olpcnews.com/forum/index.php?topic=4891.msg32524)

Code:
sudo yum -y install wxPython

Plug in the USB drive you want to use.  Anything larger than 2 GB is kinda pointless.  This command formats it as FAT32 and applies the drive label of "Dropbox" so you don't mix it up with anything else.  You can use it on other machines, but keep in mind that anything you put on it will be synced to Dropbox the next time you plug it into the XO.

Code:
sudo umount /dev/sda1
sudo mkfs.vfat -F 32 -n Dropbox /dev/sda1

Unplug it, then plug it back in.  It should automatically show up under /media/Dropbox.

Note the Serial Number this returns:

Code:
cat /proc/scsi/usb-storage/*

My drive serial number is 5B811F000149 and I'll use that in the following example.

As root, create /etc/udev/rules.d/95-dropbox-usb.rules

Code:
SUBSYSTEMS="usb", ATTRS{serial}=="5B811F000149", SYMLINK+="Dropbox", RUN+="/bin/sh /home/olpc/.dropbox-dist/start-dropbox.sh"

Create /home/olpc/.dropbox-dist/start-dropbox.sh

Code:
#!/bin/sh
killall dropbox
su - olpc -c '/home/olpc/.dropbox-dist/dropboxd&'
exit

Make it executable

Code:
chmod +x /home/olpc/.dropbox-dist/start-dropbox.sh

Get the Python script to change your Dropbox path to your USB drive from here:

http://dl.dropbox.com/u/552/pyDropboxPath/index.html

Navigate to the folder with the latest version, then download pyDropboxPath.py.  Make it executable, then run it.

Code:
chmod +x pyDropboxPath.py
./pyDropboxPath.py

Click Browse, then select your USB drive, which should be listed in the left hand pane as Dropbox.  Click Open.  Click "Save new dropbox folder location."  Close the DropboxPath window.  

***********************************************************************************
Make sure Dropbox won't start unless the USB drive is plugged in:

If you were using the Dropbox daemon, make sure it's not set to run at boot.

Code:
sudo chkconfig dropbox off

Also, if you haven't already, disable Dropbox in the system tray.  Right click on the Dropbox icon on the system tray and go to Preferences.  Uncheck "Start Dropbox on System Startup."  Click close.
***********************************************************************************

Power off the XO and remove the USB drive.  Power back on and let the desktop load.  Insert the USB drive and cross your fingers.  When the drive mounts, give it a few seconds and it should start syncing.

When you switch to Sugar, your Dropbox USB drive will appear in the Journal and anything you put on it will be synced.

Sometimes there's an issue with the XO not syncing Dropbox when you boot with the USB drive in.  If that happens, shut down, take out the drive, boot up into Gnome or Sugar, then insert the drive.  You should get syncing goodness after that.


Warning for mixing up steps 2 and 3:


If you do not use the udev rule while using a USB drive for your Dropbox but you've got the Dropbox daemon running:

Running the XO without the Dropbox USB drive inserted, either booting without it or umounting at some point, doesn't hurt anything.  Your files won't be deleted.  ***HOWEVER***  After running the XO with the Dropbox service running but without the Dropbox USB drive plugged in, the next time you want to use it, you have to do this to get it to sync:

Code:
killall dropbox
sudo service dropbox start

It should go without saying in all cases, you should always properly umount your external media and not just yank it out.  Though I did test improperly yanking out my Dropbox USB drive from the XO and my Dropbox stuff stayed intact.
« Last Edit: September 18, 2010, 10:10:02 AM by anna » Logged
Pages: [1]
Print
Jump to:  

Members
Total Members: 2406
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 33
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 15
Total: 15