3

I'm inheriting admin control over a server used to process and share data between investigators. We've been trying to use Dropbox to share some of the files. Dropbox was installed when I took over the server, so it seemed like an easy method. However, I can't get Dropbox to stay running consistently.

I initially linked my account to Dropbox using the GUI in an X session. I added the Dropbox CLI interface (dropbox.py) and an init.d entry to start it as a daemon, using one of the many examples I found online (currently init.d script is modeled after this one, see below for the actual script).

When I reboot the server calling service dropbox status returns that it is running, but dropbox.py states it is not, and nothing syncs. If I manually start using dropbox.py, everything syncs - but the dropbox service reports it as not running. If I manually start via service dropbox start, the service reports itself as not running but dropbox.py reports it as syncing. Whenever I log in and fix it, everything seems to run fine for a day or two, but then it stops syncing again.

I've tried killing the init.d script, removing all entries and reinstalling. I've tried reinstalling Dropbox via command line. I cannot seem to figure out what the issue is, and the examples I'm finding elsewhere all assume the server is running headless only (which it isn't - several users are primarily accessing it via remote desktop).

I don't care if Dropbox starts on GUI login or not, I just want it running in the background at all times, whether I am logged in or not. And I definitely don't want it to stop if I log in (either CLI or X session), which I have read can happen depending on how it's started initially.

(Dropbox 2.10.3, x64, on Ubuntu 12.04.5 LTS)

Any suggestions?

init.d/dropbox script in use (example here uses dummy user name):

#!/bin/sh
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: dropbox service
### END INIT INFO

# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="my_user_name"

start() {
  echo "Starting dropbox..."
  for dbuser in $DROPBOX_USERS; do
    HOMEDIR=$(getent passwd $dbuser | cut -d: -f6)

    DAEMON=$(find $HOMEDIR/.dropbox-dist/dropbox-lnx.* -name dropboxd)

    if [ -x $DAEMON ]; then
      HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $DAEMON -p "$HOMEDIR/.dropbox/dropbox.pid"
    fi
  done
}

stop() {
  echo "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
      HOMEDIR=$(getent passwd $dbuser | cut -d: -f6)

      DAEMON=$(find $HOMEDIR/.dropbox-dist/dropbox-lnx.* -name dropbox)

      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=`ps -u $dbuser -o pid,cmd | grep "$HOMEDIR"/"$DAEMON"\$ | awk '{ print \$1 }'`
    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
  • Updated: Removed '"$HOMEDIR"/' in the status grep command as I realized it was already defined in $DAEMON. Returns status as running but pulls multiple PIDs instead of just the first one; returns an error as well. If I run the same command manually it only returns the single correct process ID. – dr.nixon Aug 11 '14 at 17:46
  • Ever solve this? – HDave Sep 11 '14 at 18:07
  • Apparently. It's still running, so the script seems to be working. But I also haven't logged in interactively since setting it up, and I read elsewhere that doing so might interrupt the CLI daemon. I killed Dropbox and reinstalled from CLI, that and fixing the script error above seem to have corrected things. – dr.nixon Sep 15 '14 at 16:33
1

I've been using the script at http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment which had been working previously, but when I check today it wasn't working.

Eventually I found that the line

DAEMON=.dropbox-dist/dropbox

needed changing to DAEMON=.dropbox-dist/dropboxd

Now it works.

  • FYI, stopping the daemon won't work right. When dropboxd runs, it spawns a process like .dropbox-dist/dropbox-lnx.x86_64-2.10.30/dropbox. When 'stop' is called in the init script, it looks for .dropbox-dist/dropboxd. – David L Nov 18 '14 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.