Install Dropbox as a service on Linux

May 13th, 2012 | Posted by spritian in Linux | Ubuntu

This article will guide you on how to install Dropbox as a service on Linux. First things first, let’s get Dropbox downloaded and installed on our server. To start, paste the following in your terminal…

For 32-bit:


cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

For 64-bit:


cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

After that’s complete, run the dropboxd command:


~/.dropbox-dist/dropboxd

Next, You’ll see something like this…


This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=hostid to link this machine.

Click that link, login with your credentials to link your new dropboxd service to your account. Shortly after, the message above should stop spamming and say that it is now linked! Hit CTRL+C to quit.

The last thing we need to do is enable a init.d script to boot at runtime.

First, determine your current runlevel:


runlevel
N 2

So our current runlevel is 2. Let’s add it correctly though by adding a new “dropboxd” file in /etc/init.d. The only thing you need to modify in the script below is the DROPBOX_USERS variable.


#!/bin/sh
DROPBOX_USERS="myusername"
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

Now that the script resides in init.d, let’s change folders to /etc/rc2.d (our runlevel) and make a symlink from ../init.d/dropboxd to the present working dir.


cd /etc/rc2.d
ln -s ../init.d/dropboxd S99dropboxd

That’s it! You can call it with the service command, or just execute it from /etc/init.d or /etc/rc2.d.

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

3 Responses

  • Jorge says:

    Er obviously their pcraviy policy plays with you when they say: BY UTILIZING THE SITE, CONTENT, FILES AND/OR SERVICES, YOU CONSENT TO ALLOW DROPBOX TO ACCESS YOUR COMPUTER TO ACCESS ANY FILES THAT ARE PLACED IN THE MY DROPBOX,’ DROPBOX’ FOLDERS, AND/OR ANY OTHER FOLDER WHICH YOU CHOOSE TO LINK TO DROPBOX. It is not a joke, they are mixing Dropbox (as a service) with Dropbox as a company, throughout all their legal stuff. WTF (sorry for ranting here, but I think other users should be concerned, and I almost rushed into using their service after reading your posts).Cheers!

  • Pingback: 多终端远程发布 Octopress 博客 | Opoo.org



Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre user="" computer="" escaped="">