How to install and configure Torrent client in redhat/centos 6.x

Posted by Md. Mahidul Hasan on 4:37 AM with No comments
How to install and configure Torrent client in redhat 6

Topic Index:
   1. Concept
   2. Installation
   3. Set global speed restriction
   4. Start a download from Transmission-gui
   5. Start a download from command line
   6. Start a download from web interface
   7. Create new Torrent
   8. Download torrent file using cronjob
   9. Troubleshooting

01. Concept:          
As we all know torrent is a peer-to-peer file sharing protocal whish is used for the transaction of big amount data. For this kinds of sharing we can use may kinds of torrent clients like bittorrent, utorrent, transmission etc. Torrent is simple in windows internment but little bit complected from linux command line. Here I have explained details regarding transmission torrent client which gives you all the features you want. Some of the major feature is like below-
1. Command line usability
2. Uses as desktop client
3. Remote access to the client
4. Web interface for accessing through Internet

02. Installation:
First install dependencies:
[root@gw1 ~]# yum -y install openssl* make gcc gcc-c++ autoconf automake openssl-devel curl-devel libevent-devel wget libevent-1.4.so.2

If still libevent is missing then menually download and install it like this way:
[root@gw1 ~]# wget ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6rolling/x86_64/os/Packages/libevent-1.4.13-4.el6.x86_64.rpm
or
[root@gw1 ~]# wget ftp://rpmfind.net/linux/centos/6.4/os/x86_64/Packages/libevent-1.4.13-4.el6.x86_64.rpm
[root@gw1 ~]# rpm -ivh libevent-1.4.13-4.el6.x86_64.rpm

Now we are going to download a torrent client named transmission:
[root@gw1 ~]# wget ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/transmission-daemon-2.13-1.el6.x86_64.rpm
[root@gw1 ~]# wget http://dl.dropboxusercontent.com/u/72284235/transmission.tar.gz
[root@gw1 ~]# tar -zxvf transmission.tar.gz

Lets unzip it and install the nessesary packages:
[root@gw1 ~]# rpm -ivh transmission-daemon-2.13-1.el6.x86_64.rpm

To use transmission client from desktop envirnment follow below step:
[root@gw1 ~]# rpm -ivh transmission/*

To use transmission client only from command line interface (CLI) follow below steps:
[root@gw1 ~]# rpm -ivh transmission/transmission-common-2.13-1.el6.x86_64.rpm
[root@gw1 ~]# rpm -ivh transmission/transmission-cli-2.13-1.el6.x86_64.rpm

[root@gw1 ~]# service transmission-daemon restart
[root@gw1 ~]# chkconfig transmission-daemon on

03. Set global speed restriction:
The daemon has to be stopped before making changes to the config file. Otherwise, the config file will be overwritten on daemon restart later. Unless performing a reload instead of restart.

[root@gw1 ~]# /etc/init.d/transmission-daemon stop

[root@gw1 ~]# vim /etc/init.d/transmission-daemon
DAEMON_ARGS="-g $TRANSMISSION_HOME/.config/transmission"
#DAEMON_ARGS="-T --blocklist -g $TRANSMISSION_HOME/.config/transmission"

[root@gw1 ~]# vim /var/lib/transmission/.config/transmission/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": true,
    "blocklist-url": "http://www.example.com/blocklist",
    "cache-size-mb": 2,
    "dht-enabled": true,
    "download-dir": "/storage/Downloads",
    "encryption": 1,
    "idle-seeding-limit": 30,
    "idle-seeding-limit-enabled": false,
    "incomplete-dir": "/storage/Downloads",            
    "incomplete-dir-enabled": false,
    "lazy-bitfield-enabled": true,
    "lpd-enabled": false,
    "message-level": 2,
    "open-file-limit": 32,
    "peer-limit-global": 240,
    "peer-limit-per-torrent": 60,
    "peer-port": 51413,
    "peer-port-random-high": 65535,
    "peer-port-random-low": 49152,
    "peer-port-random-on-start": false,
    "peer-socket-tos": 0,
    "pex-enabled": true,
    "port-forwarding-enabled": true,
    "preallocation": 1,
    "ratio-limit": 2,
    "ratio-limit-enabled": false,
    "rename-partial-files": true,
    "rpc-authentication-required": true,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-password": "your_password_here",
    "rpc-port": 9091,
    "rpc-username": "admin",
    "rpc-whitelist": "127.0.0.1",
    "rpc-whitelist-enabled": false,
    "script-torrent-done-enabled": false,
    "script-torrent-done-filename": "",
    "speed-limit-down": 100,
    "speed-limit-down-enabled": false,
    "speed-limit-up": 5,
    "speed-limit-up-enabled": true,
    "start-added-torrents": true,
    "trash-original-torrent-files": false,
    "umask": 18,
    "upload-slots-per-torrent": 14
}

[root@gw1 ~]# mkdir -p /storage/Downloads
[root@gw1 ~]# chown transmission.transmission /storage/Downloads
[root@gw1 ~]# chown transmission.transmission -R /storage/Downloads
[root@gw1 ~]# /etc/init.d/transmission-daemon start
                           
04. Start a download from Transmission-gui:
Edit-> Preferences -> Transmission Preferences -> Speed Limits/Alternative Speed Limits
Under Speed Limits/Alternative Speed Limits you can set what the max speed your data needs to be uploaded.

05. Start a download from command line:
[root@gw1 ~]#  /usr/bin/transmission-cli magnet:?xt=urn:btih:4d2220f8855996486033ff7b83f5e5d0ba863640&dn=New+Avengers+010+%282013%29+%28Digital%29+%28Zone-Empire%29&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337

To stop the transmission deamon use the below command:
[root@gw1 ~]# killall transmission-cli

To Resume the download:
[root@gw1 ~]# /usr/bin/transmission-cli /root/.config/transmission/torrents/StarCraft_2_HOTS.4be19f8ca99be826.torrent

Stop the download:
[root@gw1 ~]# killall transmission-cli

Download location:
[root@gw1 ~]# ls /storage/Downloads

06. Start a download from web interface:
Go to the transmission web interface.
http://localhost:9091
Username: admin
Password: web_password_here




07. Create new Torrent: 
Create a new torrent on the transmission server using transmission-create
[root@gw1 ~]# transmission-create -t -o .torrent
[root@gw1 ~]# transmission-create -t http://xxx.yyy.com:6969/announce -o your_file_or_folder_name.torrent your_file_or_folder

Verify the torrent file using transmission-show
[root@gw1 ~]# transmission-show .torrent

08. Download torrent file using cronjob:            

[root@gw Downloads]# crontab -e
# Minute   Hour   Day of Month       Month          Day of Week              Command
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)    command with full path

20      22      23      *       *       /usr/bin/killall transmission-cli
21      22      23      *       *       /usr/bin/transmission-cli magnet:?xt=urn:btih:4d2220f8855996486033ff7b83f5e5d0ba863640&dn=New+Avengers+010+%282013%29+%28Digital%29+%28Zone-Empire%29&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337

09. Troubleshooting: 
Error#01:
After restarting the transmission-daemon "settings.json" config back to previous state. Or sometimes only authentication reset to false.

Solution:
[root@gw1 ~]# vim /etc/init.d/transmission-daemon
DAEMON_ARGS="-g $TRANSMISSION_HOME/.config/transmission"
#DAEMON_ARGS="-T --blocklist -g $TRANSMISSION_HOME/.config/transmission"

Then stop the transmission-daemon, change your settings and start the transmission-daemon again. Problem solved.