Browse code

New article Download torrents on your server

Cinan Rakosnik authored on 26/12/2013 at 14:17:33
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,76 @@
0
+---
1
+layout: post
2
+title: "Download torrents on your server"
3
+date: 2013-12-25 22:34
4
+comments: true
5
+categories: [server]
6
+cover: /images/cover/avatar.png
7
+keywords: transmission, torrent, server, remote, rsync, firewall
8
+description: Setup transmission client on server
9
+---
10
+
11
+### tl;dr
12
+* How to setup Transmission client on your Linux server
13
+* Firewall setup
14
+* Email notifications setup
15
+
16
+# Why am I doing this?
17
+
18
+Recently I've needed to download some stuff from torrentz. I have quite
19
+unstable and slow internet connection at home, so I've decided to 
20
+download the stuff to my server and later transfer it to my laptop via
21
+rsync (with transfer resume enabled and high compression ratio).
22
+
23
+# Choose a torrent client
24
+
25
+There are [many](http://alinuxblog.wordpress.com/2010/09/14/top-10-torrent-clients-for-linux/)
26
+torrent clients suitable for headless Linux server (so they don't 
27
+need X.Org server and allow remote access). I've picked out [Transmission](http://www.transmissionbt.com/).
28
+It looks easy to configure & use, supports magnet links, is lightweight, 
29
+has web interface and is actively developed.
30
+
31
+# Install & configure
32
+
33
+If your Linux distribution provides split Transmission package, you need just
34
+transmission-cli or transmission-daemon (simply, ignore GTK or Qt packages).
35
+
36
+After installation edit Transmission daemon configuration file (may be located
37
+here ```/var/lib/transmission/.config/transmission-daemon/settings.json``` or 
38
+here ```/etc/init.d/transmission-daemon/settings.json```). 
39
+
40
+Interesting options you'll probably need to edit are these:
41
+
42
+* encryption: 2 (Require encrypted connections)
43
+* rpc-enabled: true (Required for Transmission web client)
44
+* rpc-password: "" (Put some password, after transmission-daemon restart it will be
45
+hashed)
46
+* rpc-port: 9091
47
+* rpc-whitelist-enabled: false (if you have dynamic public IP address you want disable this option)
48
+* umask: 0 (Give access to downloaded files to everybody -- files have read & write permissions for owner, group and others)
49
+
50
+If you're a bitch and want to disable seeding right after torrent download is completed,
51
+set ```ratio-limit``` to ```0``` and ```ratio-limit-enabled``` to ```true```.
52
+
53
+# Open ports in your firewall
54
+
55
+Find ```peer-port``` option in transmission config. Open this port in ```/etc/iptables/iptables.rules```:
56
+
57
+	-A INPUT -p tcp -m tcp --dport 51413 -j ACCEPT
58
+	-A OUTPUT -p tcp -m tcp --sport 51413 -j ACCEPT
59
+	-A OUTPUT -p udp -m udp --dport 80:60000 -j ACCEPT
60
+
61
+Port 51413 has to be opened otherwise Transmission cannot download and upload
62
+data. Also I've opened a range of UDP ports because of magnet links.
63
+
64
+# Hey! Downloading is finished!
65
+
66
+Transmission daemon can run any script after downloads are completed.
67
+First I've set ```script-torrent-done-enabled``` to ```true``` and inserted
68
+full path to the script into ```script-torrent-done-filename``` option.
69
+
70
+Here's my script:
71
+
72
+{% codeblock lang:bash %}
73
+#!/usr/bin/env bash
74
+echo "'$TR_TORRENT_NAME' is finished!" | gnu-mail -a "From: cinan.remote@gmail.com" -s "Torrent download finished" cinan6@gmail.com
75
+{% endcodeblock %}