I figured I'd try to write a brief how to on getting the rtorrent/ntorrent working together since I've went through it recently in desperation (my Transmission is acting up and downloading really slow, with only half a dozen peers per torrent and no obvious problems to fix).

This is meant for those who wish to run an alternative BT (rtorrent) and do not mind using a client side interface (ntorrent) on their desktop to manage their torrents.

ntorrent is a Java based application and will work on any platform supporting Java >= 1.6. Go to its page and download the binary package to your desktop, it's in the featured downloads (bz2 file and any language addition you need).

Anyways, this might not be exactly step-by-step since I'm recollecting my journey and I might miss a step so please pitch in with your comments.

Oh, if you mess up your router I am not responsible - you have been warned!

I will assume that everyone has a similar setup, WL500gP, /opt and oleg's firmware/feeds.

First of all make sure you got everything up to date:

ipkg update
ipkg upgrade
Then we need to grab rtorrent, it will also install libtorrent and bunch of other things (xmlrpc etc) but no worries you need those as well

ipkg install rtorrent
We'll need to run apache or lighttpd to have scgi, so let's install the later:

ipkg install lighttpd
Also, we need screen:

ipkg install screen
...and bash

ipkg install bash
Now we are ready to do some configurating, first lighttpd, the config file for it is in /opt/etc/lighttpd/lighttpd.conf so edit it:

vi /opt/etc/lighttpd/lighttpd.conf
I have kept most things default, you may change the port from default 8081 to something else if you like.
I didn't, what I added was mod_scgi in the server.modules list (I added around the end, you can add anywhere as long as it's not commented):

#                               "mod_rrdtool",
                                "mod_accesslog" )
At the very end of the file I've added the following:

scgi.server = (                                                            
        "/RPC2" =>                                                         
                ( "" =>                                             
                                "socket" => "/opt/var/run/rpc.socket",       
                                "check-local" => "disable",                  
                                "disable-time" => 0,  # don't disable scgi if connection fails
This will enable passing the socket connection from rtorrent via lighttpd to our remote ntorrent client via http:// protocol.

Save and exit the file.

Let's make rtorrent config file next, I will use a non default location for it (it usually sits in your home dir as .rtorrent.rc but I want it on my mounted drive):

vi /opt/etc/rtorrent.conf
And these are some of the settings, you can adjust more settings by reading the rtorrent manpage

scgi_local = /opt/var/run/rpc.socket
session = /opt/share/torrent/work
port_range = 10000-11000
directory = /opt/share/torrent/dl
check_hash = yes
encryption = prefer_plaintext
stop_on_ratio = 100
upload_rate = 50
max_uploads = 5
I have used ports 10000-11000 for it, but you can use any port range you like. Remember that you will have to open these ports in your firewall, so...

vi /usr/local/sbin/post-firewall
This is what you should have, at least:


## set default policy
iptables -P INPUT DROP
## deny ftp access from WAN
iptables -I INPUT 1 -p tcp -i "$1" --syn --dport 21 -j DROP
## Allow access to various router services from WAN
## open 10000-11000 for rtorrent
for P in 10000:11000; do
  iptables -I INPUT 1 -p tcp --syn -i "$1" --dport $P -j ACCEPT
You might wanna change your pre-shutdown as well, I used the one wirespot posted (thanks!).

vi /usr/local/sbin/pre-shutdown
...and add the following:

# This one is simple. I send signal INT to rtorrent
# to tell it to do a graceful shutdown that will make
# it save its hashes and full status. (You need to
# enable sessions with session=dir in rtorrent.rc
# for this to work!):
/bin/kill -INT $(/bin/pidof rtorrent) &
# Then I wait for 10 seconds to be sure it died
# gracefully. The rtorrent docs say it dies in 5,
# I just wanna make extra sure.
/bin/sleep 10
Since we made the change to flashfs this needs to "stick" after reboot so:

flashfs save && flashfs commit