Installing rTorrent and hellanzb on CentOS5 64-bit VPS

Overview

The aim of this guide is to walk through the process of getting rTorrent and hellanzb working on a VPS running CentOS5 (64-bit version).1

In the interests of the author’s sanity, It is assumed that the reader has some familiarity with Unix command-line operations, and that the reader knows what the various permissions octals mean in Unix.

Please read the TODO to see what still needs fixing.

Assumptions

  • Operating System is CentOS5 64-bit, kernel 2.6.1x series 1)
  • CentOS5 is running on a OpenVZ VPS.
  • gcc, make, automake and autoconf installed
  • A text editor you are comfortable with (nano2 is recommended) but you can always use vi if you are hardcore
  • Working FTP Server (ProFTPD is highly recommended)
  • Installing software while logged in as root does not strike you as heresy.
  • Patience – lots of it.

Installing rTorrent

The Easy Way

rTorrent’s dependency tree is fairly long and very specific on the minimum versions required. The core dependency list is as follows:

  • pkg-config
  • libsigc++
  • curl 7.19.2 or higher
  • xmlrpc-c

Reminder: The rest of this section assumes you will be executing the commands as root

pkg-config

The current version of pkg-config (at the time of writing this guide) is 0.23. You can check the version information on the pkg-config website while the actual source tarballs are in the release directory.

The following set of commands will install pkg-config:

libsigc++

Make sure you have rpmforge in your list of repositories. See this section for instructions if you are not sure how to proceed. If you have rpmforge already installed, you need to execute the following command:
yum install libsigc++20 libsigc++20-devel
Now to check if everything went ok with the libsigc++ install. Open the file ld.so.conf
nano -w /etc/ld.so.conf
and add the following lines:

Save and exit. Now run the following commands:

If everything went well, you should see something similar to the output below:

curl

Older versions of curl have bugs with some advanced features that libtorrent uses3 . Hence, rtorrent requires curl 7.19.2 or higher to be installed. However, CentOS 5 only ships with 7.15.5 and there are no updates available on the standard repositories.The current version of curl (at the time of writing this guide) is 7.19.3. You can check the version information on the curl website while the actual source tarballs are available on the download page.

Installing curl is fairly standard:

The curl make process can take a very long time, so this might be a good time to go get yourself a sandwich. Once the install process finishes, we need to check if the libraries are visible to pkg-config:

Now we move to the most important dependency for rtorrent, XMLRPC-C.

XMLRPC-C

XMLRPC-C comes in 3 flavours: Super-Stable, Stable and Advanced. While the Super-Stable version is available as a regular tarball, it seems like getting that version to work reliably is a hit-and-miss affair4. We are instead going to build the Advanced version for use with rtorrent.

To get the Advanced version source files, we need to install the subversion client:

Next, we need to install a missing dependency for XMLRPC-C5:

Now, we start the XMLRPC-C build process:

The following command must execute without any errors:

Any errors at this stage means the rtorrent install will fail. Double-check that you have executed all the commands listed above starting from the section on installing curl.

Now that we have all the dependencies for rtorrent in place, it’s time to get started with installing rtorrent.

libtorrent/rTorrent

The latest build of rTorrent has a lot of functionality for managing torrents automatically. Plus, wTorrent relies on the latest build of rTorrent for much of it’s functionality.

Start by checking out the latest rTorrent build from the repository:

Run the following commands to install libtorrent:

Check if the libtorrent install took:

You should see the following output after the pkg-config command listed above:
[root@centos]# pkg-config --cflags --libs libtorrent
-I/usr/local/include -L/usr/local/lib -ltorrent

If everything is in order, it's time to start the rTorrent install:

If everything executes without errors, congratulations! You have a working rTorrent install ready for use. Before you can start using rTorrent though, you need to setup the rTorrent configuration file.

Creating a basic .rtorrent.rc file

rTorrent looks a file called ”.rtorrent.rc” in the home directory of the user launching rTorrent. A sample .rtorrent.rc file is included below. A few things to note about this sample file:

  • Download/Upload speeds are set to unlimited (You may want to limit this to around 60-70% of your total VPS link speed)
  • Downloads are saved in ~/downloads
  • Make sure to point the session variable to a directory that exists.
  • rTorrent listens for XMLRPC connection on localhost, port 5000

Working with rTorrent

Launch rTorrent by running the following command:

You should find yourself looking a fairly spartan window:

rtorrent-main

Let's start by loading a new torrent meta-file. Torrent meta-files can be loaded into rTorrent using the Backspace key. Auto-completion of directories using the Tab key and wildcards (example: *.torrent) is supported.

Once you have a torrent loaded, you can use the following list of commands to manage rTorrent:

CommandDescription
Ctrl+SStart download. Runs hash first unless already done.
Ctrl+DStop an active download, or remove a stopped download.
Ctrl+QInitiate shutdown
↑/ ↓Select item
Go back to the previous screen.
Switch to Download View.
LView log. Exit by pressing Space.

There is one problem with launching rTorrent from a regular shell window. Once you type in Ctrl+Q to exit from rTorrent, it shuts down completely, stopping all your in-progress torrents. The next section will deal with how to keep rTorrent running in the background as well as how to launch rTorrent on startup.

Running rTorrent as a Service

We will be using dtach to keep rTorrent running in the background6. To install dtach, execute the following command:

Now you can launch rtorrent using dtach:

Once rTorrent launches, press Ctrl+\. You will get the following message at the shell:

You can verify that rTorrent is still running by running the following command:

To reconnect the rTorrent session in the background, type

In order to launch rTorrent at startup, we need to create an entry in the init.d folder as well as a configuration file that the init.d script can read.

These commands need to be executed while logged in as root

The configuration file can be created as follows:

Now copy and paste the following text into your rtorrent.init.conf file:

Now we need to make the rtorrent file executable:

Next we add rTorrent to the list of startup services:

Now you can start rTorrent using the following command:

If there are no problems with your configuration file, you should see the following:

Verify that rTorrent is running with the following command:

You should see the following:

Caveats

Unfortunately, launching rTorrent as a starup service this way comes with some limitations:

  • The startup script launches rTorrent through a couple of layers of redirection. This means that sometimes, rTorrent can fail to start but the startup script still says “Starting rtorrent via dtach: rtorrent [ OK ]”
  • Another problem is that if rTorrent finds any problems in the .rtorrent.rc file, it does not send the message to stderr but rather to stdout (i.e. on-screen)
  • So if you make a change to your .rtorrent.rc file you might want to check for any problems by launching rTorrent the usual way, i.e.,
    /usr/local/bin/rtorrent

    Installing hellanzb

    In case you are wondering what hellanzb is, it “is a Python application designed for *nix environments that retrieves nzb files and fully processes them. The goal being to make getting files from Usenet as hands-free as possible.”

    hellanzb's dependency list is deceptively simple:

    • Twisted
    • unrar/unzip
    • par2cmdline
    • pyOpenSSL (if you want to use SSL connections to your Usenet provider)

    The reality of course is a bit more complicated. Let's get started with Twisted.

    hellanzb dependencies

    hellanzb's core dependency is Twisted - a networking stack written in Python. Twisted in turn, relies on zope.interface and python headers. Let's start with the core python headers install:

    While zope.interface is available as a simple tarball, I never managed to get the build to work. The only thing that did work was a default file that I located on a 3rd-party repository7 :

    Now we can get started with Twisted. The current version of Twisted (at the time of writing this article) is 8.2.0 . You can find the latest version info on the Twisted website, and a link to the source tarball is available on the home page as well. Installation is as follows:

    The odd install path for Twisted is due to a bug in the way Python packages get installed on 64-bit OS'es. See this bug report.

    The next set of dependencies for hellanzb are for unrar/unzip. If you have been using the instructions listed in this article on how to install rTorrent, you should have the rpmforge repository installed. The only thing left to do is to execute the following command:

    Now we move par2cmdline. In case you are wondering what this program does, you should read this article on PAR files. The latest version of the par2cmdline client for UNIX (at the time of writing this article) is 0.3. You can download the source tarball from the clients section of the parchive website.

    Unfortunately, a bug in gcc 4.x.x prevents par2cmdline from compiling properly unless a patch is applied8 . The complete process for building par2cmdline goes like this:

    Optional:Finally, we install PyOpenSSL:

    Building hellanzb

    At the time of writing this article, the latest version of hellanzb was 0.13. You can check the version info on hellanzb's website while the actual source tarballs are available in the distfiles folder. You could be adventurous and try the nightly builds in the distfiles folder, but the stable version works well enough.

    If everything went well, you have a working hellanzb install. Now it's time to configure hellanzb.

    Creating a hellanzb.conf file

    hellanzb looks for a configuration file called “hellanzb.conf” in the /usr/etc folder. A sample hellanzb.conf file is given below. You should note the following about this sample conf file:

    • Download speeds are set to 150kB/s (You may want to limit this to around 30% of your total VPS link speed)9
    • Finished Downloads are saved in /home/nzb/downloads/completed_files
    • hellanzb listens for XMLRPC connection on localhost, port 8760

    Working with hellanzb

    It might not seem possible, but hellanzb boasts an interface even more spartan than rTorrent. hellanzb can be launched with the following command:
    /usr/bin/hellanzb.py
    Once hellanzb starts, you will see the following in your SSH session:

    hellanzb-main

    In order to have hellanzb process nzb files, you need to place them in the “Hellanzb.QUEUE_DIR” folder10 .

    Unlike rTorrent, hellanzb ships with a “daemon” mode built-in, so you can start it as a service very easily by issuing the following command:

    In order to see what hellanzb is currently doing, you can use the following command:

    Let's now see how to add hellanzb to the list of services on startup.

    Running hellanzb as a Service

    In order to launch hellanzb at startup, we use a process identical to the one used for rTorrent. First, we create an entry in the init.d folder and then add a configuration file that the init.d script can read.

    These commands need to be executed while logged in as root

    The configuration file can be created as follows:

    Now copy and paste the following text into your hellanzb.init.conf file:

    Now we need to make the hellanzb file executable:

    If you would like to skip copying and pasting text into your shell session, you can run the following commands instead:

    Next we add hellanzb to the list of startup services:

    Now you can start hellanzb using the following command:

    If there are no problems with your configuration file, you should see the following:

    Verify that hellanzb is running with the following command:

    You should see the following:

    Other Tips

    Download files via FTP reliably

    If you are using ProFTPD as your FTP server, you want to add the following line to your proftpd.conf file: (usually located in /etc)

    This is recommended as there are some issues with VPS kernels that can cause timeouts on large transfers - See this article

    Fixing the sudo error

    By now you would be familiar with this annoying problem every time you issue the sudo command:

    This is actually due to a bug in the version of sudo that ships with Red Hat. You can check out this blog post for instructions on how to upgrade your version of sudo which will fix this annoying error message.

    SAFE USAGE

    Copyright laws and laws pertaining to patents and inventions protect original works of authorship and inventions. Individuals who reproduce, distribute copies, receive copies, publicly perform or display works or inventions other than their own and without the consent of the owners or holders of rights, or their authorized agents, in original works of authorship or inventions, may be in violation of copyright, patent or other intellectual property infringement. The authors and contributors of this article do not encourage or condone the illegal copying of copyrighted material. This is not intended to be legal counsel or advice. If you have any questions, consult your attorney.11

    TODO

    1. Fix the inevitable spelling errors/bugs in this article?

  1. I’m guessing the guide will still work for higher kernel versions in the 2.6 series, but experience has taught me to hedge my bets 

  2. nano is not installed by default 

  3. http://libtorrent.rakshasa.no/wiki/LibTorrentKnownIssues#Inabilitytoconnecttotrackersorannouncestimeout  

  4. http://libtorrent.rakshasa.no/ticket/1028 

  5. http://fr.rpmfind.net/linux/RPM/fedora/updates/testing/7/i386/xmlrpc-c-1.06.25-1.fc7.i386.html 

  6. The other option is screen, which is a better screen-multiplexer program but requires a lot more privileges to run 

  7. http://rpm.pbone.net/index.php3/stat/4/idpl/10370620/com/python-ZopeInterface-3.3.0-1.el5.pp.x86_64.rpm.html 

  8. http://slackbuilds.org/repository/12.2/system/par2cmdline/ 

  9. hellanzb 0.13 has a problem with speed limits due to a bug in the underlying twisted network stack 

  10. That would be /home/nzb/usenet/nzb/daemon.queue/ if you used the sample hellanzb.conf from this wiki 

  11. Taken directly from the hellanzb README at http://www.hellanzb.com/trac/hellanzb/browser/trunk/README