Solving the Dropbox Problem

In our department, all of our home directories are stored on a central fileserver and mounted to each machine as needed. Windows workstations get a network drive rooted at /home/<user> and linux workstations automount /home on /misc/home as needed. Many of our faculty use Dropbox as a way to access their files from home, on vacation, wherever they need to be. This can cause a problem for us with dropbox because we also provide terminal server access (from anywhere). We have had trouble with users installing dropbox into their home directories, and running it on more than one department workstation (or our terminal server). This can cause trouble because there are multiple dropbox clients updating the same directory on disk. I decided to do a centralized dropbox install on our fileserver which can be made available to anyone who would like to link their dropbox account to the department fileserver.

Get The Dropbox Tarball

root@fileserver# wget -O dropbox.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64

root@fileserver# tar xf dropbox.tar.gz -C /opt/

root@fileserver# mv /opt/.dropbox-dist /opt/dropbox

Set The Sysconfig Options (/etc/sysconfig/dropbox)

This file in sysconfig tells us how many dropbox daemons to run/install. For each user who wants to use dropbox, we have them fill out a webform with their userid, which we add to DROPBOX_USERS

DROPBOX_USERS="user1 user2 user3 ..."

Install The Init Script (/etc/init.d/dropbox)

Modified from the one provided at Dropbox Wiki

# chkconfig: 345 85 15
# description: Startup script for dropbox daemon
#
# processname: dropboxd
# pidfile: /var/run/dropbox.pid
# config: /etc/sysconfig/dropbox
#

### BEGIN INIT INFO
# 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 dropbox.com
# This service starts up the dropbox daemon.
### END INIT INFO

# 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
prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/$prog}
config=${CONFIG-/etc/sysconfig/dropbox}
RETVAL=0

start() {
echo -n $"Starting $prog"
if [ -z $DROPBOX_USERS ] ; then
    echo -n ": unconfigured: $config"
    echo_failure
    echo
    rm -f ${lockfile} ${pidfile}
    RETURN=6
    return $RETVAL
fi
for dbuser in $DROPBOX_USERS; do
    daemon --user $dbuser /bin/sh -c "/opt/dropbox/dropboxd&"
done
RETVAL=$?
echo
[ $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."
    else
        echo "dropboxd for USER $dbuser: running (pid $dbpid)"
    fi
    done
}

stop() {
echo -n $"Stopping $prog"
for dbuser in $DROPBOX_USERS; do
    killproc /opt/dropbox/dropbox
done
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

# See how we were called.
case "$1" in
start)
    start
    ;;
status)
    status
    ;;
stop)
    stop
    ;;
restart)
    stop
    start
    ;;
*)
    echo $"Usage: $prog {start|status|stop|restart}"
    RETVAL=3

esac

exit $RETVAL

Post-Setup

After the dropbox distribution is in place, the init script is installed and the users are configured, it is time to start each of the daemons.

root@fileserver# service dropbox start
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=abcdef1234567890 to
link this machine.

At this point, dropbox will print registration URLs to stdout. For now, it is important to do one user at a time to match each registration URL to a user.

TODO

  • Automate dropbox user addition
    • Eventually I would like to build this into our soon-to-be-released selfserv application. It would be trivial to modify this script to check a UNIX group rather than an initscript array to get user information.
  • Capture the output from each daemon to separate logfiles in order to track down issues
  • Use pydropboxvalues to capture registration URL and present it to the user on the selfserv signup page

Copyright © 2012-2014 Brian Stinson. All Rights Reserved