Install Dropbox headless on a Linux server

Selection_237

Dropbox est un service de stockage et de partage de copies de fichiers locaux en ligne proposé par Dropbox Inc.
Via un agent installé sur votre ordinateur ou mobile, il est capable de synchroniser une arborescence sur le cloud et permet ainsi une sauvegarde et un versionning de celui-ci.
L’usage classique de Dropbox est d’utiliser un outil sur votre Desktop. Un usage moins évident est de l’utiliser sans le programme Desktop Windows sur un serveur LINUX.
Nous allons voir comment l’installer et le configurer sur un serveur LINUX DEBIAN.

La première étape consiste à mettre à jour le système.

apt-get update
apt-get upgrade

Ensuite on télécharge Dropbox depuis le serveur officiel.
Pour un système 32bit :

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

Pour un système 64bit :

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
Selection_234

The archive's decompression is done in the .dropbox-dist directory
Execute the following command to run the program:

~/.dropbox-dist/dropboxd

The program will then detect that the computer is not linked to any account and will ask you to authenticate. To link the server the program provides you with a URL to open in your browser.
As long as this step has not been completed, the program will continue to prompt you for this action.

Selection_236

On the Dropbox browser, we are asked to confirm this linking:

Selection_237-1

Once accepted, the linking is immediately taken into account.

Selection_238-1
Selection_239


It is now necessary to create the Dropbox service, and for this, a file is available here: https://github.com/joeroback/dropbox

And if the file disappears one day you can download it here:

You install it like this:

wget -O /etc/systemd/system/dropbox@.service https://raw.githubusercontent.com/joeroback/dropbox/master/dropbox%40.service

Enable the start at boot of the machine:

systemctl enable dropbox@root

Validate the installation by restarting the systemctl daemon

systemctl daemon-reload

And then start the service:

systemctl start dropbox@root

Next, check the status:

systemctl status dropbox@root
Selection_240

Apparently, there is a problem. We see that the service is looking for the file in /home/root/.dropbox-dist/dropboxd
In our case, the file is in /root/.dropbox-dist/dropboxd
We need to modify the service script: /etc/systemd/system/dropbox@.service

Selection_241

We reload and restart the service:

systemctl daemon-reload
systemctl start dropbox@root

The indicator is green, we're good to go.

Selection_242

All our files are well synchronized.

If Dropbox is now functional on your server, it still remains tedious to use on the command line. To make our lives easier, the editor provides a Python script to use in CLI to communicate with the program.

cd /usr/bin && curl -LO https://www.dropbox.com/download?dl=packages/dropbox.py && chmod +x dropbox.py

In case you need it, you can download it here:

By placing it in /usr/bin, you allow the system to provide you with access regardless of where you are.

Selection_245

One of the most useful commands is to verify the status of a file. Dropbox will be able to provide its status via a color code upon executing ls.

Selection_246


When reading the source of the utility, you can see the following statuses with the corresponding color code:
up to date : 32
syncing : 36
unsyncable: 41
selsync : 37