Tutorial

How To Install Dropbox Client as a Service on CentOS 7

Published on February 25, 2016
How To Install Dropbox Client as a Service on CentOS 7

Introduction

In this tutorial, we’ll show you how to install the Dropbox client, and configure it to run as a headless service, on a CentOS 7 server. This will allow your server to connect to Dropbox so that you can keep a copy of your Dropbox files synchronized on your server.

Prerequisites

You must have a non-root user with superuser privileges (sudo). To set that up, follow at least steps 1 through 3 in the Initial Server Setup with CentOS 7 tutorial. All of the commands in this tutorial will be executed as this non-root user.

Once you’re ready, we’ll install the Dropbox client.

Install Dropbox Client

The latest version of the Linux Dropbox client can be downloaded to your home directory with these commands:

  1. cd ~
  2. curl -Lo dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64

Now you will have a file called dropbox-linux-x86_64.tar.gz in your home directory.

Note: If you’re running a 32-bit distribution, use this command to download the 32-bit Linux client instead:

cd ~
curl -Lo dropbox-linux-x86.tar.gz https://www.dropbox.com/download?plat=lnx.x86

Next, extract the contents of the Dropbox archive to /opt/dropbox with these commands:

sudo mkdir -p /opt/dropbox
sudo tar xzfv dropbox-linux-x86_64.tar.gz --strip 1 -C /opt/dropbox

The Dropbox client is now on your server, but you need to link it with your Dropbox account.

To link your Dropbox client with your Dropbox account, run this command (as the user whose home directory you want to store the Dropbox files in):

  1. /opt/dropbox/dropboxd

This starts the Dropbox client in the foreground, so you won’t be able to enter any other commands at the moment. The first time you run the client, you should see output that looks like this:

Host ID Link:
This computer isn't linked to any Dropbox account... Please visit https://www.dropbox.com/cli_link_nonce?nonce=ac8d12e1f599137703d88f2949c265eb to link this device.

Visit the URL in the output (highlighted in the above example) in a web browser on your local computer.

Log in to Dropbox (if you aren’t already logged in), then click the connect button:

Dropbox Connect Prompt

After seeing a success message in your web browser, you should see this output on your CentOS server:

Link success output:
This computer is now linked to Dropbox. Welcome Sammy

Now your Dropbox account is linked with the client. You should now have a directory in your home directory called “Dropbox”. This is where it will store your synchronized Dropbox files.

Press Ctrl-C to quit running Dropbox for now.

The next step is to set up some scripts so that Dropbox will run as a service, so that you don’t need to be logged in for the client to keep running.

Set Up Service Script

To start Dropbox as a service, you’ll need to create an init script and a Systemd unit file. To save yourself the trouble, you can use this command to download them:

  1. sudo curl -o /etc/init.d/dropbox https://gist.githubusercontent.com/thisismitch/6293d3f7f5fa37ca6eab/raw/2b326bf77368cbe5d01af21c623cd4dd75528c3d/dropbox
  2. sudo curl -o /etc/systemd/system/dropbox.service https://gist.githubusercontent.com/thisismitch/6293d3f7f5fa37ca6eab/raw/99947e2ef986492fecbe1b7bfbaa303fefc42a62/dropbox.service

Next, make the scripts executable with this command:

  1. sudo chmod +x /etc/systemd/system/dropbox.service /etc/init.d/dropbox

The script expects the /etc/systemd/dropbox file to contain a list of system users that will run Dropbox. Create the file and open it for editing with this command:

  1. sudo nano /etc/sysconfig/dropbox

Add a line that specifies that DROPBOX_USERS is equal to your system username. For example, if your username is “sammy”, it should look like this:

/etc/sysconfig/dropbox
DROPBOX_USERS="sammy"

Save and exit the file by pressing Ctrl-x, then y, then Enter.

Reload the Systemd daemon, so that you can use the unit file:

  1. sudo systemctl daemon-reload

Now Dropbox is ready to be started as a service. Run this command to start it:

  1. sudo systemctl start dropbox

Then run this command to configure the service to start when your server boots:

  1. sudo systemctl enable dropbox

Now the Dropbox client is running as a service and will start automatically when your server boots.

Install Dropbox CLI

Dropbox also includes a command line interface (CLI) that you may want to install so that you can configure your Dropbox client.

To download it to your home directory, run these commands:

cd ~
curl -LO https://www.dropbox.com/download?dl=packages/dropbox.py

Now you will have a file called dropbox.py, the Dropbox CLI, in your home directory.

Use this command to make it executable:

chmod +x ~/dropbox.py

Then, in your home directory, make a symbolic link named .dropbox-dist that points to your Dropbox installation path. This is necessary because the Dropbox CLI expects ~/.dropbox-dist to contain your Dropbox installation:

  1. ln -s /opt/dropbox ~/.dropbox-dist

Now you can run the Dropbox CLI from your home directory with this command:

  1. ~/dropbox.py

This will print out a basic help page. The next subsection will cover how use the Dropbox CLI to do a few basic things.

How to Use the Dropbox CLI

Remember that running the CLI without any options with print out how to use it.

If you want to check the status of your Dropbox, use the status command:

  1. ~/dropbox.py status

If all of your files are synchronized, you should see this message:

Output:
Up to date

You can also use it to turn off the automatic LAN sync feature, which tries to synchronize relevant files on your LAN:

  1. ~/dropbox.py lansync n

Another handy command is exclude. This will let you specify files and directories that should not be synchronized on your server. For example, if you don’t want your server to download the photos directory from Dropbox, you could run this command:

  1. ~/dropbox.py exclude add ~/Dropbox/photos

Then you can verify which files and directories are excluded from your server with this command:

  1. ~/dropbox.py exclude list

Feel free to play with the CLI to see what else you can do with it.

If you want to link more Dropbox accounts, follow this section.

It is possible to link multiple Dropbox accounts to your server. However, you will require an additional system user for each Dropbox account that you want to link. If you don’t know how to add users to your CentOS server, follow this tutorial: How To Add and Delete Users on CentOS.

Once you have the system user account that you want to use, log in to your server as that user.

Run /opt/dropbox/dropboxd. As before, this will output a URL to link a Dropbox account to your server.

Log in to Dropbox under the account that you want to link to your server. Then visit the URL on your server, and click the connect button.

Next, edit /etc/default/dropbox:

  1. sudo nano /etc/default/dropbox

Add the new system user to the list of Dropbox users. For example, if you have two system users running Dropbox, “sammy” and “ben”, it would look something like this.

/etc/default/dropbox
DROPBOX_USERS="sammy ben"

Save and exit the file by pressing Ctrl-x, then y, then Enter.

Now restart the Dropbox service:

  1. sudo service dropbox restart

Now your server is linked to multiple Dropbox accounts.

To use the CLI on the new user, be sure to follow the Install Dropbox CLI section again as the new user.

If you want to unlink a Dropbox account, follow these steps.

First, stop the service:

  1. sudo service dropbox stop

Then edit /etc/defaults/dropbox and remove the user from the list.

Then delete the user’s Dropbox directory. For example:

  1. sudo rm -r ~/ben/Dropbox

Then, if your server still has other Dropbox accounts linked to it, start the Dropbox client again:

  1. sudo service dropbox start

Lastly, if you want to restrict access completely, you can go to your Dropbox Account Security page and delete any linked devices.

Conclusion

The Dropbox client is now installed and running on your server. Your server should now be linked and synchronized with your Dropbox account.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
8 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Boa tarde,

Na hora da instalação esta dando o erro:

/opt/dropbox/dropbox-lnx.x86_64-159.4.5870/dropbox: /lib64/libc.so.6: version `GLIBC_2.18’ not found (required by /opt/dropbox/dropbox-lnx.x86_64-159.4.5870/libdropbox_core.so)

Se alguém puder me ajudar.

Obrigado!

I’m facing the problem

dropbox: load fq extension '/mnt/dropbox/dropbox-lnx.x86_64-76.4.126/apex._apex.cpython-37m-x86_64-linux-gnu.so'
Traceback (most recent call last):
  File "dropbox/client/main.pyc", line 18, in <module>
  File "dropbox/client/features/catalina_migration/catalina_migration_controller.pyc", line 12, in <module>
  File "dropbox/client/authentication/manager.pyc", line 57, in <module>
  File "dropbox/client/high_trace.pyc", line 53, in <module>
  File "dropbox/client/logging/dbxlog_logger.pyc", line 11, in <module>
  File "apex/dbxlog.pyc", line 14, in <module>
  File "<_bootstrap_overrides>", line 153, in load_module
ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /mnt/dropbox/dropbox-lnx.x86_64-76.4.126/apex._apex.cpython-37m-x86_64-linux-gnu.so)
!! dropbox: fatal python exception:
['Traceback (most recent call last):\n', '  File "dropbox/client/main.pyc", line 18, in <module>\n', '  File "dropbox/client/features/catalina_migration/catalina_migration_controller.pyc", line 12, in <module>\n', '  File "dropbox/client/authentication/manager.pyc", line 57, in <module>\n', '  File "dropbox/client/high_trace.pyc", line 53, in <module>\n', '  File "dropbox/client/logging/dbxlog_logger.pyc", line 11, in <module>\n', '  File "apex/dbxlog.pyc", line 14, in <module>\n', '  File "<_bootstrap_overrides>", line 153, in load_module\n', "ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /mnt/dropbox/dropbox-lnx.x86_64-76.4.126/apex._apex.cpython-37m-x86_64-linux-gnu.so)\n"] (error 3)
Aborted

any suggestions?

Can I change the location of where the dropbox client is installed?

I have httpd installed and want to have dropbox installed under /var/www so it will go /var/www/Dropbox as i want to run websites that are synced in dropbox.

I follow this tutorial step by step, and my environment is Centos 7.

but when i run $ /opt/dropbox/dropboxd

and get the following error message:

$ /opt/dropbox/dropboxd
Couldn't start Dropbox.
This is usually because of a permissions error. Storing your home folder on a network share can also cause an error.

Get more help at https://www.dropbox.com/c/help/permissions_error

Please contact Dropbox support with the following info for help:

/tmp/dropbox_errorsqSc6U.txt

and in /tmp/dropbox_errorsqSc6U.txt, it contains:

bn.BUILD_KEY: Dropbox
bn.VERSION: 24.4.16
bn.DROPBOXEXT_VERSION: failed
bn.is_frozen: True
machine_id: failed
pid: 11163
ppid: 11162
ppid exe: '/usr/bin/sudo'
uid: 0
user_info: pwd.struct_passwd(pw_name='root', pw_passwd='x', pw_uid=0, pw_gid=0, pw_gecos='root', pw_dir='/root', pw_shell='/bin/bash')
effective_user_info: pwd.struct_passwd(pw_name='root', pw_passwd='x', pw_uid=0, pw_gid=0, pw_gecos='root', pw_dir='/root', pw_shell='/bin/bash')
euid: 0
gid: 0
egid: 0
group_info: grp.struct_group(gr_name='root', gr_passwd='x', gr_gid=0, gr_mem=[])
effective_group_info: grp.struct_group(gr_name='root', gr_passwd='x', gr_gid=0, gr_mem=[])
LD_LIBRARY_PATH: None
cwd: '/opt/dropbox'
     real_path='/opt/dropbox'
                mode=040755     uid=0   gid=0
     parent     mode=040755     uid=0   gid=0
HOME: u'/root'
appdata: u'/root/.dropbox/instance1'
         real_path=u'/root/.dropbox/instance1'
                mode=040700     uid=0   gid=0
         parent mode=040700     uid=0   gid=0
dropbox_path: u'/root/Dropbox'
              real_path=u'/root/Dropbox'
                        not found
              parent    mode=040550     uid=0   gid=0
sys_executable: '/opt/dropbox/dropbox-lnx.x86_64-24.4.16/dropbox'
                real_path='/opt/dropbox/dropbox-lnx.x86_64-24.4.16/dropbox'
                        mode=0100755    uid=1000        gid=1000
                parent  mode=040755     uid=1000        gid=1000
trace.__file__: '/opt/dropbox/dropbox-lnx.x86_64-24.4.16/library.zip/dropbox/client/ui/common/boot_error.pyc'
                real_path='/opt/dropbox/dropbox-lnx.x86_64-24.4.16/library.zip/dropbox/client/ui/common/boot_error.pyc'
                        not found
                parent  not found
tempdir: '/tmp'
         real_path='/tmp'
                mode=041777     uid=0   gid=0
         parent mode=040555     uid=0   gid=0
Traceback (most recent call last):
  File "dropbox/client/main.py", line 5610, in main_startup
  File "dropbox/client/main.py", line 2306, in run
  File "dropbox/client/main.py", line 1608, in activate_translation
  File "dropbox/i18n.py", line 314, in activate_translation
  File "dropbox/i18n.py", line 366, in system_lang_code
  File "dropbox/i18n.py", line 509, in get_system_languages
  File "locale.py", line 543, in getdefaultlocale
  File "locale.py", line 475, in _parse_localename
ValueError: unknown locale: UTF-8

I am sure that my user “carlos” can run sudo.

Other information:

$ cat /etc/*-release
CentOS Linux release 7.3.1611 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.3.1611 (Core)
CentOS Linux release 7.3.1611 (Core)

$ uname -m
x86_64

Could anyone help me to fix it? Thanks.

multiuser systemd script with no wrapper the following procedure does:

  • install the dropbox headless linux client daemon in its own folder
  • create and activate the multiuser systemd script (written by me)
  • create a local dropbox user
  • synchronize
  • install the service for that user

su # be the super user mkdir /opt/dropbox # create install subdirectory, ensure all parents has “+x” permissions cd /opt/dropbox curl -JLO https://www.dropbox.com/download?plat=lnx.x86_64 # or “lnx.x86” for 32-bit (wget redirections are bugged) tar -xvzf dropbox-lnx.{version}.tar.gz # replace {version} vi /etc/systemd/system/dropbox@.service # edit file as shown below

------ edit file ------ [Unit]

Description=Dropbox headless client daemon for user %i Documentation=https://www.digitalocean.com/community/tutorials/how-to-install-dropbox-client-as-a-service-on-centos-7 After=network.target syslog.target

[Service]

User=%i Environment=LC_ALL=en_US.UTF-8 Environment=LANG=en_US.UTF-8

ExecStart=/opt/dropbox/.dropbox-dist/dropboxd

[Install]

WantedBy=multi-user.target ------ end ------

systemctl daemon-reload # load new script useradd dpbox-user # create local user su dpbox-user /opt/dropbox/.dropbox-dist/dropboxd # sinchronize dropbox account before enable daemon

------ console message ------ This pc is not linked to dropbox… Visit https://www.dropbox.com/cli_link_nonce?nonce=XxXxXxX … ------ stay ------

.# open the shown link in another browser from any pc, login and press “Connect” .# when the message changes, cancel the program (ctrl-c)

------ console message ------ linked to dropbox, welcome {user} ------ cancel ------

exit # return to super user systemctl enable dropbox@dpbox-user.service # enable and start dropbox for our user systemctl start dropbox@dpbox-user.service

the following procedure does:

  • install the dropbox headless linux client daemon in its own folder
  • create and activate the multiuser systemd script (written by me)
  • create a local dropbox user
  • synchronize
  • install the service for that user

su # be the super user mkdir /opt/dropbox # create install subdirectory, ensure all parents has “+x” permissions cd /opt/dropbox curl -JLO https://www.dropbox.com/download?plat=lnx.x86_64 # or “lnx.x86” for 32-bit (wget redirections are bugged) tar -xvzf dropbox-lnx.<version>.tar.gz # replace <version> vi /etc/systemd/system/dropbox@.service # edit file as shown below

------ edit file ------ [Unit]

Description=Dropbox headless client daemon for user %i Documentation=https://www.digitalocean.com/community/tutorials/how-to-install-dropbox-client-as-a-service-on-centos-7 After=network.target syslog.target

[Service]

User=%i Environment=LC_ALL=en_US.UTF-8 Environment=LANG=en_US.UTF-8

ExecStart=/opt/dropbox/.dropbox-dist/dropboxd

[Install]

WantedBy=multi-user.target ------ end ------

systemctl daemon-reload # load new script useradd dpbox-user # create local user su dpbox-user /opt/dropbox/.dropbox-dist/dropboxd # sinchronize dropbox account before enable daemon

------ console message ------ This pc is not linked to dropbox… Visit https://www.dropbox.com/cli_link_nonce?nonce=XxXxXxX … ------ stay ------

open the shown link in another browser from any pc, login and press “Connect”

when the message changes, cancel the program (ctrl-c)

------ console message ------ linked to dropbox, welcome <user> ------ cancel ------

exit # return to super user systemctl enable dropbox@dpbox-user.service # enable and start dropbox for our user systemctl start dropbox@dpbox-user.service

There’s a reference to /etc/systemd/dropbox but it should have been /etc/sysconfig/dropbox probably. Variable dbuser_home set in the init script is not used. It looks like this script is a modified copy of https://gist.github.com/kbrnsr/571f0bdb865e8fb1d846 or similar where this variable is being used.

Why use an init script instead of just plain systemd running the dropboxd daemon that comes with the base install? What I use is:

[Unit]
Description=Dropbox Service
After=network.target

[Service]
Restart=always
ExecStart=/home/username/.dropbox-dist/dropboxd
User=username

[Install]
WantedBy=multi-user.target

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel