Dropbox FUSION Icon By Parthiban Mohanraj
This post will help you install the Linux Dropbox client on your headless Ubuntu Server and link it up to your Dropbox account. Unlike the process of mounting an S3 bucket we looked at before the Dropbox approach is a much better solution for sharing files. If you’re a daily Dropbox user you’ll quickly get hooked on the convenience of having your servers in the same file sharing loop as all your other Dropbox connected devices!

Dropbox FUSION Icon By Parthiban Mohanraj

Dropbox FUSION Icon By Parthiban Mohanraj

This post will help you install the Linux Dropbox client on your headless Ubuntu Server and link it up to your Dropbox account. Unlike the process of mounting an S3 bucket we looked at before the Dropbox approach is a much better solution for sharing files. If you’re a daily Dropbox user you’ll quickly get hooked on the convenience of having your servers in the same file sharing loop as all your other Dropbox connected devices!

Installing Dropbox

Start off by downloading the Linux version of Dropbox onto your server. These steps have been tested on Ubuntu Server 10.10 and 11.04.

Download the 32Bit Version

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

Download the 64Bit Version

 wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"

If you unsure which version you need you can quickly check by running uname -a.

 sudo uname -a

If the uname output has an i686 at the end you need the 32Bit version and if it has x86_64 you want the 64Bit version.

When you extract the Dropbox archive it will automatically place its files in the home directory of the the user you’re logged in as under: ~/.dropbox. You can always move these files later but its something to keep in mind.

Extract the Dropbox archive

 tar -xzvf dropbox.tar.gz

Linking Your Server to Your Dropbox Account

Before you take the next step you’ll want to make sure your LANG environment variable is set to a value other than NULL.

Check the value of your LANG environment variable

 printenv LANG     // outputs en_US.UTF-8 on my machine

To connect the Dropbox client on your server to your Dropbox account you’ll need to copy the link it outputs into a browser window and then login to your Dropbox account.

Run dropboxd on your server

 ~/.dropbox-dist/dropboxd

It will start outputting a link similar to this one every few seconds

 This client is not linked to any account... Please visit https://www.dropbox.com/cli_link?host_id=1c1497d78b543178b9349a7c1a8b087a&cl=en_US to link this machine.

The trick to a smooth link is to make sure you leave dropboxd running while you follow the link. You don’t need to access the link from the server you’re trying to install Dropbox on. You can copy and paste that link into a browser running on a separate machine and Dropbox will authorize the client running on your server.

Once it succeeds you’ll see the message Client successfully linked, Welcome! on your server and it will stop printing the authorization link.

Hit ctrl c to terminate the process

 Client successfully linked, Welcome!

Once the Dropbox client on your server is successfully linked it will automatically create a Dropbox folder under ~/Dropbox for the user you’re logged in as. All your folders will be visible under the Dropbox folder but since the Dropbox service isn’t actually running on your server yet you you won’t be able to see the files inside these folders until the client is running and has a check to synchronize.

You can manually start the service by running

 ~/.dropbox-dist/dropbox

However, a better option for controlling the Dropbox client is to setup an Ubuntu service management script for it.

Start Dropbox Automatically On Boot

Dropbox provides a handy little service management script that makes it easy to start, stop and check the status of the Dropbox client.

Create a new file for the service management script

 sudo vi /etc/init.d/dropbox

Paste the following script into the new file

 #!/bin/sh # dropbox service # Replace with linux users you want to run Dropbox clients for 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

Make sure you replace the value of DROPBOX_USERS with a comma separated list of the linux users on your machine you want to run the Dropbox client to run for. Each user in the list should have a copy of the Dropbox files and folders that you extracted from the archive, available under their home directory.

Make sure the script is executable and add it to default system startup run levels

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

Control the Dropbox client like any other Ubuntu service

 sudo service dropbox start|stop|reload|force-reload|restart|status

Dropbox Delorean By Dropbox Artwork Team

Dropbox Delorean By Dropbox Artwork Team

Depending upon the number of files you have on Dropbox and the speed of your internet connection it may take some time for the Dropbox client to synchronize everything.

Check Status with Dropbox CLI

Dropbox has a command line python script available separately to provide more functionality and details on the status of the Dropbox client.

Download the dropbox.py script and adjust the file permissions

 wget -O ~/.dropbox/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py" chmod 755 ~/.dropbox/dropbox.py

You can download the script anywhere you like, I’ve included it along with the rest of the Dropbox files.

Now you can easily check the status of the Dropbox client

 ~/.dropbox/dropbox.py status Downloading 125 files (303.9 KB/sec, 1 hr left)

Get a full list of CLI commands

 ~/.dropbox/dropbox.py help   Note: use dropbox help <command> to view usage for a specific command.    status       get current status of the dropboxd  help         provide help  puburl       get public url of a file in your dropbox  stop         stop dropboxd  running      return whether dropbox is running  start        start dropboxd  filestatus   get current sync status of one or more files  ls           list directory contents with current sync status  autostart    automatically start dropbox at login  exclude      ignores/excludes a directory from syncing

Use the exclude command to keep specific files or folders from syncing to your server

 ~/.dropbox/dropbox.py help exclude   dropbox exclude [list] dropbox exclude add [DIRECTORY] [DIRECTORY] ... dropbox exclude remove [DIRECTORY] [DIRECTORY] ...   "list" prints a list of directories currently excluded from syncing.   "add" adds one or more directories to the exclusion list, then resynchronizes Dropbox.  "remove" removes one or more directories from the exclusion list, then resynchronizes Dropbox. With no arguments, executes "list".  Any specified path must be within Dropbox.

Once the Dropbox service is running and fully syncrhonized you can access all your Dropbox files and easily share files on your server with all your other Dropbox connected gadgets!

For more resources and troubleshooting tips visit the Text Based Linux Install page on the Dropbox wiki and the Dropbox forums. Happy syncing!

  • Prashant Raju

    Great post! Finally a guide that just works!

    Keep up the good work.

  • http://rawberg.com/blog David Feinberg

    Thanks for the kind words Prashant, glad to hear you got everything working!

  • http://putokaz.wordpress.com/2011/06/05/installing-dropbox-on-ubuntu-server/ Installing dropbox on Ubuntu server « Putokaz
  • Anonymous

    What a great guide — very clear and, as Prashant said, it just works! Thanks and I look forward to your service launching.

  • http://rawberg.com/blog David Feinberg

    thanks for the positive feedback djmccormick!

  • Jonas Nyström

    Great! Thanks! Using the Dropbox GUI, it’s possible to controll specifically what folders to be synced. Can this somehow be done from the command-line too?

  • http://rawberg.com/blog David Feinberg

    You got it, you just have to use the exclude command.
    http://wiki.dropbox.com/TipsAndTricks/UsingDropboxCLI#EXCLUDE

  • Kyle

    For some reason, the nice format of this guide makes this look much friendlier. lol!

  • Darksteel Shaman

    Incredible guide! Got dropbox up and running in no time! Thanks a bunch :)

  • http://rawberg.com/blog David Feinberg

    Glad to hear it worked out for you Darksteel and thanks for the positive feedback!

  • http://adminsgoodies.com/dropbox-on-linux-server-how-to-includeexclude-folders/ Dropbox on linux server – how to include/exclude folders? – Admins Goodies

    […] Background: I’m trying out the solutions for installing Dropbox on a linux server given here, and it seems to work fine: http://ubuntuservergui.com/ubuntu-server-guide/install-dropbox-ubuntu-server […]

  • Daniel

    Thank you for this post, very helpful :)

  • Adamjseed

    David, Great tutorial.

    Do you know how to move the drobox folder to a different location on a headless install?

    Im thinking that I may need to install the full client and forward the x11 to move it.

  • http://rawberg.com/blog David Feinberg

    Have you tried manually changing the PARENT_DIR setting in the dropbox.py file?

  • http://rawberg.com/blog David Feinberg

    Glad to hear it helped you out!

  • Sebastian Sawicki

    Haven’t you hear about upstart? Using /etc/init.d is deprecated ;]
    What’s more if you have root access it would be nice to place dropbox-dist files (which are mainly binaries and some libs) in some system folder. I’ve putted it in /opt/dropbox-dist :
    # sudo mv ~/.dropbox-dist /opt/dropbox-dist
    # sudo chown -R root:root /opt/dropbox-dist
    # sudo chmod -R go-w /opt/dropbox-dist

    …there is no need in having same binaries for each user.

  • http://rawberg.com/blog David Feinberg

    Good tips Sebastian, thanks for sharing!


Articolul original: aici


 

Tags: