How To Install Dropbox In An Entirely Text Based Linux Environment

Prerequisites

Setup process

1. Log in to your Linux server so you obtain a shell prompt, and change to your home directory.

$ cd

2. Use wget to download the Dropbox Linux client, using either the link to the latest stable version (32-bit or 64-bit), or go to the forums and find a link to the latest forums version.

# this example is the 32-bit build of the client
$ wget -O dropbox.tar.gz http://www.getdropbox.com/download?plat=lnx.x86

3a. Use tar to extract the client. It will be placed in a folder .dropbox-dist/ which may be in the folder ~/ or may be in the folder / (or possibly elsewhere).

$ tar -zxof dropbox.tar.gz

3b. Move the folder and all its contents to .dropbox-dist to ~/.dropbox-dist if neccessary.

$ mv .dropbox-dist ~/.dropbox-dist

4. Use wget to download the Python scripts needed to set this up.

$ wget http://dl.getdropbox.com/u/6995/dbmakefakelib.py
$ wget http://dl.getdropbox.com/u/6995/dbreadconfig.py

5. Run the dbmakefakelib.py script - this creates fake stub copies of the GUI libraries so dropboxd will start.

$ python dbmakefakelib.py
adding library libgtk-x11-2.0.so.0
adding library libgdk-x11-2.0.so.0
adding library libatk-1.0.so.0
adding library libgdk_pixbuf-2.0.so.0
adding library libpango-1.0.so.0
adding library libgobject-2.0.so.0
adding library libgmodule-2.0.so.0
adding library libgthread-2.0.so.0
adding library libglib-2.0.so.0
adding function gtk_tree_view_new
adding function gtk_toolbar_new
adding function g_threads_got_initialized
adding function gtk_grab_remove
adding function gtk_button_new
adding function gtk_frame_new
adding function gtk_major_version
... lots more of this ...
adding function g_static_rw_lock_writer_unlock
adding function g_value_set_boxed_take_ownership
adding function g_boxed_type_register_static
adding function g_datalist_clear
dropboxd ran for 15 seconds without quitting - success?

6. At the end of the last script, dropboxd should have run successfully 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. This can be displayed by running the dbreadconfig.py script.


NOTES BY USERS ON RUNNING SCRIPTS:

dbreadconfig.py fails on my machine (gutsy) when importing ctypes. Try deleting all the code which uses ctypes, since you only need that for Windows anyway.

dbreadconfig.py failed on my Ubuntu 8.04 - I just had to apt-get install gcc and libc6-dev. - Mario

Also, separately, please put each import statement on a different line so that debugging can go much faster, among other reasons (PEP 8). -jperla

I had some trouble with the python scripts, so I modified the scripts. Here are my alternate ones: (Linux only) - dickeytk

If dropboxd just exists without any reason, check that you allow enough size for data seg, stack, virtual memory (ulimit -a). - tomle

I had to modify dbmakefilelib.py and change the reference to "dropboxd" to "dropbox" for it to terminate correctly -frohoff

dbmakefilelib.py did not terminate correctly for me either, I just did ^C to kill it and was able to start dropbox again by running ~/dropbox-dist/.dropboxd and continued with the instructions and everything was fine. - Nick Fitzgerald


$ python dbreadconfig.py
host_id = 739bfe362f3bb3246da99dc8d20dbe2b
last_revision = None
schema_version = 6

If dbreadconfig.py fails for you, you can retrieve the information manually. Install a copy of sqlite from http://www.sqlite.org/download.html and then run the following:

$ cd .~/.dropbox
$ sqlite3 dropbox.db

SQLite version 3.3.6
Enter ".help" for instructions
sqlite> .dump config

Obtain the value for 'host_id' and then decode that value using the base64 decoder of your choice (I used the one at http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/). You want the hex value on the first line, after the 'V', that's the HOSTID.

If you get an error about an unreadable database, make sure you are using sqlite *3*. Also note that you don't need the python-sqlite3 package in Ubuntu - I think it is included in the main release. -Martin

7. Take the URL https://www.dropbox.com/cli_link?host_id=HOSTID and replace HOSTID with the host id from the previous step. Go to this in a web browser on any computer (it doesn't have to be the Linux server) and fill in the details 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).

8. Create a folder ~/Dropbox for the Dropbox files.

$ mkdir ~/Dropbox

9. 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 &

Following on from that, there are a few different options to run the Dropbox client on an ongoing basis. You could put the above line in your server startup scripts, e.g./etc/rc.local, or maybe just a certain user's login scripts.

It is recommended to download the official Dropbox CLI to start the dropbox daemon (as an unprivileged user) and get its status.

$ 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:

$ dropbox stop
$ cp ~/.dropbox/dropbox.db dropbox.db.backup
$ wget http://dl.dropbox.com/u/119154/permalink/dropboxdir.py
$ chmod +x dropboxdir.py
$ mv ~/Dropbox /foo/bar
$ ./dropboxdir --setfolder=/foo/bar
$ dropbox start

Running on system startup

You can also use an init.d or event.d script to automatically run dropboxd. samples are provided for: * Debian/Ubuntu * Fedora/Redhat * Gentoo

I found that installing gparted installed the required gnome libraries to enable the dropbox gui to run under KDE with the icon showing in the tray - Ali L.

Debian/Ubuntu

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

# 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

If you want to use the newer upstart init present on Ubuntu installations and are running dropboxd under a sandbox user (say, dropbox), you can place the following script into /etc/event.d, naming it dropbox

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on shutdown
respawn

script
  cd /home/dropbox
  exec sudo -H -u dropbox ./.dropbox-dist/dropbox
end script

After creating the file, run initctl start dropbox and you're set!

Change DROPBOX_USERS to include all users that want to run dropboxd (separated by spaces), and save the file to /etc/init.d/dropbox.

Then for Ubuntu/Debian run:

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

To start the service, run

$ /etc/init.d/dropbox start

To stop it, run

$ /etc/init.d/dropbox stop

To restart it, run

$ /etc/init.d/dropbox restart

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

$ /etc/init.d/dropbox status

Fedora/Red hat

# 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="user1 user2"

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/dropbox
    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

Change DROPBOX_USERS to include all users that want to run dropboxd (separated by spaces), and save the file to /etc/init.d/dropbox.

For Fedora/RedHat run:

chkconfig --add dropbox

Then run ntsysv. If it worked you should see dropbox in the list.

To start the service, run

$ service dropbox start

To stop it, run

$ service dropbox stop

To restart it, run

$ service dropbox restart

Gentoo

For Gentoo x86/amd64:

# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DROPBOX_USERS="user1 user2"
NICENESS=5

opts="${opts} status"

depend() {
    need net
}

start() {
    ebegin "Starting dropbox..."
    for dbuser in $DROPBOX_USERS; do
        start-stop-daemon -b -o -N $NICENESS -c $dbuser -S -v -e HOME="/home/$dbuser" -x /home/$dbuser/.dropbox-dist/dropboxd
    done
    eend $?
}

stop() {
    ebegin "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
        start-stop-daemon -o -c $dbuser -K -x /home/$dbuser/.dropbox-dist/dropbox
    done
    eend $?
}

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

for Gentoo ~x86/~amd64 using openrc and baselayout-2:

# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/sys-fs/dropbox/files/dropbox.init-1.0,v 1.4 2007/04/04 13:35:25 cardoe Exp $

DROPBOX_USERS="will"
NICENESS=5

depend() {
        need localmount net
        after bootmisc
}

start() {
        ebegin "Starting dropbox..."
        for dbuser in $DROPBOX_USERS; do
          start-stop-daemon -S -b -m --pidfile /var/run/dropbox-$dbuser.pid -o -N $NICENESS -c $dbuser -v -e HOME="/home/$dbuser" -x /home/$dbuser/.dropbox-dist/dropboxd
        done
        eend $?
}

stop() {
        ebegin "Stopping dropbox..."
        for dbuser in $DROPBOX_USERS; do
        start-stop-daemon --stop --pidfile /var/run/dropbox-$dbuser.pid
        done
        eend $?
}

status() {
    for dbuser in $DROPBOX_USERS; do
        if [ -e /var/run/dropbox-$dbuser.pid ] ; then
            echo "dropboxd for USER $dbuser: running."
        else
            echo "dropboxd for USER $dbuser: not running."
        fi
    done
    eend $?
}

Change DROPBOX_USERS to include all users that want to run dropboxd (separated by spaces), and save the file to /etc/init.d/dropbox.

For Gentoo run:

rc-update add dropbox default

To start the service, run

$ /etc/init.d/dropbox start

To stop it, run

$ /etc/init.d/dropbox stop

To restart it, run

$ /etc/init.d/dropbox restart

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

$ /etc/init.d/dropbox status

daemontools

You can also use the excellent daemontools package by Dan J. Bernstein (author of qmail) to keep Dropbox running at all times.

Install daemontools - click here for instructions. If you are installing on Linux, you will need the errno patch.

Now, you will need to decide where to store your Dropbox. We will refer to this as $DBOXHOME. I picked a folder inside my Samba server's public directory, but this decision will depend on your intended usage.

Now:

1. Become root

$ su

2. Create the sandbox user, dropbox.

# useradd -d $DBOXHOME -g daemon -m -p none -s /bin/false dropbox

3. Change directories to the new user's home

# cd ~dropbox

4. Download the Dropbox daemon and extract it

# wget -O - http://www.getdropbox.com/download?plat=lnx.x86 | tar xzf -

5. Move the Dropbox files to a better location for a proper system-wide app (but keep it symlinked for compatibility)

# mv .dropbox-dist /opt/dropbox
# ln -s /opt/dropbox .dropbox-dist

6. Create a daemontools service directory

# mkdir -p svc/log
# cd svc

6. Create run scripts for dropboxd and the logger, multilog

# cat > run << EOF
#!/bin/sh
HOME=~dropbox exec setuidgid dropbox /opt/dropbox/dropboxd
EOF

# cat > log/run << EOF
#!/bin/sh
exec multilog t ./main
EOF

# chmod +x {,log/}run

7. Download dbmakefakelib.py and run it.

# wget http://dl.getdropbox.com/u/6995/dbmakefakelib.py
# HOME=~dropbox setuidgid dropbox python dbmakefakelib.py
dropboxd ran for 15 seconds without quitting - success?

8. Fix ownership

chown -R dropbox:daemon .

9. Get your activation URL. You will need to visit this from any browser to link your Dropbox to this host. Log in, and the rest will take care of itself.

# HOST_ID=`echo '.dump config' | sqlite3 .dropbox/dropbox.db | grep host_id | cut -d \' -f 4 | python -c 'print raw_input().decode("base64")' | grep '^V' | cut -b 2-`

# echo https://www.getdropbox.com/cli_link?host_id=$HOST_ID
https://www.getdropbox.com/cli_link?host_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

10. Make sure there's only one copy of dropboxd running and it's being supervised by daemontools/svscan.

# killall dropbox dropboxd
# cd /service
# ln -s ~dropbox/svc dropbox
# svstat /service/dropbox/
/service/dropbox/: up (pid 19378) 56 seconds

That's all...

TipsAndTricks/TextBasedLinuxInstall (last edited 2010-01-31 01:42:43 by WimC)