x - NOTE TO SELF - Guide on setting up RuTorrent - Rtorrent - On Debian Box

( WARNING IF DONE INCORRECTLY - CAN DAMAGE THE NAS (if your doing this on a READYNAS) - HOWEVER IF YOUR VERSED IN LINUX THIS SHOULD BE CAKEWALK - WARNING BREAKING THE NAS THRU SSH ACCESS VOIDS THE WARRANTY)
( If done on a Debian Box this guide should be easy - considering you understand my cryptic way of explaining things)

First off let me apologize for the bad formatting of this guide - I made this for myself - But I decided to share this on here since Ive seen so many posts on this

As an Alternative which works better than Transmission in my opinion: Check out RuTorrent. It works with rtorrent. There are addons available to get Rutorrent and rtorrent install on the nas. If the addons are not for your architecture check out Rutorrent and rtorrent setup guides on Debian systems and attempt - if you accept the risk/challenge - on the NAS.

I set this up on a Debian Box back home - NOT A READYNAS - but the READYNAS is a DEBIAN box - so if you want here are the steps I followed to get Rtorrent on my Virtual Machine (debian) working - It downloaded torrents to my Host Machine (which ran the Debian VM) - The host machine has a 4tb drive connected to it (Downloads folder that I shared). Everytime my Virtual machine launches it launches RTORRENT/rutorrent and mounts the 4tb drive across the network using CIFS (on windows I had to share the drive to all users, on the nas I had to authenticate with one of the users, and also force that authentication). Alternatively you could mount a NAS share on the Debian box. So basically - If all else fails you could setup a VM running Debian follow my steps but instead of a 4TB drive as I used, you can point it at your NAS.
 
There are two ways to look at the instructions below:
 
 
1- The code you type at your DEBIAN machine that sets up Rutorrent/rtorrent on it - it also points it to a remote share which could be a READYNAS or a NAS - I show you how to write a script that auto mounts these shares upon login - Also I show you how to start Rutorrent and rtorrent
 
2- Since the READYNAS is a debian box you could attempt this code on it - you could skip all the codes that talk about mounting remote shares as you will be downloading to the NAS most likely. I guarantee a few things will be different if you run this code on the NAS you will come across obstacles that you will have to overcome



###################################################

TRY AT YOUR OWN RISK
    
BELOW is a rutorrent rtorrent guide versed more
towards Debian Boxes

WHAT WILL BE DIFFERENT ON NAS SYSTEM:

The folders that I make and download at would be different if I set this up on a NAS

On a NAS you have to put your Webserver stuff in a
different folder then /var/www

Also you might need to add entries to your
/etc/apt/sources.list to be able to "apt-get install"
all those apps

###################################################


### INSTALLING ###

apt-get update
apt-get install subversion build-essential automake libtool libcppunit-dev libcurl3-dev libsigc++-2.0-dev unzip unrar-free curl libncurses-dev apache2 php5 php5-cli php5-curl libapache2-mod-scgi

ln -s /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load

mkdir ~/install;cd ~/install
svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c

cd xmlrpc-c

./configure --disable-cplusplus
make
make install

cd ~/install
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.3.tar.gz
tar -xzvf libtorrent-0.13.3.tar.gz
cd libtorrent-0.13.3
./autogen.sh
./configure
make
make install


cd ~/install
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.3.tar.gz
tar -xzvf rtorrent-0.9.3.tar.gz
cd rtorrent-0.9.3
./autogen.sh
./configure --with-xmlrpc-c
make
make install
ldconfig

mkdir /home/kossboss/rtorrent
mkdir /home/kossboss/rtorrent/.session
mkdir /home/kossboss/rtorrent/watch
mkdir /home/kossboss/rtorrent/download

Setup .rtorrent.rc file (rTorrent config):


cd ~/
wget http://vps6.net/src/.rtorrent.rc
cp .rtorrent.rc /home/kossboss/


#####(Edit the settings in .rtorrent.rc, like max upload/download speed, max connected peers, etc, as needed.)#####

cd ~/install
wget https://rutorrent.googlecode.com/files/rutorrent-3.5.tar.gz
tar -xzvf rutorrent-3.5.tar.gz
mv rutorrent /var/www
wget https://rutorrent.googlecode.com/files/plugins-3.5.tar.gz
tar -xzvf plugins-3.5.tar.gz
mv plugins /var/www/rutorrent
rm -rf /var/www/rutorrent/plugins/darkpal
chown -R www-data:www-data /var/www/rutorrent

a2enmod ssl
a2enmod auth_digest
a2enmod scgi
openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem
chmod 600 /etc/apache2/apache.pem
htdigest -c /etc/apache2/passwords seedbox kossboss

#####(Enter a password of your choice when prompted, you will use this to log in to the ruTorrent web UI.)#######

cd /etc/apache2/sites-available/
rm -rf default
wget http://vps6.net/src/default
a2ensite default-ssl
/etc/init.d/apache2 reload


#### follow the rclocal and dtach script so that it launches when you start the debian box ###

### MY RC.LOCAL SCRIPT === SO THAT rtorrent launches thru a dtach session and also the win8 download folder gets mounted ###

cat /etc/rc.local
    
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/sbin/mountrdownwin.sh

start-stop-daemon --start --chuid kossboss --name rtorrent --exec /usr/bin/dtach -- -n /home/kossboss/rtorrent`date +%x-%T | tr [/:] -`.dtach /usr/local/bin/rtorrent

exit 0

#####################################################################################
The next part ASSUMES YOUR SETTING UP RTORRENT/RUTORRENT ON YOUR DEBIAN VM  and sets up scripts that mounts my remote USB drive - you could do this on your Debian VM and make it mount the READYNAS shares on there
(or)
SKIP THIS NEXT SECTION IF WRITING THESE SCRIPTS IF YOUR JUST ATTEMPTING TO SETUP THE RUTORRENT/RTORRENT ON YOUR NAS

#####################################################################################

### MADE THIS SCRIPT LAUNCH AT START (during login of session actually and start) thru rc.local  (or you can use .bashrc)###
* it checks for mounts existing so that you dont have double mounts

#!/bin/bash
echo "=== mountrdownwin script =="
echo "* Mounting download locations"
mountc="//10.11.12.13/Downloads"
volc="/mnt/rdownwin"
if mount | grep -i "on ${volc} type" > /dev/null;
then
echo "ALREADY MOUNTED: $mountc -> $volc"
else
echo "MOUNTING: $mountc -> $volc"
mount -t cifs -o user=kossboss,pass='password',uid=kossboss "$mountc" "$volc"
fi
echo "=== EOF mountrdownwin script =="


### THIS SCRIPT WILL UNMOUNT THAT IF YOU NEED IT ###

#!/bin/bash
umount /mnt/rdownwin

### GIVE kossboss-user to run those PERMISSION ###

chmod 777 mountrdownwin.sh
chmod 777 umountrdownwin.sh


mkdir /mnt/rdownwin/0rtor && chmod 777 -R /mnt/rdownwin/0rtor

### IN RUTORRENT INTERFACE: ###

* Log in with password that you set for WebUI uptop

default download directory:
/home/kossboss/rtorrent/download

changed to:
/mnt/rdownwin/0rtor

### ONLY CHANGE TO /home/kossboss/.rtorrent ###
* I include full file below
directory = /mnt/rdownwin/0rtor/
from
directory = /home/kossboss/rtorrent/download
-- this just means by default this is the setting but can change it when logged in to the web interface (the web interface doesnt modify the .rtorrent file)

#### DONT FORGET TO GET RID OF INSTALL ###

cd ~
rm -rf install

#########
#########
#########

Didnt modify this one, just download as per instructions below

#########
#########
#########

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

<Location /rutorrent>
AuthType Digest
AuthName "seedbox"
AuthDigestDomain /var/www/rutorrent/ http://127.0.0.1/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/passwords
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>

</VirtualHost>

<VirtualHost *:443>
ServerAdmin webmaster@localhost

SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
<Location /rutorrent>
AuthType Digest
AuthName "seedbox"
AuthDigestDomain /var/www/rutorrent/ http://127.0.0.1/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/passwords
Require valid-user
SetEnv R_ENV "/var/www/rutorrent"
</Location>
</VirtualHost>

##################################################################
##################################################################
##################################################################

.rutorrent.rc file

I let this file know via the "Directory" Directive below to put
all of its downloads into the rdownwin share which and in a folder
called 0rtor

##################################################################
##################################################################
##################################################################

# This is an example resource file for seeder1rent. Copy to
# ~/.seeder1rent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
#
# Based on original .seeder1rent.rc file from http://libtorrent.rakshasa.no/
# Modified by Lemonberry for rtGui http://rtgui.googlecode.com/
#
# This assumes the following directory structure:
#
# /Torrents/Downloading - temporaray location for torrents while downloading (see "directory")
# /Torrents/Complete - Torrents are moved here when complete (see "on_finished")
# /Torrents/TorrentFiles/Auto - The 'autoload' directory for seeder1rent to use.  Place a file
#           in here, and seeder1rent loads it #automatically.  (see "schedule = watch_directory")
# /Torrents/Downloading/seeder1rent.session - for storing seeder1rent session information
#

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 250

# Same as above but for seeding completed torrents (-1 = same as downloading)
min_peers_seed = -1
max_peers_seed = -1

# Maximum number of simultanious uploads per torrent.
max_uploads = 50

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 0

# Default directory to save the downloaded torrents.
directory = /mnt/rdownwin/0rtor/

# Default session directory. Make sure you don't run multiple instance
# of seeder1rent using the same session directory. Perhaps using a
# relative path?
session = /home/kossboss/rtorrent/.session

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/kossboss/rtorrent/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=

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

# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
#schedule = ratio,60,60,stop_on_ratio=200,200M,2000


# When the torrent finishes, it executes "mv -n <base_path> ~/Download/"
# and then sets the destination directory to "~/Download/". (0.7.7+)
# on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/seeder1/download/complete/ ;d.set_directory=/home/seeder1/download/complete/"

# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no

# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no

# Port range to use for listening.
port_range = 55995-56000

# Start opening ports at a random position within the port range.
#port_random = yes

scgi_port = 127.0.0.1:5000

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
#check_hash = no

# Set whetever the client should try to connect to UDP trackers.
#use_udp_trackers = no

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
encryption = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
dht = disable

# UDP port to use for DHT.
#
# dht_port = 6881

# Enable peer exchange (for torrents not marked private)
#
peer_exchange = no

#
# Do not modify the following parameters unless you know what you're doing.
#

# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10

# Interval between attempts to check the hash, in milliseconds.
#hash_interval = 100

# Number of attempts to check the hash while using the mincore status,
# before forcing. Overworked systems might need lower values to get a
# decent hash checking rate.
#hash_max_tries = 10

# Max number of files to keep open simultaniously.
#max_open_files = 128

# Number of sockets to simultaneously keep open.
#max_open_sockets = <no default>


# Example of scheduling commands: Switch between two ip's every 5
# seconds.
#schedule = "ip_tick1,5,10,ip=torretta"
#schedule = "ip_tick2,10,10,ip=lampedusa"

# Remove a scheduled event.
#schedule_remove = "ip_tick1"
Comments