Saturday, January 14, 2012

NAS 110/220/440 part 4: Bittorent client to NAS 110, 220, 440 (Debian linux)


Transmission (headless server)

Transmission is great, but in lenny you get a very, very old version. There is way to get the latest or from backports but I would suggest compiling the latest from trunk. I have compiled the 2 packages needed...
And they are right here:


Older version:
libevent-2.0.16_1-1_armel.deb
transmission_2.42-1_armel.deb

Newer version:
1. transmission_2.77-1_armel.deb
2. libevent_2.0.21-1_armel.deb
3. (not sure it is needed, but here you go) intltool_0.50.2-2_all.deb

A simple dpkg -i *.deb should do the trick. Just follow the settings part for all the install methods below...


Otherwise:

  • Install transmission (from backports)
    nano /etc/apt/sources.list
    # Add those lines:
    • # Backports repository
      deb http://backports.debian.org/debian-backports lenny-backports main
    aptitude update
    aptitude install libcurl3-gnutls libevent-1.4-2
    Then download from here (common, cli, daemon)
    dpkg -i transmission-common_1.77-1~bpo50+2_all.deb
    dpkg -i transmission-daemon_1.77-1~bpo50+2_armel.deb
    dpkg -i transmission-cli_1.77-1~bpo50+2_armel.deb

  • (preferred way) Or download a tar from here  http://download-origin.transmissionbt.com/files/
    then untar from your computer and then put it in the Public folder somewhere so as to compile.
    Download from here the latest libevent for compile
    tar xvjf libevent-file.tar.bz2
    cd libevent-2.x
    ./configure && make && make install
    cd ../..
    tar xvjf transmission-2.42.tar.bz2
    cd transmission-2.42
    #install this one here ( it is the backport of libevent)
     aptitude install libcurl4-openssl-dev intltool
    ./configure
    #(or if you have compiled the libevent yourself then
     ./configure --enable-utp --enable-lightweight LIBEVENT_CFLAGS=-I/usr/local/include LIBEVENT_LIBS="-L/usr/local/lib -levent"
    if later on you have a collect2 problem then the libcurl libs are in a different path; just run a whereis libcurl and add to configure the flags (LIBCURL_CFLAGS="-I/usr/local/include" LIBCURL_LIBS="-L/usr/local/lib")#)
    make
    make install
  • nano /etc/init.d/transmission-daemon
    edit Daemon=/usr/bin/$NAME to /usr/local/bin/$NAME
    and edit USER=root
  • nano /etc/rc.local
    add just before exit 0 the "/etc/init.d/transmission-daemon start"

Settings for all the methods
transmission-daemon -f -t -u your_username -v your_password -w /media/Data/Public/torrents

The -f option sets transmission-daemon to run in the foreground (not as a daemon) for this session so we can easily close it using Ctrl + C. "-t" sets the authentication to true, "-g" sets the Transmission Daemon config folder. Without setting it, ~/.config/transmission-daemon will be used.

  • mkdir /media/Data/Public/torrents/.incomplete; mkdir /media/Data/Public/torrents/torrents;
  • You may have to "ps aux" and "kill PID" (whee the PID is the pid of the daemon) the daemon. Make sure the daemon is not running.
  • We need this to run transmission...
    ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
  • cp /var/lib/transmission-daemon/info/settings.json ~/.config/transmission-daemon/
  • rm /var/lib/transmission-daemon/info/settings.json
  • ln -s ~/.config/transmission-daemon/settings.json /var/lib/transmission-daemon/info/settings.json
  • nano /var/lib/transmission-daemon/info/settings.json
    • Change to "rpc-whitelist":"127.0.0.1,192.168.*.*"
    • SOS: Change to "download-dir": "\/media\/Data\/Public\/downloaded",
    • If you want to change the password change it a readable way:   "rpc-password": "root", "rpc-username": "root"
    • If you want to observe for a folder change 
      • "watch-dir": "\/media\/Data\/Public\/torrents\/torrents",
      • "watch-dir-enabled": true
    • SOS: As we don;t have much space, make sure that you add: 
      • "incomplete-dir": "\/media\/Data\/Public\/torrents\/Incomplete",
      • "incomplete-dir-enabled": true
    • Change preallocation to 2 so as not to fragment our hdd
    • For the rest just check  https://trac.transmissionbt.com/wiki/EditConfigFiles
  • /etc/init.d/transmission-daemon start or in case you did not compile it yourself then just nano  /etc/rc.local and add the
    /usr/local/bin/transmission-daemon -g /root/.config/transmission-daemon/
     right before exit 0.
You can download transmission remote gui, or from your browser point to 192.168.x.x:9091 (your NAS's IP)

Here is my settings.json:

{
    "alt-speed-down": 50,
    "alt-speed-enabled": false,
    "alt-speed-time-begin": 540,
    "alt-speed-time-day": 127,
    "alt-speed-time-enabled": false,
    "alt-speed-time-end": 1020,
    "alt-speed-up": 50,
    "bind-address-ipv4": "0.0.0.0",
    "bind-address-ipv6": "::",
    "blocklist-enabled": false,
    "cache-size-mb": 6,
    "dht-enabled": true,
    "download-dir": "\/media\/Data\/Public\/torrents\/downloaded",
    "download-limit": 100,
    "download-limit-enabled": 0,
    "encryption": 2,
    "incomplete-dir": "\/media\/Data\/Public\/torrents\/.incomplete",
    "incomplete-dir-enabled": true,
    "lazy-bitfield-enabled": true,
    "max-peers-global": 200,
    "message-level": 2,
    "open-file-limit": 32,
    "peer-limit-global": 240,
    "peer-limit-per-torrent": 60,
    "peer-port": 51000,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": true,
    "peer-socket-tos": 0,
    "pex-enabled": true,
    "port-forwarding-enabled": false,
    "preallocation": 2,
    "proxy": "",
    "proxy-auth-enabled": false,
    "proxy-auth-password": "",
    "proxy-auth-username": "",
    "proxy-enabled": false,
    "proxy-port": 80,
    "proxy-type": 0,
    "ratio-limit": 2.0000,
    "ratio-limit-enabled": false,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "****",
    "rpc-port": 9091,
    "rpc-username": "root",
    "rpc-whitelist": "127.0.0.1,192.168.*.*",
    "rpc-whitelist-enabled": true,
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 100,
    "speed-limit-up-enabled": false,
    "umask": 18,
    "upload-limit": 100,
    "upload-limit-enabled": 0,
    "upload-slots-per-torrent": 14,
    "watch-dir": "\/media\/Data\/Public\/torrents\/torrents",
    "watch-dir-enabled": true
}


Optionally:
As the web interface of transmission is not so good, I have changed it with Transmission WEB Control.
/usr/local/share/transmission/
tar -cvf oldweb.tar ./web; gzip -9 oldweb.tar; rm -rf web
wget https://transmission-control.googlecode.com/svn/resouces/transmission-control-full.tar.gz
tar -xzf transmission-control-full.tar.gz

If you are satisfied with this one (i.e. transmission), don't proceed any further... The others gave me headaches...
--------------------------------------------------------------------------------------------------------
Btpd
  • Build btpd torrent client
    aptitude install build-essential libssl-dev subversion
  • wget https://github.com/downloads/btpd/btpd/btpd-0.16.tar.gz
    tar -zxf btpd-0.16.tar.gz
    cd btpd-0.16
    ./configure
    make
    make install

  • Install the webui
    aptitude install python-twisted-bin python-twisted-core python-twisted-web
    cd ..
    svn checkout http://btpd-webui.googlecode.com/svn/trunk/ btpd-webui
    cd btpd-webui
    checkinstall -D python setup.py install
    nano /etc/conf.d/btpd
# owner of btpd process (must be existing)
BTPDUSER="root"
# Extra arguments for btpd
BTPDEXTRARGS="--bw-in 128 --bw-out 10"

username and password are btpd in server.name:12321/login

Now, in order to change to your needs, just

  • nano ~/.btpd-webui/config

I have done it like this

## WebUI username
#username = btpd

## WebUI password
#password = btpd

## Base directory for downloaded content
#content_directory = /root/.btpd-webui/content
content_directory = /media/Data/Public/torrent/webuicontent

## Btpd base directory
#btpd_directory = /root/.btpd
btpd_directory=/media/Data/Public/torrents

## WebUI update interval (seconds)
#update_frequency = 2

## HTTP Server port
#port = 12321

And then issue a "btpd-webui restart"

You can start anytime the btpd client by issuing this command (change bw-out and max peers to you needs)
 btpd --bw-out 200 --max-peers 40 -d /media/Data/Public/torrents

 btcli -d /media/Data/Public/torrents list

-----------------------------------------------------------------------------------------------------
Alternatively you could try your luck with rtorrent... I couldn't get it to compile with xmlrpc-c in our armel...
  • Compile rtorrent dependencies
    aptitude install build-essential libssl-dev libsigc++-2.0-dev subversion  libncurses5-dev libcurl4-openssl-dev libwww-dev libwww-ssl-dev mysql-server mysql-client libxmlrpc-c3 libcppunit-dev
    libtool
    cd /media/Data/Public/compiles
    mkdir rtorrent;mkdir rtorrent/rtorrent;mkdir rtorrent/libtorrent;mkdir rtorrent/xmlrpc cd rtorrent/libtorrent
    wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.0.tar.gz
    tar -zxf libtorrent-0.13.0.tar.gz
    cd libtorrent-0.13.0
    ./configure && make all && make install
    cd ../../libwww
    wget http://www.physionet.org/physiotools/libwww/w3c-libwww-5.4.0.tar.gz
    tar xfvz w3c-libwww-5.4.0.tar.gz
    cd w3c-libwww-5.4.0
    ./configure --with-ssl --with-zlib --with-regex --with-expat --with-md5
    make
    make install
    aptitude install
    cd ../../xmlrpc
    svn checkout -r 1579 http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/advanced xmlrpc-c
    (svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/trunk xmlrpc-c)
    cd xmlrpc-c
    ./configure && make && make install
    cd ../../rtorrent
  • Compile rtorrent
    wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.0.tar.gz
    tar -zxf rtorrent-0.9.0.tar.gz
    cd rtorrent-0.9.0
    ./configure --with-xmlrpc-c=/usr/local/bin/xmlrpc-c-config
  • (note to self... I din;t think of "ln" symlinking)

Info:
for btpd here and here
for transmission here, here and here for scripts upon finishing a torrent,
for rutorrent with rtorrent (here) for rtorrent compile (here,)
http://homepage.mac.com/paalb/Examples/ln.html

2 comments:

  1. hi!
    It is tough to discover knowledgeable individuals on this matter, but you sound like you know what you’re speaking about!NYC working Thanks . .

    ReplyDelete
    Replies
    1. Hello! Thanks buddy. Hope it helps.
      I am very happy from my NAS. At first all I wanted to do was to have my Samsung playback the video files from it and over the days I figured it could do a lot more (Linux is always a very powerful Operating system).
      Take care!

      Delete