Install Dropbox In An Entirely Text-Based Linux Environment

Install Dropbox in an small server (like a netbook or a raspberryPI) can make fast and easy automatic file transfer between your computer and your server.
To do it, follow the instructions in:  http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment

Ubuntu Server Install also contains some notes on getting Dropbox running via the command line.

Prerequisites

  • At least version 2.4 of the C library
  • wget
  • Python 2.x ≥ 2.5 (we do not offer support for Python 3.0)
  • a web browser

Setup process

Short version

  1. Get the latest release tar from the download page:  x86  |  x86_64
  2. Files are extracted to .dropbox-dist
  3. Run dropboxd

Step-by-step version

  1. Log in to your Linux server so you obtain a shell prompt, and change to your home directory.
    cd
  2. Stable 32-bit:
    wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"

    Stable 64-bit:

    wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"
  3. Sanity check to make sure we’re not going to clog our home directory.
    tar -tzf dropbox.tar.gz
  4. Extract
    tar -xvzf dropbox.tar.gz
  5. Make sure the LANG environment variable is set to something other than NULL, e.g. en_US.iso88591. If it is NULL, you’ll get a cryptic error.
  6. Run dropboxd
    ~/.dropbox-dist/dropboxd
  7. You should see output like this:
    This client is not linked to any account... Please visit https://www.dropbox.com/cli_link?host_id=7d44a557aa58f285f2da0x67334d02c1 to link this machine.

dropboxd will create a ~/Dropbox folder and start synchronizing it after this step! Go to the URL given; you should see a success message at the top of your screen.

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).


Post-installation

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 -O ~/bin/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"  
$ chmod 755 ~/bin/dropbox.py  
$ ~/bin/dropbox.py help

In case you get the following error (after trying to run the Dropbox CLI):

$ ~/bin/dropbox.py help  File "/home/username/bin/dropbox.py", line 91  with open(pidfile, "r") as f:  ^ SyntaxError: invalid syntax

update to Python 2.6 and it will go away. Or better try python2.6 rather than your plain command python as you may already have it installed.

NOTE: For CentOS users, use either the EPEL or IUS repo to install the python26.<arch> RPM. The package installs Python 2.6 in parallel to the distribution default version. This way YUM will not be effected by the newer version. Once installed update the hash-bang line to refer to /usr/bin/python26 or /usr/bin/python2.6.

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

(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.)

(The script dropboxdir.py must be located in parent directory to ~/.dropbox-dist/ )

Note that the script above currently only works for Dropbox 0.7.x and not 1.0.x – for Dropbox 1.0 you can use this PHP script or this Python script.

Using symbolic links to move the folder location

$ dropbox stop $ mv ~/Dropbox /target/folder $ ln -s /target/folder/Dropbox ~/ $ dropbox start

Suppress LAN Sync broadcasts

To stop dropbox from sending LAN Sync broadcasts every 30 seconds over port 17500 (http://forums.dropbox.com/topic.php?id=16253) see DisableLanSync

Unlink / Relink Dropbox account

You shouldn’t need to do this, but occasionally it can fix “odd quirks”, so is often recommended as a troubleshooting tip on the forums.

To unlink:

$ dropbox stop $ mv ~/.dropbox ~/.dropbox.old

To relink:

$ dropbox start

Running on system startup

Some *nix boxes will let you use “cron” to ensure that dropbox starts up when the machine boots. I’ve done this by putting

@reboot $HOME/.dropbox-dist/dropboxd

into my crontab. Do “man 5 crontab” in a console window to see if your flavor of cron supports that syntax.

You can also use an init.d or event.d script to automatically run dropboxd. Click below for the correct script for your Linux distribution.

+Gentoo

Check below for further instructions once you have downloaded the init.d script for your platform./etc/init.d/dropbox and service dropbox can be called with start, stop, restart and status.

Debian/Ubuntu

Look above for a sample init.d script for Debian/Ubuntu and the event.d sample.

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

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 
# Without next line DB does not sync non ASCII characters (ubuntu 10.04-x86_64, db 0.7.110) 
export LANG=en_US.UTF-8 cd /home/dropbox exec sudo -H -u dropbox ./.dropbox-dist/dropbox end script

After creating the file, run initctl and you’re set! Alternatively, if only one user of the system is running Dropbox, you can run the script as that user, replacing /home/dropbox with /home/USERNAME and sudo -H -u dropbox with sudo -H -u USERNAME

If gives the error about the job not existing, although this time it says: Unknown job: dropbox

Put the content of the script on: /etc/init/dropbox.conf

(The latter version is for Ubuntu 10.4 and, presumably, later versions.)

Fedora/Redhat

Look above for the Fedora/RedHat init.d script. Save it to /etc/init.d/dropbox.

Add the file /etc/sysconfig/dropbox with one line setting the variable DROPBOX_USERS to include all users that want to run dropboxd in quotes and separated by spaces.

$ cat /etc/sysconfig/dropbox DROPBOX_USERS="user1 user2"

Fix file permissions:

$ /bin/chmod 0755 /etc/init.d/dropbox $ /bin/chmod 0644 /etc/sysconfig/dropbox $ /bin/ls -l /etc/init.d/dropbox /etc/sysconfig/dropbox

Fix SELinux permissions:

$ /usr/bin/chcon -u system_u -t initrc_exec_t /etc/init.d/dropbox
$ /usr/bin/chcon -u system_u -t etc_t /etc/sysconfig/dropbox $ /bin/ls -lZ /etc/init.d/dropbox /etc/sysconfig/dropbox

For Fedora/RedHat run:

$ chkconfig dropbox on

Verify it worked. You should see dropbox in the list.

$ chkconfig --list | egrep '3:on|5:on' | less

In Fedora 15 or other systems using systemd, add the following as the first line in the init.d script:

#!/bin/sh

Gentoo

Look above for the Gentoo init.d scripts.

rc-update add dropbox default

openSuse 11.3

Look above for the openSuse init.d scripts.

Etiquetas: ,

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: