Dropbox is so useful! Wouldn’t it be great to have that same convenience and function for your user account on your server, just like you have on your workstation?
This has been tested on Ubuntu Lucid and Jaunty. This procedure will create a system with:
- Install a separate Dropbox client (daemon) for individual users
- Each user has a separate Dropbox account
- All the daemons will be managed together with normal daemon controls
This allows individuals to have their own Dropbox accounts, each with a separate process syncing their individual ~/Dropbox directory. With one command an admin can start or stop all the daemons at once.
Install Prerequisites
Later, we’ll need to read a sqlite3 database record, so install sqlite3.
sudo aptitude -y install sqlite3
Install Dropbox client for an individual user
This step is repeated for each user that wants a Dropbox client. Start by setting up your own account, then repeat for each user. This is run with a user’s own account. The changes made all take place in their home directory.
First, determine whether you have 32-bit or 64-bit Ubuntu Server. You must install the correct version, either 32 or 64 bit or it will not work. The following command will tell you which is installed:
uname -a | grep '_64' >/dev/null && echo 'A 64-bit OS is installed'; uname -a | grep '_64' >/dev/null || echo 'A 32-bit OS is installed'
Run the correct installation, based on whether a 32-bit or 64-bit OS is installed.
32-bit installation:
cd ~ wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86 tar -zxof dropbox.tar.gz
or
64-bit installation:
cd ~ wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86_64 tar -zxof dropbox.tar.gz
Link user’s Dropbox client to their Dropbox account:
wget http://dl.dropbox.com/u/6995/dbmakefakelib.py python dbmakefakelib.py
The above will run for a little while without printing anything, then print “dropboxd ran for 15 seconds without quitting – success?”. When it does so, press control-c twice. Yes, it is unusual. What this does is populate a sqlite3 database with an ID from the Dropbox server. Next, we’ll extract that code and use it to link your Dropbox user account with this CLI Dropbox client instance.
On the server, via SSH
Get the URL with:
echo https://www.dropbox.com/cli_link?host_id=`echo '.dump config' | sqlite3 ~/.dropbox/dropbox.db | grep host_id | cut -d \' -f 4 | python -c 'print raw_input().decode("base64")' | grep '^V' | cut -b 2-`
On your local machine, in a web browser
Copy the URL that the above printed and paste it into a web browser. When you do so, Dropbox will register your client on the server with your Dropbox account.
At this point, Dropbox will not be quite working yet. The next steps will take care of that.
Create Dropbox daemon control
The next task is to create a system to start and stop the dropbox daemon for each user on the system that has Dropbox installed for his/her user account. The following daemon init script was lifted from: http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall.
Of course, this is for the use of the system admin. This creates a normal daemon init start/stop script and installs it so the Dropbox daemons are started when the system boots. The admin can also use this to control the Dropbox daemons manually.
sudo vi /etc/init.d/dropbox
Paste in the following code. Then, modify line 3, replacing “user1 user2″ with your username. For future reference, additional user’s Dropbox daemons can be controlled with this one script – add additional username separated with spaces.
# dropbox service
# separate usernames in the following line with spaces.
DROPBOX_USERS="user1 user2"
DAEMON=.dropbox-dist/dropbox
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then
HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
fi
done
}
stop() {
echo "Stopping dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then
start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
fi
done
}
status() {
for dbuser in $DROPBOX_USERS; do
dbpid=`pgrep -u $dbuser dropbox`
if [ -z $dbpid ] ; then
echo "dropboxd for USER $dbuser: not running."
else
echo "dropboxd for USER $dbuser: running (pid $dbpid)"
fi
done
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
exit 1
esac
exit 0
Make the init script executable and restart the daemon:
sudo chmod +x /etc/init.d/dropbox sudo /etc/init.d/dropbox restart
When you restart the daemon, it will be running correctly linked to your Dropbox account. It will create a Dropbox directory in your home directory and will start to populate it with files you have on Dropbox.
Have the daemon(s) run automatically at boot time:
sudo update-rc.d dropbox defaults
The above correctly copies links as needed so the daemon(s) start when the server boots.
Managing the Daemons
A separate daemon will be run for each user that has the Dropbox client installed – with only one command. This makes it easy for individual users to have separate Dropbox accounts, each syncing to ~/Dropbox for their user account. Here are the commands to manage these daemons:
Start Dropbox services for all users:
sudo /etc/init.d/dropbox start
Stop Dropbox services for all users:
sudo /etc/init.d/dropbox stop
Restart Dropbox services for all users:
sudo /etc/init.d/dropbox restart
Get service status for each user Dropbox service:
sudo /etc/init.d/dropbox status

Thanks, this helped a lot.
Glad to hear it!
Excellent tutorial. Very thorough.
I can only suggest clarifying the registration URL step a little. I had to execute the embedded executable code separately on my server (remotely hosted), then copy the key, with the rest of the registration URL into the browser address bar on the laptop I was working on – which was logged into my Dropbox account.
Thanks a bunch. I’d have never figured out all this without your post.
Cheers!
Thanks, Louis. I updated the post. -A
Thank, You, Very, Much for this guide. I’ve read several of them but the rest was either outdated or incomplete.
With your guide the process was almost flawless. One minor glitch being that after ‘python dbmakefakelib.py’ I got Dropbox ‘account linking’ window, and breaking the process with Ctrl+C did not put the host_id where the next command could grab it from… (I guess your guide is aimed at server admins working w/o UI.)
I had to obtain the host_id elsewhere, but now all seems running well.
Thanks again
Good to hear – maybe someone else will benefit from you comments. -Andrew
Just one question,
How heavy is the client on system resources? I am running a 13 EUR / month VPS, and this dropbox gallery thing would be for one or more small artist websites, giving them a more comfortable way to upload their images.
I imagine the client/daemon has to “check base” from time to time, similar to a cron job.
Besides, it will have an install footprint on disk (but probably not too much).
Besides that, I dunno. Some constant memory hugging? I hope not?
Otherwise, thanks for the tutorial!