Orangeek, the original hand-drawn mascot

orangeek's blog

bittorrent automation with Linux and rtorrent

0 Comments

Since I download regularly legit files via torrent, and I don't own an Android phone ;), I created a setup that makes life really simplier.

At home I've a 24/7 server (a fanless epia me6000 with debian) that shares part of its filesystem via NFS and samba. After downloading the .torrent file, I simply put it in a shared directory (say, /data/download on the server's filesystem). The server is configured to check every N seconds to look for .torrent files in that directory and, eventually, start the download. After the download is finished, the torrent client moves the files in a specified directory, always shared trough the network via NFS or samba.

I'll describe below the steps needed for a such setup.

So, I just wrote I use Debian Linux as the OS and rtorrent as the torrent client, which I really love: it's super fast (I tried it even on a wireless router with debian installed!), super light and rich of features.

In order to automate your bittorrent client as I did, you just need to modify two files: the .rtorrent.rc in your home directory and a startup file in /etc/init.d/ (or whatever file your distro loads at startup).

rtorrent configuration

Modify your .rtorrent.rc file in your home directory and set the proper parameters. Below are mines.

#directory where to put the downloaded files
directory = /data/download/
#insert below the directory where rtorrent should look for new .torrent files
schedule = watch_directory,5,5,load_start=/data/download/*.torrent
# when finished, rtorrent will untie the .torrent file ...
schedule = untied_directory,5,5,stop_untied=
#...and move the downloaded files into another directory ! keep it shared trough the network if you want to make life easy !! :)
on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/data/download/fatti/ ;d.set_directory=/data/download/fatti/"

Start at boot rtorrent in a 'screen' session

I'll not get into the 'screen' program: if you want to automate your torrent activity on a centralized server, I'm quite sure you already have heard of it. On my debian system, I created an /etc/init.d/ file, called 'rtorrent_start', used to start at every boot a 'screen' session with rtorrent, ready to load every torrent files in your 'watched directory' (see above). Here the content of the file.

#!/bin/bash
echo 'starting rtorrent on screen'
su -c 'screen -d -m rtorrent /data/download/*.torrent' orangeek &

 And... voilà! :)

I'm already planning to add some useful tools in this process: since I can't access via ssh my machine when at work, I want to install an IM app on the server (say, pidgin), choose some random username and configure the client to auto-accept incoming files. The client could save the .torrent file in the 'watched directory' and so I don't have to wait til I'm home to put things in download... Finally, you can use a web interface for rtorrent but you'll have to use a development version of the client since, afaik, the one provided via apt for debian doesn't support this feature yet (same for the RSS download capability which, combined with TVrss.net, is a killer app!)

Written by orangeek

Friday 13 March 2009 at 12:20 PM

Posted in tech

automation, bittorrent, linux, rtorrent, torrent

0 Comments

    Comments are closed.