Deluge bittorrent client

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install deluged deluge-console deluge-web

deluged

sudo pkill deluged

cp ~/.config/deluge/auth ~/.config/deluge/auth.old

nano ~/.config/deluge/auth

Once inside nano, you’ll need to add a line to the bottom of the configuration file with the following convention:

user:password:level

for example pi:password:10

Where in user is the username you want for Deluge, password is the password you want, and the level is 10 (the full-access/administrative level for the daemon). For our purposes, we used pi:raspberry:10.When you’re done editing, hit CTRL+X and save your changes. Once you’ve saved them, start up the daemon again and then the console:

deluged

deluge-console

If starting the console gives you an error code instead of nice cleanly formatted console interface type “exit” and then make sure you’ve started up the daemon.

Once you’re inside the console, we need to make a quick configuration change. Enter the following:

config -s allow_remote True

config allow_remote

exit

This enables remote connections to your Deluge daemon and double checks that the config variable has been set. Now it’s time to kill the daemon and restart it one more time so that the config changes take effect:

sudo pkill deluged

deluged

At this point your deluge daemon is ready for remote access. We need to install the Deluge desktop client in order to finish the configuration. Hit up the Deluge Downloads page and select the installer for your operating system. Once you have installed the Deluge desktop client, run it for the first time; we need to make some quick changes.

Once launched, navigate to Preferences -> Interface. Within the interface submenu, you’ll see a check box for “Classic Mode”. By default it is checked. Uncheck it.

Click OK and then restart the Deluge desktop client. This time when Deluge starts, it will present you with the Connection Manager. Here is where you input the information about your Raspberry Pi and the Deluge installation. Click the Add button in the Connection Manger and plug in your Pi’s info like so:

You’ll need to input the IP address of the Raspberry Pi on your network, as well as the username and password you set during the earlier configuration. Leave the port at the default 58846. Click Add.

Back in the Connection Manager, you’ll see the entry for the Raspberry Pi; (in my case PI and my pwd) if all goes well, the indicator light will turn green.

Click Connect and you’ll be kicked into the interface, connected to the remote machine:

It’s a fresh install, nary a .torrent in site, but our connection between the remote machine and the desktop client is a success!

Our next step is to configure Deluge to use our external hard drive. By following along with the hard drive mounting instructions in How to Turn a Raspberry Pi into a Low-Power Network Storage Device, you’re ready with a hard drive set to auto-mount on boot.

Now all we need to do is change the default locations in Deluge. Navigate to Preferences -> Downloads. By default Deluge directs everything to /home/pi. That little SD card is going to fill up real fast, however, so we need to change it.

First, we’re going to create some new folders in /media/pi/usbdrive/

This way we can easily access our downloaded torrents over the network and have a network accessible watch folder for auto-loading torrent files. Use the following commands to create the folder set

sudo mkdir /media/pi/usbdrive/downloads

sudo mkdir /media/pi/usbdrive/completed

sudo mkdir /media/pi/usbdrive/watch

sudo mkdir /media/pi/usbdrive/torrent-backups

Now we’re going to turn right around and plug these four new directories into Deluge:

Now we want deluge to autostart op the PI

remove the init.scripts:

sudo update-rc.d deluge-daemon remove

edit the rc.local to add a line in order to start deluged with user "pi":

sudo nano /etc/rc.local

and enter this in the file:

#!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.

# Print the IP address

#_IP=$(hostname -I) || true

#if [ "$_IP" ]; then

#printf "My IP address is %s\n" "$_IP"

#fi

#

# torrent client start:

sudo -u pi /usr/bin/python /usr/bin/deluged

exit 0

reboot the raspberry and look if you can login from tour deluge thin client.

Now it is interesting to manage the torrents from your Android.

Install the app Transdroid from Google play.

setup Transdrone:

The next step is very important if you want to use Transdrone to control Deluge from anywhere you go and not just your home Wi-Fi network. You will need to open up the port 8112 and redirect this to your home computer. First get your Ubuntu computer’s IP address. Right-click on the connections icons in the top panel; this is the NetworkManager Applet. If choose ‘Connection Information’ it will give you some statistics about your current computer’s network connection. You need the number that says ‘IP Address’. Note it down or remember it: this is your computer local IP address.

Now go to your the manager interface of your router or ADSL modem. It will most likely have a NAT tab or settings screen. Here you will need to set up a port forward from all external traffic on port number 8112 to you local computers’ IP address – the one that you just retrieved from the Ubuntu connection manager – on the same port. There are too many routers and ADSL modems to make detailed explanations here, but you can use the website PortForward for in-depth help.

Setting up Transdrone

The final step is to set up Transdrone. Install the software from Google Play and open up the application. You will see a message that you need to set up a server configuration first. Hit your Android device’s menu button and choose ‘Settings’. Next, click the ‘Add a sever’ button to create your first sever configuration. You can add more later, if you need to.

Now fill in all the settings. The name is totally up to you. From the type menu you choose for Deluge 1.2+ of course.

The IP address is your server’s external IP address. If you do not know this, open up a browser on your Ubuntu machine and surf to whatismyip.com. It will present you the external IP address that you need in Transdroid.

You may skip the external acces and use your internal IP adress if you only want to control Deluge from within your own network at home (or can VPN directly into your own home network).

The port number is the next setting and is 8112. (Except for when you manually changed it, of course.)

Choose to enable authentication and fill in the web UI password, which is ‘deluge’ by default. Note that there is no username.

Time to test your settings!

First disconnect from the Wi-Fi network if you are connected to the local network and want to test from outside your home network. (the one where your Ubuntu machine is in as well). This is important, because you will need to use different settings for that. Don't disconnect if you only want to control deluge from home.

Now, hit the back button of your Android device twice to return to the main screen. It should now state that it is connecting to the sever. After a couple of seconds you should get a listing of all the active torrents in Deluge. Rewards yourself by downloading some torrents, right from your phone.

:)

Be aware that the deluge-web deamon has to made to start automatically too. That works like this:

1.Create an empty file with extension .sh and name it whatever you want. For example:

leafpad autostartdelugeweb.sh

2.Copy and Paste the following EXACTLY to the script name that you just created.

 #! /bin/sh   ### BEGIN INIT INFO  # Provides:          noip  # Required-Start:    $remote_fs $syslog  # Required-Stop:     $remote_fs $syslog  # Default-Start:     2 3 4 5  # Default-Stop:      0 1 6  # Short-Description: Simple script to start a program at boot  ### END INIT INFO   #change /direct/path/to/your/application to the path your application is in.  cd /usr/bin      # example cd /home/pi/myprogram/   #change YourProgramExactName to Exact name of your program that you want to auto start  ./deluge-web   exit 0 
    1. Then, save the script file within your home folder
    2. Then, open /home/pi/.config/autostart folder. It might be different in your case. Just open your home folder and enable view hidden folders. open .config/autostart. If you don't see autostart folder, then create a folder called autostart within .config folder.
    3. within autostart folder you will need to create a shortcut to your script file that you created as follows. Create an empty file with extension .desktop.
    4. Copy and paste the following in the empty desktop file except you will need to change Comment, Name, Exec, Path and Icon field's value to yours.
      1. [Desktop Entry] Comment= Exec=/home/pi/autostartdelugeweb.sh Icon=/home/pi/autostartdelugeweb.sh Name=autostartdelugeweg.sh Path=/home/pi Type=Application
    5. Save and close the file after changing all the necessary fields. You are done. Just test it out.

Now the deluge-web deamon should start at boot.

Now edit the /home/pi/.config/deluge/web.conf file by doing

leafpad /home/pi/.config/deluge/web.conf

and enter in the line default deamon this number between the " "

127.0.0.1:58846

This makes deluge-web auto connecting the web server, so that Transdroid can do that too.

Local Wi-Fi network access

One thing you should know when you have a Wi-Fi network at home, is that you cannot use your external IP address as described above while you are connected this way. When connected to the wireless network that your Ubuntu machine is in, you will need to use your machine’s internal IP address instead.

Easiest thing to do is to open Transdrones settings menu again and add a new sever configuration. Use the exact same details that you used before, but now use your Ubuntu machine’s local IP address. Of course you also want to give it a name that identifies it as being your local configuration.

Give it a test by going to the main screen and choose ‘servers‘ from the menu. You can select the other configuration from the pop-up menu. A little tip: switching servers can also be done by swiping your finger from left to right (or the other way around). No need to open the menu each time!

Troubleshooting

If Transdrone refuses to connect you, use these steps to trace the problem.

First try to connect to the web UI directly from your Raspberry PI machine. Start a browser and surf to http://127.0.0.1:8112/. If you can a page not found error, deluge-web is not running or you set up the web UI to run on a different port number.. if it does, try to connect from your Ubuntu machine, using the IP adress from your Pi. e.g. http://192.168.2.20:8112

If you are presented a login screen but are refused access, please check your password, maybe re-enter them. As long as you cannot even access the web UI, Transdrone will not work as well.

If you do not see any running deamons in the connection manager, then deluge is not running. Start it and reload the web UI. You should always first connect the web UI to the running daemon before using Transdrone.

If this direct connection works, check if you can connect using Transdrone while connected on your internal Wi-Fi network. Remember to use you internal IP address now. If this works but external connections via 3G/EDGE don’t, you have not set up the port forwarding correctly.

Still having troubles? Use the ‘error report’ feature in Transdrones menu to get personal help.