Dropbox

From ArchWiki
Revision as of 22:05, 8 June 2012 by Mloskot (Talk | contribs) (Clarified unencrypted storage wording)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Dropbox is a file sharing system that recently introduced a GNU/Linux client. Use it to transparently sync files across computers and architectures. Simply drop files into your ~/Dropbox folder, and they will automatically sync to your centralized repository.

Installation

dropboxAUR can be installed from the AUR. Alternatively, dropbox-experimentalAUR is also available.

  1. After installing the package, you can start Dropbox from your application menu or run dropboxd from the command-line. The client icon will appear in the system tray.
  2. Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.
  3. After some time you will see a "Welcome to Dropbox" pop-up, which will give you the opportunity to view a short tour of Dropbox.
  4. Press the "Finish and go to My Dropbox".

For KDE users, no further steps are required (it is enough to install the above dropboxAUR package from the AUR), as KDE saves running applications when logging out and restarts them automatically.

Optional packages

  • For a command-line interface, install dropbox-cliAUR from the AUR.
  • For integration with Nautilus, install nautilus-dropboxAUR from the AUR. The Nautilus plugin will start Dropbox automatically.
  • For integration with Thunar, install thunar-dropboxAUR from the AUR.
  • For KDE users, there is a KDE client available: kfileboxAUR from the AUR.

Automatically Starting Dropbox

Dropbox can be automatically started by adding dropboxd to ~/.xinitrc (or autostart.sh, depending on your setup). Alternatively, you can start it as a daemon.

Alternative to install: use the web interface

If all you need is basic access to the files in your Dropbox, you can use the web interface at https://www.dropbox.com/ to upload and download files to your Dropbox. This can be a viable alternative to running a Dropbox daemon and mirroring all the files on your own machine.

Daemon

To run Dropbox as a daemon similarly to sshd or vsftpd, simply do one of the following:

dropbox-daemon Method

Install dropbox-daemonAUR and configure your username in /etc/conf.d/dropboxd.conf

This allows you to start or stop Dropbox just like any other service.

# /etc/rc.d/dropboxd start
# /etc/rc.d/dropboxd stop
# /etc/rc.d/dropboxd restart

Place dropboxd in the DAEMONS array in /etc/rc.conf for it to start at boot.:

DAEMONS=(... @dropboxd ...)

Manual Method

As root, copy this into a file called /etc/rc.d/dropboxd and set USER to your username.

#!/bin/bash

USER=yourusername

. /etc/rc.conf
. /etc/rc.d/functions

PID=`pidof -o %PPID /opt/dropbox/dropbox`

case "$1" in
  start)
    stat_busy "Starting Dropbox Service"
    LANG=$LOCALE
    [ -z "$PID" ] && su -c "/usr/bin/dropboxd &" $USER
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon dropboxd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Dropbox Service"
    [ ! -z "$PID" ] && kill $PID > /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon dropboxd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
    ;;
esac
exit 0

An Organized Way:

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

USER=yourusername
DROPBOXD_PATH='/usr/bin/dropboxd'
DROPBOX_PATH='/opt/dropbox/dropbox'

PID=`pidof -o %PPID $DROPBOX_PATH`

case "$1" in
  start)
    stat_busy "Starting Dropbox Service"
    if [ $USER = 'yourusername' ]; then
        echo "Please edit /etc/rc.d/dropboxd' 'USER' before using this script."
        stat_fail
    else
	LANG=$LOCALE
        [ -z "$PID" ] && su -c "$DROPBOXD_PATH &" $USER
        if [ $? -gt 0 ]; then
          stat_fail
        else
          add_daemon dropboxd
          stat_done
        fi
    fi
    ;;
  stop)
    stat_busy "Stopping Dropbox Service"
    [ ! -z "$PID" ] && kill $PID > /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon dropboxd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 3
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
    ;;
esac
exit 0

Make the file executable with

# chmod +x /etc/rc.d/dropboxd

This allows you to start or stop dropboxd just like any other service. For example:

# /etc/rc.d/dropboxd start
# /etc/rc.d/dropboxd stop
# /etc/rc.d/dropboxd restart

To start it at boot, add it to your DAEMONS array in rc.conf: /etc/rc.conf:

DAEMONS=(... @dropboxd ...)

Without Nautilus (Another Way)

Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:

1. Create a fake Nautilus script that will launch Thunar:

   $ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus

2. Insert this text into the file, then save and exit:

   #!/bin/bash
   exec thunar $2
   exit 0

3. Launch Dropbox

   $ dropboxd

4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.

Note: In this way there is no need to create a Dropbox daemon in /etc/rc.d/ and to start it at boot via /etc/rc.conf or to make it start via your session manager: just leave the "Start Dropbox on system startup" option flagged in the Preferences window.
Note: If you already have Nautilus installed but do not want to use it, neither modify the existing file under /usr/bin, just change the /usr/bin for /opt/dropbox in the step 2 above, like this: $ sudo touch /opt/dropbox/nautilus && sudo chmod +x /opt/dropbox/nautilus && sudo nano /opt/dropbox/nautilus. Dropbox will look in this path first!

Securing Your Dropbox

If you want to store sensitive data in your Dropbox, you should encrypt it before. Syncing to Dropbox is encrypted, but all files are (for the time being) stored on the server unencrypted just as you put them in your Dropbox.

  • Dropbox works with TrueCrypt, and after you initially uploaded the TrueCrypt volume to Dropbox, performance is quite okay, because Dropbox has a working binary diff.
  • Another possibility is to use EncFS, which has the advantage that all files are encrypted separately, i.e. you do not have to determine in advance the size of the content you want to encrypt and your encrypted directory grows and shrinks while you add/delete/modify files in it. You can also mount an encrypted volume at startup using the -S option of encfs to avoid having to input the passphrase, but note that your encrypted files are not secure from someone who has direct access to your computer.

Multiple Dropbox Instances

If you need to separate or distinguish your data, personal and work usage for example, you can subscribe to Dropbox with different email addresses and have multiple directories synced to different instances.

The basic principle and general how-to are described in the Dropbox Wiki.

Note: When dealing with multiple instances you have to select the Dropbox destination folder, which the Dropbox installer asks in the last step; usage examples may be /home/dropbox-personal, /home/dropbox-work, and so on.

For convenience, here is a script that I use to accomplish the task: just add a dir in the "dropboxes" list to have another instance of Dropbox, referring to the dir, loaded at script startup.

#!/bin/bash                                                                                              
                                                                                                         
 #*******************************                                                                        
 # Multiple dropbox instances                                                                            
 #*******************************                                                                        
                                                                                                         
 dropboxes=(.dropbox-personal .dropbox-work)                                                            
                                                                                                         
 for dropbox in ${dropboxes[@]}                                                                          
 do                                                                                                      
     if ! [ -d $HOME/$dropbox ];then                                                                     
         mkdir $HOME/$dropbox                                                                            
     fi                                                                                                  
     HOME=$HOME/$dropbox/ /usr/bin/dropbox start -i                                                      
 done   

Dropbox on Laptops

Dropbox itself is pretty good at dealing with connectivity problems. If you have a laptop and roam between different network environments, Dropbox will have problems reconnecting if you do not restart it. The easiest way to solve this with netcfg is to use POST_UP and PRE_DOWN.

In every network profile you use, add the appropriate commands:

POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"
PRE_DOWN="any other code; killall dropbox"

Obviously, your_user has to be edited and 'any other code;' can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.

If you have connectivity problem with NetworkManager, this thread on forum should be useful.

Known Issues

Connecting...

It may happen that Dropbox cannot connect successfully because it was loaded before an Internet connection was established. To solve the problem the content of the file /opt/dropbox/dropboxd needs to be replaced with the following:

#!/bin/sh

# Copyright 2008 Evenflow, Inc., 2010 Dropbox
#
# Environment script for the dropbox executable.

start_dropbox() {
PAR=$(dirname $(readlink -f $0))
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH 

TMP1=`ps ax|grep dropbox|grep -v grep`
if [ -n "$TMP1" ]; then
  kill -9 $(pidof dropbox) >/dev/null 2>&1
fi
exec $PAR/dropbox $@ &
}

do_dropbox() {
start_dropbox >/dev/null 2>&1
while [ 1 ]; do
  sleep 5
  ERROR="$(net_test)"
  if [ -n "$ERROR" ]; then
    LAST_ERROR=1
  else
    if [ -n "$LAST_ERROR" ]; then
      # Connection seems to be up but last cycle was down
      LAST_ERROR=""
      start_dropbox >/dev/null 2>&1
    fi
  fi
done

}

net_test() {
TMP1="$(ip addr |grep "inet " |grep -v "127.0.0.1")"
[ -z "$TMP1" ] && echo "error"
}

do_dropbox

Following is an alternative script that will check for an actual internet connection, by using curl to check if any entry in a list of hosts and ip addresses is available. If none of the specified hosts are available, the script will wait and try again (albeit not forever). The way the script increments the waiting time is quite messy, but the logic goes like this:

Start with a wait time of 5 seconds.

Multiply by 1.5.

Do this as long as the wait time is less than 1500 seconds (25 minutes), and the check_net() function returns non-zero values (failure).

#!/bin/bash

# Copyright 2008 Evenflow, Inc., 2010 Dropbox
#
# Environment script for the dropbox executable.

WAIT_TIME=5 #initial time to wait between checking the internet connection
#HOSTS="www.google.com www.wikipedia.org 8.8.8.8 208.67.222.222"
HOSTS="www.google.com www.wikipedia.org "

PAR=$(dirname $(readlink -f $0))
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH=$PAR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH

#non-zero exit code iff none of the hosts could be reached
check_net() {
        local ret=1
        for i in $HOSTS; do
                #ping -w2 -c2 $i > /dev/null 2>&1 && ret=0 && break
                curl -o /dev/null $i > /dev/null 2>&1 && ret=0 && break
        done
        echo $ret
}

#if dropbox is running; kill it. Then start dropbox
start_dropbox() {
local tmp=`ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep`
        if [ -n "$tmp" ]; then
                kill -9 $(pidof dropbox) > /dev/null 2>&1
        fi
        exec $PAR/dropbox $@ > /dev/null 2>&1 &
}

#loop over: start dropbox iff check_net returns 0
#loop (and with it, the entire script) terminates when dropbox has been restarted,
#+ or the waiting time has exeeded 1500 seconds (it grows 50% with each iteration of the loop)
attempt_startup() {
        while [ $WAIT_TIME -lt 1500  ] ; do
                if [ $(check_net) -eq 0 ]; then
                        start_dropbox
                        exit
                fi
                sleep $WAIT_TIME
                #WAIT_TIME=$(($WAIT_TIME+$WAIT_TIME/2))
                let "WAIT_TIME += WAIT_TIME/2"
        done
}

start_dropbox
attempt_startup &

Dropbox does not start - "This is usually because of a permission error"

Check permissions

Make sure that you own Dropbox's directories before running the application. This includes

  • ~/.dropbox - Dropbox's configuration directory
  • ~/Dropbox - Dropbox's download directory (default)

You can ensure this by changing their owner with chown -R.

This error could also be caused by /var being full.

Re-linking your account

Dropbox's FAQ suggests that this error may be caused by misconfiguration and is fixed by (re)moving the current configuration folder

# mv ~/.dropbox ~/.dropbox.old

and restarting Dropbox.

Errors caused by running out of space

A common error that might happen is that there is no more available space on your /tmp and /var partitions. If this happens, Dropbox will crash on startup with the following error in its log:

Exception: Not a valid FileCache file

A detailed story of such an occurrence can be found in the forums. Make sure there is enough space available before launching Dropbox.

Locale caused errors

Try starting dropboxd with this code:

LANG=$LOCALE
dropboxd

(You can also use a different value for LANG; it must be in the format "en_US.UTF-8") This helps when running from a Bash script or Bash shell where /etc/rc.d/functions has been loaded

Alternatives