Share the Knowledge!

In this guide I will show you how to setup dropbox backup as service. Some of the following information has been found here: Text Based Linux Install

Disclaimer

Even I tried myself this command sequence you are informed and you must accept any risks deriving from these documentation usage and you cannot claim any damages to me for your own actions.

Prerequisites

Registration and creating the account procedures could be complete in a more intuitive way using the graphical user interface (GUI) if you have at least one Linux box onto which forward display X connection. In order to be able to remote the GUI you should start from that linux box and allow X forwarding:

xhost +server_ip
ssh -X user_name@server_ip

It was reported that it would be possible to install DropBox following the next instructions and not forwarding X (at least it was done in Debian squeeze). Don’t run export DISPLAY. When you run dropboxd, it will print onto the text console a URI to activate the account. Copy that URI into your browser and proceed to creation of a Dropbox account. A few seconds after visiting that uri, dropboxd will complain it cannot run nautilus. Just ignore it and continue with the steps.

Howto step by step

sudo -s
groupadd dropbox
useradd -r -d /etc/dropbox -g dropbox -s /bin/false dropbox
# note that when running 64-bit you need to use http://www.dropbox.com/download/?plat=lnx.x86_64 in the next line (!)
wget -O /tmp/dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86
mkdir -p /usr/local/dropbox /etc/dropbox
chown dropbox.dropbox /etc/dropbox
chmod 700 /etc/dropbox
tar xvzf /tmp/dropbox.tar.gz -C /usr/local/dropbox --strip 1
rm /tmp/dropbox.tar.gz

su -l dropbox -s /bin/bash
umask 0027
# the next line is useful only if you a linux box with X
export DISPLAY=10.0.XX.YY:0.0
/usr/local/dropbox/dropboxd
# register a new account and/or register this machine. Be sure to '''do this while dropboxd is running'''
exit

cat <<EOF | sed -e "s,%,$,g" >/etc/init.d/dropbox
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the dropbox service
# Description: starts dropbox using start-stop-daemon
### END INIT INFO

DROPBOX_USERS="dropbox"
DAEMON=/usr/local/dropbox/dropbox
unset DISPLAY

start() {
   echo "Starting dropbox..."
   for dbuser in %DROPBOX_USERS; do
      HOMEDIR=%(getent passwd %dbuser | cut -d: -f6)
      if [ -x %DAEMON ]; then
         HOME="%HOMEDIR" start-stop-daemon -b -o -c %dbuser -S -u %dbuser -x %DAEMON
      fi
   done
}

stop() {
   echo "Stopping dropbox..."
   for dbuser in %DROPBOX_USERS; do
      HOMEDIR=%(getent passwd %dbuser | cut -d: -f6)
      if [ -x %DAEMON ]; then
         start-stop-daemon -o -c %dbuser -K -u %dbuser -x %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
      sleep 1
      status
      ;;

   stop)
      stop
      sleep 1
      status
      ;;

   restart|reload|force-reload)
      stop
      start
      sleep 1
      status
      ;;

   status)
      status
      ;;

   *)
      echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
      exit 1

esac

exit 0
EOF
chmod a+x /etc/init.d/dropbox
update-rc.d dropbox defaults
/etc/init.d/dropbox start

Share the Knowledge!

Helpful(2) Unhelpful(0)
  • fx

    To make this work I had to unescape the sequences ‘<<‘ and ‘>’in line 22 with ‘<‘. Thanks a lot nonetheless!

    • fx

      ~~~~~~
      << to <

      ~~~~~~

      • Guest

        This guide is outdated; dropbox is available through Portage with a simple: emerge -av dropbox.

    • Mauro Toffanin

      This guide is very outdated; dropbox is available through Portage with a simple: emerge -av dropbox.

  • Jonatas Prust

    After i do the command /usr/local/dropbox/dropboxd, i get the message:
    Unable to access the X Display, is $DISPLAY set properly?

    I enable the service and have it running, but not syncing.
    Starting dropbox…
    dropboxd for USER dropbox: running (pid 29005)

    Debian Squeeze 64 with gnome installed.

    • Mauro Toffanin

      this guide is outdated; dropbox is available through Portage with a simple: emerge -av dropbox.

  • Vieras

    On line 34 there should be ‘d’ in the end.
    DAEMON=/usr/local/dropbox/dropboxd