Torrent management: Set up rtorrent

From Bitpost wiki
Revision as of 21:15, 2 April 2009 by M (talk | contribs)

rtorrent will do most of our work. It takes a bit of configuring to get it just the way you want, but with a little effort it will tackle our toughest tasks.

First, install it. It should be available as a package on most modern linux distributions, but you'll need version 0.8.4, so download and install manually if needed.

Next, configure it. As of this writing, rtorrent does amazing things, but the documentation just isn't there yet, so it's tricky to get it just right. Here are the important parts of the configuration.

# rtorrent seems really greedy without a socket limit, and 200 seems to meet all needs...
max_open_sockets = 200

# require encryption, seems generally available these days...
encryption = require,allow_incoming,require_RC4
# or fall back to making encryption optional - only if you find the need...
# encryption = allow_incoming,try_outgoing,enable_retry

# starting defaults, adjust according to your available bandwidth
upload_rate = 50
download_rate = 1000

directory = ~/download/torrents

# a session directory for current status is essential to allow sane rtorrent restarts
session = ~/download/torrents/rtorrent/session

# watch directory
schedule = watch_directory,5,5,load_start=~/download/torrents*.torrent

# remove torrents if moved, restart torrents if moved back
# important to note that we REMOVE (not stop or close) torrents
# otherwise, they persist in rtorrent memory and we can't readd them to our 2nd watch directory
schedule = tied_directory,5,5,start_tied=
schedule = untied_directory,5,5,remove_untied=

# a second watch directory for freshly-archived torrents
schedule = watch_directory_2,5,5,"load_start=~/download/torrents/archived/*.torrent,d.set_directory=~/download/torrents/archived/symlinks/"

# tricky v0.8.4 configuration to move torrents when finished
system.method.set_key = event.download.finished,check_custom1,"branch=d.get_custom1=,d.set_custom2=$d.get_custom1=,d.set_custom2=~/download/torrents/finished/"
system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_custom2= ;execute=mv,-u,$d.get_base_path=,$d.get_custom2="

# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=100M

Next, simply run rtorrent in a screen session. If you don't know what screen is, go research it right now. Trust me. You want to...

screen -S mytorrents rtorrent

rtorrent will now watch for .torrent files in the watch directories.

Set up firefox to drop .torrent files into [~/download/torrents], and start clicking away!

rtorrent is gonna run rock-solid for a LONG time, so I don't even bother with an automatic startup script (left as an exercise for the reader).