Home > archlinux, muletto, post, server, ssh > how to: rtorrent con screen e ssh

how to: rtorrent con screen e ssh

 
Link:

 

  1. Configurazione host remoto:
    1. yaourt -S rtorrent screen
    2. cp /etc/screenrc ~/.screenrc
    3. nano .screenrc
      .....
      .....
      screen -t rtorrent rtorrent # rtorrent always start with screen
    4. nano .rtorrent.rc :
      
      scgi_port = 127.0.0.1:5000   # socket port for ntorrent (a gui for rtorrent :)  )
      
      # 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 = 10
      max_peers_seed = 250
      
      # Maximum number of simultanious uploads per torrent.
      #max_uploads = 8
      
      # Global upload and download rate in KiB. "0" for unlimited.
      download_rate = 0
      upload_rate = 10
      
      # Default directory to save the downloaded torrents.
      directory = /media/banca_dati/torrent
      
      # Default session directory. Make sure you don't run multiple instance
      # of rtorrent using the same session directory. Perhaps using a
      # relative path?
      session = /media/banca_dati/torrent/in_download_torrent
      
      # Watch a directory for new torrents, and stop those that have been
      # deleted.
      #schedule = watch_directory,5,5,load_start=./watch/*.torrent
      #schedule = untied_directory,5,5,stop_untied=
      schedule = watch_directory,10,10,load_start=/media/banca_dati/watch_torrent/*.torrent
      schedule = untied_directory,5,5,"remove_untied="
      #schedule = tied_directory,5,5,start_tied=
      schedule = low_diskspace,60,60,"close_low_diskspace=100M"
      
      # Port range to use for listening.
      port_range = 17594-17594
      
      # Start opening ports at a random position within the port range.
      #port_random = no
      
      # 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 = yes
      
      # Set whetever the client should try to connect to UDP trackers.
      #use_udp_trackers = yes
      
      # 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
      encryption = allow_incoming,try_outgoing,enable_retry
      
      # 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 = auto
      
      # UDP port to use for DHT.
      #
      # dht_port = 6881
      
      # Enable peer exchange (for torrents not marked private)
      #
      # peer_exchange = yes
      
      #
      # 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
      
      on_finished = rm_torrent,"execute=rm,$d.get_tied_to_file="
      on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/media/banca_dati/torrent/Completati/ ;d.set_directory=/media/banca_dati/rtorrent/Completati/"
      
    5. nano /etc/rc.d/rtorrent :
      
      #!/bin/bash
      
      . /etc/rc.conf
      . /etc/rc.d/functions
      
      case "$1" in
        start)
          stat_busy "Starting rtorrent"
          su <utente linux> -c 'screen -d -m rtorrent' &> /dev/null
          if [ $? -gt 0 ]; then
            stat_fail
          else
            add_daemon rtorrent
            stat_done
          fi
          ;;
        stop)
          stat_busy "Stopping rtorrent"
          killall -w -s 2 /usr/bin/rtorrent &> /dev/null
          if [ $? -gt 0 ]; then
            stat_fail
          else
            rm_daemon rtorrent
            stat_done
          fi
          ;;
        restart)
          $0 stop
          sleep 1
          $0 start
          ;;
        *)
          echo "usage: $0 {start|stop|restart}"
      esac
      exit 0
      
  2. Avvio:
    1. Host remoto (tramite ssh):
      1. nano rtorrentqueuemanager.py :
        
        #!/usr/bin/env python
        
        import glob
        import stat
        import os
        import shutil
        import time
        
        #change the parametes
        watch = "/media/banca_dati/watch_torrent"
        session = "/media/banca_dati/torrent/in_download_torrent"
        queue = "/media/banca_dati/torrent/coda_torrent"
        max_downloads = 2
        
        while True:
            time.sleep(60)
            sfiles = glob.glob(session + "/*.torrent")
            oldesttime = 0
            oldestfile = ""
            if len(sfiles) < max_downloads :
                qfiles = glob.glob(queue + "/*.torrent")
                for i in qfiles :
                    ftime = os.stat(i)[stat.ST_MTIME]
                    if oldesttime == 0 or ftime < oldesttime :
                        oldesttime = ftime
                        oldestfile = i
                if oldestfile != "" :
                    shutil.move(oldestfile, watch)
        
        
      2. sudo /etc/rc.d/rtorrent start
      3. sudo python rtorrentqueuemanager.py &
    2. host locale:
      1. echo "ssh -p <porta> -t <utente>@<IP> 'screen -r'" > rtorrent_connetti.sh
      2. nano .bashrc :
        
        .....
        # control+s con screen e rtorrent:
        # http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide#Addingandremovingtorrents
        #
        stty stop undef
        stty start undef
        .....
        .....
        
      3. bash rtorrent_connetti.sh
      4. # a java gui for rtorrent:
        
        yaourt -S ntorrent

 
Last update: 06 mar 2010

About these ads
  1. dax
    September 5, 2009 at 10:56 am | #1

    ciao, ti devo ringraziare. finalmente riesco a lanciare $foo su screen. eppure il man l’ho seguito più volte, google pure.
    senti un pò perchè screen -t $foo $foo? perchè due volte?

    • September 5, 2009 at 11:33 am | #2

      ho guardato sul man, -t è la flag per il titolo della shell, quindi li con quel comando imposti prima come titolo $foo e poi gli fai eseguire “$foo”

      ciao

      • September 5, 2009 at 11:36 am | #3

        anche se a me non imposta il titolo! L’ho notato solo adesso.. quindi l’ho tolta :)

  1. July 8, 2009 at 7:34 am | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

%d bloggers like this: