RTorrent ruTorrent HowTo

From SynologyWiki
Jump to: navigation, search

This is a tutorial that explains how to install the bittorrent client rtorrent and a webinterface for rtorrent, rutorrent, on your synology NAS device. Instructions are for firmware DSM 2.3-1139 or above.

This guide isn't directed at total beginners. Some linux and bittorrent knowledge is needed.

Contents

Getting ready

  • Make sure you backup your data.
  • read the tips
  • enable SSH access (tip #3)

Installing

Bootstrap

You need ipkg working for the things described below to work. For this install bootstrap by following installation instructions.

xmlrpc-c

Although Synology firmware has build in xmlrpc-c - 1.11.00-3 it does not work with rtorrent. Therefore we need to get it from SVN and compile it.

Remove current version (if installed)

ipkg remove xmlrpc-c

install packages for compiling xmlrpc-c

ipkg install gcc svn optware-devel libcurl-dev

get xmlrpc-c from SVN repository and compile it

svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
cd xmlrpc-c
C_INCLUDE_PATH=/opt/include ./configure --prefix=/opt
make
make install

if the current version of xmlrpc-c fails to compile, check out release 1.16.27 (corresponds to revision 1908)

svn checkout -r 1908 http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
cd xmlrpc-c
C_INCLUDE_PATH=/opt/include ./configure --prefix=/opt
make
make install

if you're getting an error regarding the missing header file 'syslimits.h', just create an empty file (adjust path accordingly):

touch /volume1/@optware/bin/../lib/gcc/powerpc-linux-gnuspe/3.4.6/include/syslimits.h

if you're getting an error about the missing header file 'curl/types.h' at compiling, just remove the correspondent includes from lib/curl_transport/xmlrpc_curl_transport.c, lib/curl_transport/curltransaction.c and lib/curl_transport/curlmulti.c

rTorrent

install

installing rtorrent and dependencies

ipkg install rtorrent screen

Create session directory:

mkdir -p /opt/share/torrent/session/

Create logs directory:

mkdir /opt/var/log/

rtorrent.conf

edit rtorrent config file in /opt/etc/rtorrent.conf and change settings as you want them to be. Add SCGI socket to localhost ip and 5050 port at the end of config file:

scgi_port = 127.0.0.1:5050

S99rtorrent

Edit rtorrent startup file /opt/etc/init.d/S99rtorrent

uncomment and change to custom directory layout (at the top of the file):

dirlayout=CUSTOM

Modify checkcnfg() function. Comment out (with "#") as following:

#for i in `echo "$PATH" | tr ':' '\n'` ; do
#	if [ -f $i/$NAME ] ; then
		exists=1
#		break
#	fi
#done

Modify d_start() function. Comment out (with "#") all lines in function starting with "su -c". Add the following line at the end of function

su -c "screen -dmS ${srnname} rtorrent ${options} 2>$logfile"

Restart rTorrent

/opt/etc/init.d/S99rtorrent restart

You can check if rtorrent is running on screen by:

  • getting the screens list with:
screen -list
  • switching to the rtorrent screen. Return with ctrl+a+d.
screen -r


Lighttpd

install lighttpd server

ipkg install lighttpd php-fcgi

edit lighttpd configure file /opt/etc/lighttpd/lighttpd.conf:

  • change event handler to:
server.event-handler = "poll"
  • enable modules (uncomment or add) "mod_cgi" and "mod_scgi"


add local scgi socket:

scgi.server = (
	"/RPC2" =>
		( "127.0.0.1" =>
			(
				"host" => "127.0.0.1",
				"port" => 5050,
				"check-local" => "disable"
			)
		)
	)


restart lighttpd:

/opt/etc/init.d/S80lighttpd restart


check if you have your newly installed lighttpd running at http://diskstation:8081/ (replace "diskstation" with actual name or IP). If you don't get default webpage, check lighttpd logs at /opt/var/log/lighttpd/ or see if lighttpd is running.


ruTorrent

download ruTorrent from SVN to lighttpd document root folder.

cd /opt/share/www/
svn export http://rutorrent.googlecode.com/svn/trunk/rutorrent

as ruttorent cannot use default scsi socket port (due to DSM using it) change it in ruTorrent config as well /opt/share/www/rutorrent/conf/config.php

$scgi_port = 5050;

Download and install rutorrent plugins (like custom torrent download directory, RSS downloader) as needed or all plugins at once:

cd /opt/share/www/rutorrent/
svn export --force http://rutorrent.googlecode.com/svn/trunk/plugins

You might want to increase memory_limit of PHP if you operate with large (>40 GB) torrents. Edit /opt/etc/php.ini and change memory_limit=16M (or whatever you find appropriate).

Using

got to http://diskstation:8081/rutorrent/ (or use IP address instead of "diskstation") with your browser.

Troubleshooting

  • "Bad link to rTorrent. Check if it is really running. Check $scgi_port and $scgi_host settings in config.php and scgi_port in rTorrent configuration file." Check if rtorrent is running and whether scgi socket is bound to correct port (5050).
  • "rtorrent: Fault occured while inserting xmlrpc call." - (re)install XMLRPC
  • "rtorrent: SocketFd::close() called on an invalid file descriptor" - you must have added faulty torrents to rtorrent. go to /opt/share/torrent/session/ and delete some of possibly corupted torrents. restart rtorrent afterwards.
  • "Caught Segmentation fault, dumping stack" - Refer to rtorrent support as it's rtorrent exiting. Most probably you could have increased max_open_files value on rtorrent.conf. Comment it out and restart rtorrent (this variable is for lowering the value only). To increase file limits use "ulimit -n" before starting rtorrent instead.
  • checking if lighttpd is running:
ps aux | grep lighttpd

or

netstat -a -n | grep 8081
  • Checking if rtorrent is running on screen:
screen -list
  • Starting rtorrent manually (not on screen) in active SSH session with main config file:
rtorrent -n -o import=/opt/etc/rtorrent.conf
  • to monitor the number of files open by rtorrent (needs installing "lsof"):
lsof | grep ^rtorrent | wc -l
  • to monitor the number of connections made by rtorrent (needs installing "lsof"):
lsof | grep ^rtorrent | grep -i ipv4 | wc -l

you can also use "netstat -an"

  • to add UTF8 support for torrent with non-ascii characters you must add the following to rtorrent.conf
encoding_list = UTF-8
  • to get rutorrents' "unpack" plugin working, you have to install unzip and unrar libraries
ipkg install unzip unrar
  • Sometimes after reboot lighttpd does not autostart, and you have to start it up manually
/opt/etc/init.d/S88lighttpd start
  • In order to update rutorrent:
cd /opt/share/www/
svn export --force http://rutorrent.googlecode.com/svn/trunk/rutorrent

this will owerwrite /opt/share/www/rutorrent/conf/config.php, therefore don't forget to edit it and change $scgi_port value to "5050" (without quotes).

  • In order to update/install all rutorrent plugins:
cd /opt/share/www/rutorrent/
svn export --force http://rutorrent.googlecode.com/svn/trunk/plugins
  • If you have low seed speeds, be sure to check port forwarding on your router. rtorrent does not have UPnP, and therefore cannot do it automatically.
  • To set up specific file mask for downloaded files, use "umask" param on rtorrent startup as indicated on http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.html
  • To set http password protected rutorrent login, refer to Lighttpd ModAuth manual at http://redmine.lighttpd.net/wiki/1/Docs:ModAuth
  • If you have Media Server running and use DLNA/uPnP for media file streaming to your TV/console, it's worth noting, that DSM does not add newly downloaded files to the index. You have to either manually add a single file (using "synoindex" command) with post-download script or initiate full re-index of all folders.

Notes

Package versions that this logic has been applied on:

  • DSM 2.3-1139
  • xmlrpc-c 1.06.39
  • rTorrent 0.8.6/0.12.6
  • ruTorrent 3.0


  • DSM 3.1-1613
  • xmlrpc-c 1.25.6
  • rTorrent 0.8.6/0.12.6
  • ruTorrent 3.2
Personal tools
Community Resources