RTorrent

From Segfault
Jump to: navigation, search

Installation

Install prerequisites:

sudo apt-get install g++ libcppunit-dev libsigc++-2.0-dev libcurl4-openssl-dev libssl-dev

Build libtorrent:

git clone git://github.com/rakshasa/libtorrent.git libtorrent-git
cd libtorrent-git
./autogen.sh && ./configure --prefix=/opt/libtorrent --enable-ipv6 --disable-instrumentation[1] && make
sudo make install

Or, if OpenSSL is installed in a different place:

OPENSSL_CFLAGS=-I/opt/openssl/include OPENSSL_LIBS=-L/opt/openssl/lib \
./configure --prefix=/opt/libtorrent --enable-ipv6 && make
sudo make install

Build rtorrent:

git clone git://github.com/rakshasa/rtorrent.git rtorrent-git 
cd rtorrent-git
./autogen.sh
PKG_CONFIG_PATH=/opt/libtorrent/lib/pkgconfig ./configure --prefix=/opt/rtorrent --enable-ipv6 && make
sudo make install

Usage

Note: the ipv4_filter.load statement has to be put at the end of the configuration file. This might a bug.

rTorrent v0.8.9[4] is able to handle Magnet links now. To add a magnet-link, simply paste the link into rtorrent. It will turn the link into a HASH.meta object, which will then download the actual .torrent file and save it into the session directory.

IP Filtering

The IP filtering directives can be used to suppress communication with certain (blocks of) IP addresses. I-Blocklist provides addresslists that can be used with rTorrent:

wget "http://list.iblocklist.com/?list=bt_level2&fileformat=cidr&archiveformat=gz" -O ipfilter_level2.gz
gzip -dc ipfilter_level2.gz | grep ^[0-9] | sort -u > /data/download/session/ipfilter_level2.txt

The blocklist should be in CIDR notation.[5]

RSS

We can use rssdler to periodically download .torrent files and have rTorrent watch a directory where these .torrent files are being downloaded.

sudo apt-get install python-feedparser python-mechanize                     # prerequisites

svn co http://rssdler.googlecode.com/svn/trunk/ rssdler-svn
cd rssdler-svn
python setup.py build
sudo python setup.py install --prefix=/opt/rssdler

To run rssdler, we may have to point to its search path for modules:

export PYTHONPATH=/opt/rssdler/lib/python2.7/site-packages

Or we can edit the rssdler script and add:[6]

sys.path.append('/opt/rssdler/lib/python2.7/site-packages')

A very basic configuration file for rssdler:

$ cat ~/.rssdler.conf
[global]
downloadDir = /data/download/.torrent
workingDir  = /data/download/.rssdler
minSize     = 10
log         = 5
logFile     = downloads.log
verbose     = 3
# runOnce   = false                    # default
# scanMins  = 15                       # default
 
[foo]
link        = http://example.org/foo.rss
maxSize     = 5                        # MB
regExTrue   = .torrent

With runOnce=false, rssdler will check every 15 minutes for if the RSS feed for foo contains new files containing ".torrent" in their filename - and will download them to "downloadDir":

/opt/rssdler/bin/rssdler --config ~/.rssdler.conf --run &

Now rtorrent can be instructed to watch[7] this directory:

$ grep schedule ~/.rtorrent.rc
schedule           = watch_directory,10,10,load_start=/data/download/.torrent

ruTorrent

ruTorrent is a frontend for rtorrent. The following will be an example setup[8] for Nginx. A working PHP installation is needed as well.[9][10]

Add the following to the rtorrent configuration:

scgi_local          = /var/run/rtorrent/scgi.socket
execute             = chmod,0660,/var/run/rtorrent/scgi.socket
# execute           = chgrp,www-data,/var/run/rtorrent/scgi.socket

Note: the chgrp won't work because mere users are not allowed to change (group) ownerships. So let's set the sticky bit on the socket directory instead:

mkdir -m 2770 /var/run/rtorrent
chown rtorrent:www-data /var/run/rtorrent

Add the following to the nginx configuration:

# ruTorrent
location /rutorrent {
         allow             10.2.0.0/24;
         deny              all;
}

location /RPC2 {
        include            scgi_params;
        scgi_pass          unix:/var/run/rtorrent/scgi.socket;
        allow              127.0.0.1;
        deny               all;
}

Now we can install ruTorrent in Nginx's document root:

git clone https://github.com/Novik/ruTorrent.git ruTorrent-git
cd ruTorrent-git
DOCROOT=/var/www/
git archive --format=tar --prefix=rutorrent/ HEAD | tar -C $DOCROOT -xf -

Both the webserver and the rtorrent user need write access to rutorrent/share:

mkdir $DOCROOT/rutorrent/share/tmp
chmod -R g+w $DOCROOT/rutorrent/share/
sudo chown -R www-data:rtorrent $DOCROOT/rutorrent/share

Configuration is done in rutorrent/conf/config.php, only a few adjustments must be made:

$log_file      = '/var/www/rutorrent/share/tmp/errors.log';
$scgi_port     = 0;
$scgi_host     = "/var/run/rtorrent/scgi.socket";
$profileMask   = 0775;
$tempDirectory = '/var/www/rutorrent/share/tmp/';

With all this in place, rutorrent should be good to go!

Links

References