Dropbox

Pre-Requisites

  • wget must be installed in order to download the Dropbox software

Installation

The URLs to the latest stable 32-bit and 64-bit releases are as follows:

32 bit - http://www.dropbox.com/download?plat=lnx.x86
64 bit - http://www.dropbox.com/download?plat=lnx.x86_64

At the time of writing the latest stable release is : 0.97.110

The following example will install the 32-bit version:

cd ~
wget -O wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86

Extract the archive:

tar zxof dropbox.tar.gz

Run dropboxd as a background process, using the following command:

~/.dropbox-dist/dropboxd &

dropboxd should be running for a few seconds - long enough to contact the Dropbox servers and construct the initial pieces of data required for the client to run. The most important of these for identification of the client is the host id, a 128-bit number uniquely assigned to every instance of the client. When the URL containing this host ID is displayed in the screen, stop dropboxd with the following command:

killall dropbox

Copy the URL from the previous step. Go to this in a web browser on any computer (it doesn't have to be the Linux server), and go to the URL to register or link to an existing account.

NOTE: If you want to change the account it is linked to, unlink it from the first account, then kill the running dropbox process, start it up again (with "~/.dropbox-dist/dropboxd &") and obtain the new host_id with dbreadconfig.py . If you don't restart the dropbox client, it will give the same host_id (which for some reason cause me to be unable to change the account it is linked to).

Run dropboxd as a background process; it should pick up the details you entered on the web page and set itself up completely.

~/.dropbox-dist/dropboxd &

Official Dropbox CLI

This is a tool that can be used to start/stop the dropbox daemon and get status details about the connection. I've installed it but use the init.d approach below to control the daemon.

mkdir -p ~/bin
wget -P ~/bin http://www.dropbox.com/download?dl=packages/dropbox.py
chmod 755 ~/bin/dropbox.py

~/bin/dropbox.py help

Changing the dropbox folder location

To move an existing dropbox folder to /foo/bar:

cp ~/.dropbox/dropbox.db dropbox.db.backup
mkdir -P ~/bin
wget -P ~/bin http://dl.dropbox.com/u/119154/permalink/dropboxdir.py
chmod 755 ~/bin/dropboxdir.py
mv ~/Dropbox /foo/bar
~/bin/dropboxdir --setfolder=/foo/bar

(Do not just create a new empty directory and setfolder to it - when you restart dropbox, it will think you've deleted all your files, and delete them from everywhere else too.)

Suppress broadcasts

Use this to stop dropbox from sending broadcasts every 30 seconds over port 17500. You can view and copy the dropboxp2p.py script here.

Note: I had to change the path to the Python interpreter on the first line of the script. It should be [[code]]#!/usr/bin/python[[/code]].

First stop dropbox if it is running.

mkdir -p ~/bin
nano ~/bin/dropboxp2p.py

Paste in the Python script from the above link, save the file and make it executable:

chmod 755 ~/bin/dropboxp2p.py

~/bin/dropboxp2p.py -d

Restart dropbox

To enable broadcasts again call dropboxp2p with -e instead of -d.

Running on system startup

Here's a sample init.d script for Debian/Ubuntu and the event.d sample.

sudo nano /etc/init.d/dropbox

Paste the following code into the editor (inserting a list of users that have dropbox installed):

# dropbox service
DROPBOX_USERS="user1 user2"

DAEMON=.dropbox-dist/dropbox

start() {
    echo "Starting dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

stop() {
    echo "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

status() {
    for dbuser in $DROPBOX_USERS; do
        dbpid=`pgrep -u $dbuser dropbox`
        if [ -z $dbpid ] ; then
            echo "dropboxd for USER $dbuser: not running."
        else
            echo "dropboxd for USER $dbuser: running (pid $dbpid)"
        fi
    done
}

case "$1" in
  start)
    start
    ;;

  stop)
    stop
    ;;

  restart|reload|force-reload)
    stop
    start
    ;;

  status)
    status
    ;;

  *)
    echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
    exit 1

esac

exit 0

Set it to start automatically on system boot:

sudo chmod +x /etc/init.d/dropbox
sudo update-rc.d dropbox defaults

Service Commands

To start the service, run

sudo /etc/init.d/dropbox start

To stop it, run

sudo /etc/init.d/dropbox stop

To restart it, run

sudo /etc/init.d/dropbox restart

You can also check running status in the Ubuntu/Debian and Gentoo versions with:

sudo /etc/init.d/dropbox status

References

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License