Hey T-I, I wrote this as a tutorial for my customers, but i thought i would share it here as well. If there are any issues let me know and i will try to correct it. It worked for me so we should be good to go!
In order to take advantage of this, you will need to be signed up for dropbox, a free online storage service that syncs data between all your computers and mobile devices. If you do not have an account, please click here.
This post will help you install the Linux Dropbox client on your headless Ubuntu Server and link it up to your Dropbox account. We will also show you how to setup a watch folder in your dropbox so you can easily add torrents to your seedbox from your home PC without logging in!
Installing Dropbox
Start by logging into your user account via SSH with putty, root is ok as well but this works alot better installed under your root account. Make sure you are in /home/username/ and start off by downloading the Linux version of Dropbox onto your server.
Download the 32Bit Version
Code:
wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"
Download the 64Bit Version
Code:
wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"
If you unsure which version you need you can quickly check by running uname -a.
If the uname output has an i686 at the end you need the 32Bit version and if it hasx86_64 you want the 64Bit version.
When you extract the Dropbox archive it will automatically place its files in the home directory of the the user you’re logged in as under: ~/.dropbox. You can always move these files later but its something to keep in mind.
Extract the Dropbox archive
Code:
tar -xzvf dropbox.tar.gz
Linking Your Server to Your Dropbox Account
Before you take the next step you’ll want to make sure your LANG environment variable is set to a value other than NULL.
Check the value of your LANG environment variable
// outputs en_US.UTF-8 on my machine
To connect the Dropbox client on your server to your Dropbox account you’ll need to copy the link it outputs into a browser window and then login to your Dropbox account.
Run dropboxd on your server
Code:
~/.dropbox-dist/dropboxd
It will start outputting a link similar to this one every few seconds
This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?hos...b087a&cl=en_US to link this machine.
Edit* It's been mentioned that the above link may not work on all machines, apparently it will spit out the link as a en_US link but you may have to change this based on your language selection such as : https://www.dropbox.com/cli_link?hos...3529f&cl=en_GB
Note the en_GB based on alternate english settings.
The trick to a smooth link is to make sure you leave dropboxd running while you follow the link. You don’t need to access the link from the server you’re trying to install Dropbox on. You can copy and paste that link into a browser running on a separate machine and Dropbox will authorize the client running on your server.
Once it succeeds you’ll see the message Client successfully linked, Welcome! on your server and it will stop printing the authorization link.
Hit ctrl c to terminate the process
Client successfully linked, Welcome!
Once the Dropbox client on your server is successfully linked it will automatically create a Dropbox folder under ~/Dropbox for the user you’re logged in as. All your folders will be visible under the Dropbox folder but since the Dropbox service isn’t actually running on your server yet you you won’t be able to see the files inside these folders until the client is running and has a check to synchronize.
You can manually start the service by running
Code:
~/.dropbox-dist/dropbox
However, a better option for controlling the Dropbox client is to setup an Ubuntu service management script for it.
Start Dropbox Automatically On Boot
Dropbox provides a handy little service management script that makes it easy to start, stop and check the status of the Dropbox client.
Create a new file for the service management script
Code:
sudo nano /etc/init.d/dropbox
Paste the following script into the new file
Code:
#!/bin/sh
# dropbox service
# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="user1"
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 sure you replace the value of DROPBOX_USERS with your username on your machine you want to run the Dropbox client to run for.
Make sure the script is executable and add it to default system startup run levels
Code:
sudo chmod +x /etc/init.d/dropbox
sudo update-rc.d dropbox defaults
Control the Dropbox client like any other Ubuntu service
Code:
sudo service dropbox start|stop|reload|force-reload|restart|status
Creating a "watch" folder to dump .torrent files into
In order to create a watch folder, access your dropbox in whatever means you usually do and create a folder called "watch". In reality you can name this anything you want, just remember for later what you have chosen.
In your ssh screen, change into your user directory where your rtorrent installation is.
Once you are in the right directory, open your .rtorrent.rc config file.
Find the line that contains the "schedule =" and replace it to be consistant with the following:
Code:
schedule = watch_directory,5,5,load_start=~/Dropbox/watch/*.torrent
Edit* You can also add a second line this file and have two watch difectories:
Code:
schedule = watch_directory,5,5,load_start=~/Dropbox/watch/*.torrent
schedule = watch_directory_1,5,5,load_start=~/rtorrent_watch/*.torrent
You should now be able to drop files into your watch folder and enjoy easy torrent adding. Please note, all files in your current watch directory will need to be moved in order to show up. Also, upon initial setup, your seedbox will need to sync to your dropbox account. This may take some time depending on the size of your dropbox.