Friday, November 14, 2014

Install Dropbox On CentOS (No GUI required)

This guide is designed for VPS owners who use CentOS 32-bit, or 64-bit.


  • Architecture x86 (32-bit) or x86_64 (64-bit)
  • wget
  • vi (text editor)
  • Python 2.x
  • a web browser (on a PC you have access to)

Setup process

Install the latest dropbox linux distro

This ONLY installs for the current user. I would recommend root. But you are free to choose whatever user you want to have the dropbox user on the VPS.
  1. Check the version of CentOS you have:
    uname -m
  2. If you are on 32-bit CentOS: (i686)
    cd ~ && wget -O - "" | tar xzf -
  3. If you are on 64-bit CentOS: (x86_64)
    cd ~ && wget -O - "" | tar xzf -

Run & Link your Dropbox Account

  1. Run the dropboxd application.
  2. It will return repeatedly:
    "This computer isn't linked to any Dropbox account...
    Please visit code)" to link this device.
  3. Go to a browser window. (Doesn’t matter if it’s the same computer, can be your Windows PC.) Copy the link, paste it, and log into the dropbox account you want the account to be linked to.
  4. After your done logging in, a new folder will appear on the server’s user directory called “Dropbox”. Use ctrl+c to stop dropboxd for the next step.

Downloading the CLI interface from Dropbox

  1. If you do not have python (2.x) installed, you can do so with:
    yum install python
  2. Type the following to download & install the official script:
    mkdir -p ~/bin && wget -O ~/bin/ "" && chmod +x ~/bin/
  3. First you need to turn on dropbox:
    ~/bin/ start
  4. If this is a server, you want to prevent lan broadcasting so you don’t get in trouble with your VPS provider:
    ~/bin/ lansync n
  5. From here, you have to wait.. you can type this to see when dropbox is finished synchronizing all the data.
    ~/bin/ status
    "Up to date"
  6. The steps below explain how to sync a specific folder(s), if you dont care about this, you can go straight to step 10. Before moving to the next step, it is important to know that putting files in your root directory of dropbox will clutter things, create a folder like “unsorted”, and put your files in there. (Note: Someone could add white list functionality to via github)
  7. After it says it’s up to date, you want to exclude everything:
    cd ~/Dropbox && ~/bin/ exclude add *
  8. This will show all the files excluded.
    ~/bin/ exclude list
  9. Then you can remove files from exclusion (the ones you want the server to have), by typing this:
    ~/bin/ exclude remove 'a folder with spaces' my_homework etc
  10. Give it a few seconds.. then turn off the dropbox sync like this:
    ~/bin/ stop

Creating soft links outside of ~/Dropbox

The first argument is the path to the folder you want to sync, like your log files.
The second argument is the path to the new dropbox folder/file you want to keep updated in ~/Dropbox.
  1. Ensure that dropbox is stopped by typing:
    ~/bin/ stop
  2. Remove the synced file/folder
    rm -rf ~/Dropbox/my_server_log
    ln -s /path/to/(server log) ~/Dropbox/my_server_log
  3. (Optionally) This may be the /path/to/(server log) might be out of date. You can make dropbox OVERWRITE the server file by setting the date below the last modified date shown on dropbox. I highly recommend that you backup the dropbox folder before you start syncing.
  4. Start dropbox:
    ~/bin/ start
  5. You can “watch” the sync by typing this:
    ~/bin/ status
  6. When uploading new content, it will say files uploaded, when downloading, it will say files are downloading. When deleting, you don’t get any messages on what’s being deleted using status.
  7. Repeat steps 1-6 until you have soft linked all files/folders you wanted to have synced with ~/Dropbox.

Create a linux service daemon (Automatic sync after reboot)

  1. Ensure that dropbox is not running, by typing this:
    ~/bin/ stop
  2. On CentOS, type the following:
    touch /etc/init.d/dropbox && chmod 755 /etc/init.d/dropbox && vi /etc/init.d/dropbox
  3. Press “i” without quotes to enter edit mode. Then paste the following code:
    # chkconfig: 345 85 15
    # description: Startup script for dropbox daemon
    # processname: dropboxd
    # pidfile: /var/run/
    # config: /etc/sysconfig/dropbox
    # Provides: dropboxd
    # Required-Start: $local_fs $network $syslog
    # Required-Stop: $local_fs $syslog
    # Should-Start: $syslog
    # Should-Stop: $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start up the Dropbox file syncing daemon
    # Description:       Dropbox is a filesyncing sevice provided by
    #                    This service starts up the dropbox daemon.
    # Source function library.
    . /etc/rc.d/init.d/functions
    # To configure, add line with DROPBOX_USERS="user1 user2" to /etc/sysconfig/dropbox
    # Probably should use a dropbox group in /etc/groups instead.
    [ -f /etc/sysconfig/dropbox ] && . /etc/sysconfig/dropbox
    start() {
        echo -n $"Starting $prog"
        if [ -z $DROPBOX_USERS ] ; then
            echo -n ": unconfigured: $config"
            rm -f ${lockfile} ${pidfile}
            return $RETVAL
        for dbuser in $DROPBOX_USERS; do
            dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
            daemon --user $dbuser /bin/sh -c "$dbuser_home/.dropbox-dist/dropboxd&"
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
    status() {
        for dbuser in $DROPBOX_USERS; do
            dbpid=`pgrep -u $dbuser dropbox | grep -v grep`
            if [ -z $dbpid ] ; then
                echo "dropboxd for USER $dbuser: not running."
                echo "dropboxd for USER $dbuser: running (pid $dbpid)"
    stop() {
        echo -n $"Stopping $prog"
        for dbuser in $DROPBOX_USERS; do
            dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
            killproc $dbuser_home/.dropbox-dist/dropbox
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
    # See how we were called.
    case "$1" in
            echo $"Usage: $prog {start|status|stop|restart}"
    exit $RETVAL
  4. Save the pasted contents by pressing escape key, then typing “:wq” without quotes, then press the enter key.
  5. Type this to manually assign which user(s) have dropbox installed:
    vi /etc/sysconfig/dropbox
  6. Typing “i” for edit mode, and then paste this: (“linux_user_name(s)” being the user(s) you are installing with dropbox, example: DROPBOX_USERS=”jdoe”))
  7. Save the file by pressing escape key. Then typing “:wq” without quotes, then pressing the enter key.
  8. Then type this to add to chkconfig, and start the newly created dropbox service:
    service dropbox start && chkconfig dropbox on

Curious what version of the dropbox client your running?

Type this:
echo 'Dropbox '`cat ~/.dropbox-dist/VERSION`

No comments: