How to install Dropbox Client as a service on Ubuntu 14.04

Introduction

In this tutorial, we will show you how to install the Dropbox client on an Ubuntu 14.04 server and configure it to run as a headless service. This will allow your server to connect to Dropbox so that you can sync copies of Dropbox files on the server.

prerequisites

You must have a non-root user (sudo) with super user privileges. Students who don’t have a server can buy from here, but I personally recommend you to use the free Tencent Cloud Developer Lab for experimentation, and then buy server. All the commands in this tutorial will be executed as this non-root user.

Once ready, we will install the Dropbox client.

Install the Dropbox client

You can use the following command to download the latest version of the Linux Dropbox client to your home directory:

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

Now you will call a file named dropbox-linux-x86_64.tar.gz in the home directory.

**Note: **If you are running a 32-bit distribution, please use this command instead of downloading a 32-bit Linux client:

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

Next, use the following command to extract the contents of the Dropbox archive to /opt/dropbox:

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 associate it with your Dropbox account.

Link to Dropbox client

To link the Dropbox client with the Dropbox account, run this command (as the user who wants Dropboxfile storage in their home directory):

/opt/dropbox/dropboxd

This will launch the Dropbox client in the foreground, so you cannot enter any other commands at this time. When you run the client for the first time, you should see output like the following:

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 example above) in a web browser on your local computer.

Log in to Dropbox (if you are not already logged in), and click the connect button:

After seeing the success message in the web browser, you should see this output on the Ubuntu server:

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

Now your Dropbox account has been linked with the client. You should now have a directory called "Dropbox" in your home directory. This is where the synchronized Dropbox files are stored.

**Press Ctrl-C to exit and pause Dropbox. **

The next step is to set up some scripts so that Dropbox runs as a service so that you don't need to log in to keep the client running.

Set service script

To start Dropbox as a service, you need to create a script. To save trouble, you can use this command to download it to /etc/init.d/dropbox:

cd ~
sudo curl -o /etc/init.d/dropbox https://gist.githubusercontent.com/thisismitch/d0133d91452585ae2adc/raw/699e7909bdae922201b8069fde3011bbf2062048/dropbox

Next, use the following command to make the script executable:

sudo chmod +x /etc/init.d/dropbox

The script expects the /etc/default/dropbox file to contain a list of system users that will run Dropbox. Use the following command to create a file and open it for editing:

sudo nano /etc/default/dropbox

Add a line and specify that the line DROPBOX_USERS is equal to your system username. For example, if your username is "sammy", it should look like this:

DROPBOX_USERS="sammy"

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

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

sudo service dropbox start

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

sudo update-rc.d dropbox defaults

Now, the Dropbox client runs as a service and automatically starts when the server starts.

Install Dropbox CLI

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

To download it to your home directory, run the following command:

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

Now, there will be a file called dropbox.pyDropbox CLI in your home directory.

Use this command to make it executable:

chmod +x ~/dropbox.py

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

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

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

~ /dropbox.py

This will print out a basic help page. The next section will introduce how to use the Dropbox CLI to perform some basic operations.

How to use Dropbox CLI

Remember to run the CLI without any options and print out how to use it.

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

~ /dropbox.py status

If all files are synchronized, you should see the following message:

Up to date

You can also use it to turn off the automatic LAN synchronization function, which will try to synchronize related files on the LAN:

~ /dropbox.py lansync n

Another convenient command is exclude. This will allow you to specify files and directories that should not be synchronized on the server. For example, if you don't want the server to download the photos directory from Dropbox, you can run the following command:

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

Then, you can verify which files and directories are excluded from the server using the following command:

~ /dropbox.py exclude list

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

How to link other Dropbox accounts

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

You can link multiple Dropbox accounts to your server. However, you need to use another system user for each Dropbox account you want to link.

After obtaining the system user account to be used, log in to the server as that user.

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

Log in to Dropbox under the account you want to link to the server. Then visit the URL on the server and click the "Connect" button.

Next, edit /etc/default/dropbox:

sudo nano /etc/default/dropbox

Add the new system user to the Dropbox user list. For example, if you have two system users running Dropbox, "sammy" and "ben", it looks like this.

DROPBOX_USERS="sammy ben"

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

Now restart the Dropbox service:

sudo service dropbox restart

Your server is now linked to multiple Dropbox accounts.

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

How to unlink a Dropbox account

If you want to unlink your Dropbox account, please follow the steps below.

First, stop the service:

sudo service dropbox stop

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

Then delete the user's Dropbox directory. E.g:

sudo rm -r ~/ben/Dropbox

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

sudo service dropbox start

Finally, if you want to completely restrict access, you can go to the Dropbox Account Security Page and delete any linked devices.

in conclusion

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

For more Ubuntu tutorials, please go to [Tencent Cloud + Community] (https://cloud.tencent.com/developer?from=10680) to learn more.


Reference: "How To Install Dropbox Client as a Service on Ubuntu 14.04"

Recommended Posts

How to install Dropbox Client as a service on Ubuntu 14.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to build nfs service on ubuntu16.04
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install GCC compiler on Ubuntu 18.04
How to install Graylog 1.x on Ubuntu 14.04.