Page 1 of 7 123 ... LastLast
Results 1 to 15 of 102

Thread: [How to] rtorrent & ntorrent

  1. #1

    [How to] rtorrent & ntorrent

    I figured I'd try to write a brief how to on getting the rtorrent/ntorrent working together since I've went through it recently in desperation (my Transmission is acting up and downloading really slow, with only half a dozen peers per torrent and no obvious problems to fix).

    This is meant for those who wish to run an alternative BT (rtorrent) and do not mind using a client side interface (ntorrent) on their desktop to manage their torrents.

    ntorrent is a Java based application and will work on any platform supporting Java >= 1.6. Go to its page and download the binary package to your desktop, it's in the featured downloads (bz2 file and any language addition you need).

    Anyways, this might not be exactly step-by-step since I'm recollecting my journey and I might miss a step so please pitch in with your comments.

    Oh, if you mess up your router I am not responsible - you have been warned!

    I will assume that everyone has a similar setup, WL500gP, /opt and oleg's firmware/feeds.

    First of all make sure you got everything up to date:

    Code:
    ipkg update
    ipkg upgrade
    Then we need to grab rtorrent, it will also install libtorrent and bunch of other things (xmlrpc etc) but no worries you need those as well

    Code:
    ipkg install rtorrent
    We'll need to run apache or lighttpd to have scgi, so let's install the later:

    Code:
    ipkg install lighttpd
    Also, we need screen:

    Code:
    ipkg install screen
    ...and bash

    Code:
    ipkg install bash
    Now we are ready to do some configurating, first lighttpd, the config file for it is in /opt/etc/lighttpd/lighttpd.conf so edit it:

    Code:
    vi /opt/etc/lighttpd/lighttpd.conf
    I have kept most things default, you may change the port from default 8081 to something else if you like.
    I didn't, what I added was mod_scgi in the server.modules list (I added around the end, you can add anywhere as long as it's not commented):

    Code:
    #                               "mod_rrdtool",
                                    "mod_scgi",
                                    "mod_accesslog" )
    At the very end of the file I've added the following:

    Code:
    scgi.server = (                                                            
            "/RPC2" =>                                                         
                    ( "127.0.0.1" =>                                             
                            (                                                    
                                    "socket" => "/opt/var/run/rpc.socket",       
                                    "check-local" => "disable",                  
                                    "disable-time" => 0,  # don't disable scgi if connection fails
                            )                                                    
                    )                                                            
            )
    This will enable passing the socket connection from rtorrent via lighttpd to our remote ntorrent client via http:// protocol.

    Save and exit the file.

    Let's make rtorrent config file next, I will use a non default location for it (it usually sits in your home dir as .rtorrent.rc but I want it on my mounted drive):

    Code:
    vi /opt/etc/rtorrent.conf
    And these are some of the settings, you can adjust more settings by reading the rtorrent manpage

    Code:
    scgi_local = /opt/var/run/rpc.socket
    session = /opt/share/torrent/work
    port_range = 10000-11000
    directory = /opt/share/torrent/dl
    check_hash = yes
    encryption = prefer_plaintext
    stop_on_ratio = 100
    upload_rate = 50
    max_uploads = 5
    I have used ports 10000-11000 for it, but you can use any port range you like. Remember that you will have to open these ports in your firewall, so...

    Code:
    vi /usr/local/sbin/post-firewall
    This is what you should have, at least:

    Code:
    #!/bin/sh
    
    ## FIREWALL
    ## set default policy
    iptables -P INPUT DROP
    ## deny ftp access from WAN
    iptables -I INPUT 1 -p tcp -i "$1" --syn --dport 21 -j DROP
    ## Allow access to various router services from WAN
    ## open 10000-11000 for rtorrent
    for P in 10000:11000; do
      iptables -I INPUT 1 -p tcp --syn -i "$1" --dport $P -j ACCEPT
    done
    You might wanna change your pre-shutdown as well, I used the one wirespot posted (thanks!).

    Code:
    vi /usr/local/sbin/pre-shutdown
    ...and add the following:

    Code:
    #!/bin/sh
    # This one is simple. I send signal INT to rtorrent
    # to tell it to do a graceful shutdown that will make
    # it save its hashes and full status. (You need to
    # enable sessions with session=dir in rtorrent.rc
    # for this to work!):
    /bin/kill -INT $(/bin/pidof rtorrent) &
    # Then I wait for 10 seconds to be sure it died
    # gracefully. The rtorrent docs say it dies in 5,
    # I just wanna make extra sure.
    /bin/sleep 10
    Since we made the change to flashfs this needs to "stick" after reboot so:

    Code:
    flashfs save && flashfs commit

  2. #2

    (continued...)

    Next let's look at the script that starts rtorrent:

    Code:
    vi /opt/etc/init.d/S99rtorrent
    I had to change it because I did not use su, my user already has root privileges so I'm pasting the entire script without comments, so replace what you have with code below:

    Code:
    #!/opt/bin/bash 
    # Do not proceed unless some apps are available.
    test -x /opt/bin/screen || exit 0
     
    ##Start Configuration##
    
    # the full path to the filename where you store your rtorrent configuration
    config=("/opt/etc/rtorrent.conf")
     
    # set of options to run with each instance, separated by a new line
    options=("-n -o import=/opt/etc/rtorrent.conf")
    
    # default directory for screen, needs to be an absolute path                           
    base="/opt/share/torrent"                                                              
                                                                                           
    # name of screen session                                                               
    srnname="rtorrent"                                                                     
    #######################                                                                                                                                
    PATH=/opt/local/bin:/opt/sbin:/opt/bin:/sbin:/bin:/usr/sbin:/usr/bin                   
    DESC="rtorrent"                                                                        
    NAME=rtorrent                                                              
    DAEMON=/opt/bin/$NAME                                                                  
    SCRIPTNAME=/opt/etc/init.d/S99rtorrent                                                 
                                                                                           
    # Gracefully exit if the package has been removed.                                     
    test -x $DAEMON || exit 0                                                              
                                                                                           
    checkcnfg() {                                                                          
      for (( i=0 ; i < ${#config[@]} ;  i++ )) ; do                                        
            if ! [ -r "${config[i]}" ] ; then                                              
                    echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate">&2
                    exit 3                                                                                                    
            fi                                                                             
            session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//")
            if ! [ -d "${session}" ] ; then                                                                                      
                    echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions">&2   
                    exit 3                                                                                                       
            fi                                                                                                                
      done                                                                                                                       
    }                                                                                                                            
                                                                                                                                 
    d_start() {                                                                                                                  
    logger "Starting."                                                                                                           
      [ -d "${base}" ] && cd "${base}"                                                                                           
      stty stop undef && stty start undef                                                                                        
      screen -ls | grep .${srnname}[[:space:]] > /dev/null || screen -dm -S ${srnname}                                           
      for (( i=0 ; i < ${#options[@]} ; i++ )) ;  do                                                                             
        sleep 3                                                                                                                  
        screen -S ${srnname} -X screen rtorrent ${options[i]}                                                                    
      done                                                                                                                       
    }            
    d_stop() {                                                                                                                   
      for (( i=0 ; i < ${#config[@]} ; i++ )) ; do                                                                            
            session=$(cat "${config[i]}" | grep "^[[:space:]]*session" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//")
            pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g")                                      
            # make sure the pid doesn't belong to another process                                                                
            # skip the pid otherwise                                                                                             
            if ps | grep ${pid}.*rtorrent > /dev/null ; then                                                                     
                    kill -s INT ${pid}                                                                                           
            fi                                                                                                                   
      done                                                                                                                       
    }                                                                                                                         
                                                                                                                              
    checkcnfg                                                                                                                    
                                                                                                                                 
    case "$1" in                                                                                                                 
      start)                                                                                                                     
            echo -n "Starting $DESC: $NAME"                                                                                      
            d_start                                                                                                              
            echo "."                                                                                                             
            ;;                                                                                                                   
      stop)                                                                                                                      
            echo -n "Stopping $DESC: $NAME"                                                                                      
            d_stop                                                                                                               
            echo "."                                                                                                             
            ;;                                                                                                                   
      restart|force-reload)                                                                                                      
            echo -n "Restarting $DESC: $NAME"                                                                                    
            d_stop                                                                                                               
            sleep 1                                                                                                              
            d_start                                                                                                              
            echo "."                                                                                                             
            ;;                                                                                                                   
      *)                                                                                                                         
            echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2                                                      
            exit 1                                                                                                               
            ;;                                                                                                                   
    esac                                                                                                                         
                                                                                                                                 
    exit 0
    Hmm, so I guess that's it, let's reboot to make sure everything starts on its own, firewall applies new rules etc...

  3. #3

    (continued...)

    After reboot, do ps and you should see lighttpd running as well as screen with your rtorrent attached to it including the -n -o import=...rtorrent.conf.

    Now, go to your browser and connect to the lighttpd:

    Code:
    http://routerIP:8081
    You should see "lighttpd server is running." Excellent!

    Next connect to the socket interface:

    Code:
    http://routerIP:8081/RPC2
    You should see an empty screen (as in white...) but that's good. Otherwise if you get 500 Server error, then something is wrong. Either rtorrent isn't running, or lighttpd isn't passing RPC through the socket. Hard to say, you will have to troubleshoot it...

    We are ready to connect to our rtorrent now. Unpack the downloaded ntorrent binary somewhere (C:\Program Files\ntorrent, /Applications/ntorrent, /opt/ntorrent ...) and run it. The *ix users can use .sh file included, Winblows users should double-click on the .jar file.

    You will see a Profiles dialogue, select http from the protocol drop-down.

    Under host enter the IP of your router.

    Connection port is 8081 (default for lighttpd or whatever else you set it to).

    Mountpoint is /RPC2 (remember that's what we told lighttpd to use as an interface between the rtorrent socket and the Web).

    Username is your user on the router, and Password is its password.

    Tick "Remember Password" and click "Save profile".

    In a moment you should be connected. Look at the bottom of the ntorrent window, there are some numbers there. You should see the Port: 10000-11000 (range we have set earlier), and your Ping: 2 sec or so...zomg it worked, you lucky, you !

    So, "File/Add torrent" and off you go, it's pretty simple to use - you'll figure it out on your own.

    Happy Holidays!

    P.S. This is how I've done it (to best of my knowledge/recollection) so if you run into trouble you are on your own...
    Last edited by mancub; 23-12-2007 at 21:49.

  4. #4
    Hello,

    What can i say it is relay great tutorial for rtorret and ntorrent.

    I LIKE IT

    and yeah UPLOAD IS WORKING NORMAL now. With transmission i have big problems 0 upload 200 download :S so my ratio was f...... up

    THX m8
    Last edited by polde; 24-12-2007 at 11:37.

  5. #5
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    3,805
    Why not use:
    PHP Code:
    iptables -I INPUT 1 -p tcp --syn -"$1" --dport 10000:11000 -j ACCEPT 
    instead of:
    PHP Code:
    for P in 10000:11000; do
      
    iptables -I INPUT 1 -p tcp --syn -"$1" --dport $P -j ACCEPT
    done 
    Finally, are you sure that rtorrent needs that much ports to be opened? I guess the default value is something like 4-10 ports.

    Actually I suggest the following rework of the minimalistic post-firewall file:

    PHP Code:
    #! /bin/sh

    ## FIREWALL
    ## set default policy
    iptables -P INPUT DROP
    # remove last default rule
    iptables -D INPUT -j DROP

    ## Allow access to various router services from WAN
    ## open 10000-11000 for rtorrent
    iptables -A INPUT -p tcp --syn -"$1" --dport 10000:11000 -j ACCEPT 
    This allows painless addition of the new rules in the end of the INPUT chain which is generally more correct way in comparison with inserting them in the beginning.

    However, strictly speaking this method implies a requirement to set: Internet Firewall - Basic Config - Logged packets type: NONE
    Last edited by al37919; 24-12-2007 at 13:48.

  6. #6
    Hello,

    Default configuration is following:

    PHP Code:
    # Port range to use for listening.
    port_range 51777-51780 
    i use this port range and this iptables WHY? I have set ssh and other ports to open state.

    example:

    PHP Code:
    for P in 22 8008 10000:11000; do
      
    iptables -I INPUT 1 -p tcp --syn -"$1" --dport $P -j ACCEPT
    done 
    Some one know what is this seating

    PHP Code:
    # Set whetever the client should try to connect to UDP trackers.
    use_udp_trackers yes 
    Last edited by polde; 24-12-2007 at 13:48.

  7. #7
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    5
    Hi!
    I need some help, i done everything as written here, but screen and rtorrent doesn't seem to start. i have no idea why. lighttpd is working fine.
    any ideas/suggestions?

  8. #8
    Quote Originally Posted by Artus View Post
    Hi!
    I need some help, i done everything as written here, but screen and rtorrent doesn't seem to start. i have no idea why. lighttpd is working fine.
    any ideas/suggestions?
    I suggest you check if they are all installed properly and that they run on their own (so try them independently).

    Maybe your S99rtorrent isn't chmod a+x? Also, see if there's anything in the logs as well...

  9. #9
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    5
    during screen install:

    Code:
    Configuring screen
    chown: unknown user name: root
    Successfully terminated.
    is that ok?

    S99rtorrent's chmod is ok
    thanks for the help!

  10. #10
    Thanks for this tutorial.

    Would it be possible to get wtorrent working ?

    Anyway, I'm stuck with the "500 - Internal Server Error" when I'm trying mylocalip:8081/RPC2

    It seems that rtorrent isn't starting with correct options, when I type ps I get:

    Code:
      103 admin      1340 S   /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf 
      106 admin       752 R   dropbear 
      123 admin           SW  [kjournald]
      127 admin       568 S   -sh 
      208 admin       812 S   SCREEN -dm -S rtorrent 
      210 admin       488 S   /bin/sh 
      214 admin       400 R   ps
    I'm missing the "-n -o import=...rtorrent.conf" - right ?

    lighttpd is working and when I start S99rtorrent manually - it starts with no errors.

    However, when I do "./S99rtorrent stop" I get:

    Code:
    Stopping rtorrent: rtorrentcat: /opt/share/torrent/work/rtorrent.lock: No such file or directory
    kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
    .
    But I think I have made everything according to the guide - any ideas ?

  11. #11
    hey

    Try with this script for me its working.

    PHP Code:
    #!/bin/sh
    /opt/bin/screen -dmS rtorrent rtorrent -o import="/opt/etc/rtorrent.conf" 2>&>/tmp/rtl 
    edit
    dont start rtorrent with /S99rtorrent stop i run to some problem because of bash scripting.
    wtorrent is also working go trough installation guied on wtorrent page
    whit lastest build AJAX I have some problems in firefox

    Bye
    Last edited by polde; 05-01-2008 at 20:03.

  12. #12
    Quote Originally Posted by Artus View Post
    during screen install:

    Code:
    Configuring screen
    chown: unknown user name: root
    Successfully terminated.
    is that ok?

    S99rtorrent's chmod is ok
    thanks for the help!
    this is normal everyting its working i also run to this problem it OK

  13. #13
    I get rtorrent working with

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

    and

    Code:
    scgi_port = localhost:5000
    in rtorrent.conf instead of scgi_local = /opt/var/run/rpc.socket

  14. #14
    Thanks for your hints!

    I tried some different settings, but it turned out to be my rtorrent.conf that had an error.

    (had to start rtorrent "normal" to find that out)

    I'm using ssyyzz:s config.

    Now its working

    Will try wtorrent tomorrow.

    Thanks again for this tutorial

  15. #15
    I know that this is a bit off from the subject, but I'm stuck on the wtorrent install and was wondering if polde (or anyone else) could help me ?

    nTorrent is working and I'm using ssyyzz:s konfiguration from above.

    I have installed php-fcgi, edited lighttpd.conf and PHP is working.

    I have edited wtorrent/conf/home.conf.php and put chmod 777 on db, torrents and tpl_c

    When I browse to install.php I get the wtorrent install username/password page - but when I press "create" I get an empty red error-square.

    I think there is something wrong in home.conf.php ?

    I have set correct path:s and changed RT_AUTH to false - but there is no change.

    Any ideas what is wrong ?

Page 1 of 7 123 ... LastLast

Similar Threads

  1. Replies: 28
    Last Post: 02-06-2013, 21:58
  2. Ipkg rtorrent Packet gesucht
    By FastJack in forum German Discussion - Deutsch (DE)
    Replies: 1
    Last Post: 23-10-2007, 18:37
  3. older rtorrent version
    By FastJack in forum WL-500gP Q&A
    Replies: 1
    Last Post: 23-10-2007, 10:40
  4. [How To] Oleg Firmware installeren.
    By Dragonar in forum Dutch Discussion - Nederlands
    Replies: 7
    Last Post: 08-05-2007, 19:34
  5. [HOW TO] Timeouts beim Laden von bestimmten Seiten beheben - MTU Problem
    By modnet25 in forum German Discussion - Deutsch (DE)
    Replies: 3
    Last Post: 03-09-2006, 11:55

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •