Dropbox with Slackware (command line)

I tried Dropbox in a very desultory fashion a few months ago, but when I saw it worked through Nautilus, I promptly dropped it. Nautilus? The only Nautilus I know is a shell (on the beach) and a submarine (Nautilus 90 North – for school).

Recently, old friends joined me on Facebook. And I got pushed into Dropbox again. This time, there was success.

There are Windows, Mac and Linux versions of Dropbox for download. For Linux, they support a number of the more popular distributions, and have a “Compile from Source” version for the other distributions, including Slackware. I had a look at this, but it still works with Nautilus. I still don’t know what or where Nautilus is. It might be a Gnome thing, and Slackware does not do Gnome.

Luckily, for die-hard command line people who don’t live in GUI land, they have a command line version of Dropbox. The instructions are very simple, and they work.

  • Download the dropbox.tar.gz for the platform of your choice
  • Untar it in your home directory, and it creates a $HOME/.dropbox-dist directory with the Dropbox app in it.
  • Run this as $HOME/.dropbox-dist/dropboxd
  • Then follow the instructions to create a Dropbox account or log in to your existing account

I found it very easy, and in the end, I was connected, I had a $HOME/Dropbox directory with stuff in it and it worked. I remotely installed it on another of my computers and that went just as easily. And then I installed the iPhone app for Dropbox and it worked nicely too. I had no failures anywhere, which was a surprise. It all just worked. Then I had invitations from the friends who put me up to it, I accepted those invitations, we all got an extra 250 meg of storage, and I could see their public Dropbox directories. Cool.

There was one thing that needed fixing. I wanted Dropbox to start up at boot time. This was easy. I added this to the end of my /etc/rc.d/rc.local:

# Start Dropbox
if [ -x /etc/rc.d/rc.dropbox ]; then
    /etc/rc.d/rc.dropbox start
fi

and then created this file and made it executable – /etc/rc.d/rc.dropbox. Dropbox give examples of startup scripts for other distributions, and I only needed to make small modifications to make it work the Slackware way.

#!/bin/sh
#
# /etc/rc.d/rc.dropbox:  Start dropbox for the specified users
#

DROPBOX_USERS="hgriggs"

DAEMON=.dropbox-dist/dropboxd

start() {
    echo "Starting dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            echo "su -l $dbuser -c '$HOMEDIR/$DAEMON &'"
            /bin/su - $dbuser -c "$HOMEDIR/$DAEMON &"
        fi
    done
}

stop() {
    echo "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
        dbpid=`pgrep -u $dbuser dropbox`
        kill $dbpid
    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)
        stop
        start
        ;;

    status)
        status
        ;;

    *)
        echo "Usage: /etc/rc3.d/rc.dropbox {start|stop|restart|status}"
        exit 1

esac

exit 0

So now I have Dropbox working the sensible way. If I want to share files between my work and home computers and my laptops, I can drop files in my $HOME/Dropbox directory and magically they will appear everywhere. Even on my iPhone, and I note that the iPhone app has some ability to display some common formats so I can read the files. I should read more about this. But this is a very handy tool that lets me shuffle files around very easily. With the added bonus of a Public directory so I can share my files with others, and share their public files.