Gentoo Wiki ArchivesGentoo Wiki

Rtorrent

Contents

About

Rtorrent since svn revision 908 supports xmlrpc interface, but you need to put some efford to get it working with LightTPD.

Install

First of all install the xmlrpc-c, and make sure curl and libwww flags are set, so that we get command line client.

echo "dev-libs/xmlrpc-c curl" >> /etc/portage/package.use
emerge xmlrpc-c

In lighttpd scgi support comes for free, but bear in mind that flag minimal turns it off. The "php" USE FLAG needs to be enabled to not get the error "403 forbidden" for any .php page.

echo "www-servers/lighttpd php -minimal" >> /etc/portage/package.use
emerge -uN lighttpd

Then while building rtorrent, configure it with xlmrpc-c support:

echo "net-p2p/rtorrent xmlrpc" >> /etc/portage/package.use
emerge rtorrent

Configure

LightTPD

We need to turn on the module responsible for scgi support. Surprisingly the module is called mod_scgi, and we add it to the server configuration:

File: /etc/lighttpd/lighttpd.conf
# NOTE: the order of modules is important.
server.modules = (
#
# Here goes a lot of other modules you might be using on your server.
#
  "mod_access",
  "mod_scgi",
  "mod_accesslog" # Leave this one last as you may need some logging.
)

Then, at the end of that file, we add lines responsible for rtorrent interactions:

File: /etc/lighttpd/lighttpd.conf continued
scgi.server = (
  "/RPC2" =>
            ( "127.0.0.1" => 
              (
              "host" => "127.0.0.1",
              "port" => 5000,
              "check-local" => "disable",
              )
            )
)

If we set everything correctly, lighttpd should start after this command: /etc/init.d/lighttpd start

rtorrent

All we have to do for rtorrent is adding this line to ~/.rtorrent.rc, keeping the same port number as above:

File: ~/.rtorrent.rc
# ...
scgi_port = localhost:5000

We set localhost as we don't want anyone else to be able to talk to rtorrent. Rakshasa's rationale: `(Setting anything else) is however not recommend as rtorrent has no access control, which means the http server is responsible for handling that. Anyone who can send rtorrent xmlrpc commands is likely to have the ability to execute code with the privileges of the user running rtorrent.'

Here is a runscript for rtorrent to start it as a daemon. We first need to install dtach to redirect the interface output via "emerge dtach".

Runscript:

File: /etc/init.d/rtorrentd
#!/sbin/runscript

depend() {
        use net.*
}

start() {
        ebegin "Starting rtorrent"
        start-stop-daemon --start --chuid $USER \
            --env TERM="xterm" \
            --env HOME="/home/$USER" \
            --exec /usr/bin/dtach -- -n $SOCKET /usr/bin/rtorrent
        eend $?
}

stop() {
        ebegin "Stopping rtorrent"
        start-stop-daemon --stop --signal 2 --name rtorrent
        eend $?
}

And the file for configuration. You could use "root" here or create a user like "useradd -m -G users wtorrent" and put the .rtorrent.rc into the homefolder e.g. /home/wtorrent:

File: /etc/conf.d/rtorrentd
USER="wtorrent"
SOCKET="/tmp/rtorrent.dtach"

If you want to use screen, edit the start() script as following:

File: /etc/init.d/rtorrentd
start() {
        ebegin "Starting rtorrent"
        start-stop-daemon --start --chuid $USER \
            --env TERM="xterm" \
            --env HOME="/home/$USER" \
            --background \
            --exec /usr/bin/screen -- -D -m /usr/bin/rtorrent
        eend $?
}

Then you can login as wtorrent and type the command to attach to it.

screen -r

See also

The article is based on Rakshasa's libtorrent-devel mailing-list post, where examples of use and more information can be found:

(litorrent-devel) A quick guide to rtorrent's xmlrpc that assumes you read the peripheral manuals

Runscript found at http://sb0y.blog.ru/6860147.html

Retrieved from "http://www.gentoo-wiki.info/Rtorrent"

Last modified: Thu, 04 Sep 2008 11:16:00 +1000 Hits: 15,133

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.