0%

Ubuntu18.04安装rTorrent

libtorrent

安装依赖

1
2
3
4
5
6
7
8
sudo apt install 
automake \
gcc \
g++ \
libtool \
pkg-config \
libcrypto++-dev \
libssl-dev

下载源代码并解压

1
2
wget http://rtorrent.net/downloads/libtorrent-0.13.8.tar.gz
tar zxvf libtorrent-0.13.8.tar.gz

编译安装

1
2
3
4
5
cd libtorrent-0.13.8
./autogen.sh
./configure
make -j4
sudo make install

rTorrent

安装依赖

1
2
3
4
5
sudo apt install 
libncurses-dev \
libxmlrpc-core-c3-dev \
libcurl4-openssl-dev \
libcurlpp-dev

下载源代码并解压

1
2
wget http://rtorrent.net/downloads/rtorrent-0.9.8.tar.gz
tar zxvf rtorrent-0.9.8.tar.gz

编译安装

1
2
3
4
5
cd rtorrent-0.9.8
./autogen.sh
./configure --with-xmlrpc-c --with-libcurl
make -j4
sudo make install

rTorrent配置文件

rTorrent的配置文件在~/.rtorrent.rc,在启动前,需要对rTorrent进行相关的配置,下面是我的配置,仅供参考。具体配置的相关教程请参考rTorrent配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#############################################################################
# A minimal rTorrent configuration that provides the basic features
# you want to have in addition to the built-in defaults.
#
# See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# for an up-to-date version.
#############################################################################


## Instance layout (base paths)
method.insert = cfg.basedir, private|const|string, (cat,"/home/rtorrent/rtorrent/")
method.insert = cfg.download, private|const|string, (cat,"/mnt/download/")
method.insert = cfg.logs, private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile, private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session, private|const|string, (cat,(cfg.basedir),".session/")
method.insert = cfg.watch, private|const|string, (cat,(cfg.basedir),"watch/")


## Create instance directories
execute.throw = sh, -c, (cat,\
"mkdir -p \"",(cfg.download),"\" ",\
"\"",(cfg.logs),"\" ",\
"\"",(cfg.session),"\" ",\
"\"",(cfg.watch),"/load\" ",\
"\"",(cfg.watch),"/start\" ")


## Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 50000-50000
network.port_random.set = no

## Tracker-less torrent and UDP tracker support
## (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = disable
protocol.pex.set = no

trackers.use_udp.set = yes


## Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250

throttle.global_up.max_rate.set = 131072
throttle.global_down.max_rate.set = 2097152

throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80

protocol.encryption.set = allow_incoming,try_outgoing,enable_retry


## Limits for file handle resources, this is optimized for
## an `ulimit` of 1024 (a common default). You MUST leave
## a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300


## Memory resource usage (increase if you have a large number of items loaded,
## and/or the available resources to spend)
pieces.memory.max.set = 4096M
network.xmlrpc.size_limit.set = 2M


## Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
"/tmp/rtorrent.pid", " ",(system.pid))


## Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
#pieces.hash.on_completion.set = no
#view.sort_current = seeding, greater=d.ratio=
#keys.layout.set = qwerty
#network.http.capath.set = "/etc/ssl/certs"
#network.http.ssl_verify_peer.set = 0
#network.http.ssl_verify_host.set = 0


## Some additional values and commands
method.insert = system.startup_time, value|const, (system.time)
method.insert = d.data_path, simple,\
"if=(d.is_multi_file),\
(cat, (d.directory), /),\
(cat, (d.directory), /, (d.name))"
method.insert = d.session_file, simple, "cat=(session.path), (d.hash), .torrent"


## Watch directories (add more as you like, but use unique schedule names)
## Add torrent
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))
## Add & download straight away
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))


## Run the rTorrent process as a daemon in the background
## (and control via XMLRPC sockets)
system.daemon.set = false
#network.scgi.open_local ="/tmp/rpc.socket"
#execute.nothrow = chmod,770,"/tmp/rpc.socket"
scgi_port = 127.0.0.1:5000

## Logging:
## Levels = critical error warn notice info debug
## Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "notice", "log"
#log.add_output = "tracker_debug", "log"

### END of rtorrent.rc ###

配置自动启动

将下方内容写入/etc/systemd/system/rtorrent.service,然后可以使用systemd在后台启动rtorrent,并可以通过tmux a -t rtorrent查看rtorrent的运行状态。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=rTorrent
Wants=network-online.target
After=network-online.target

[Service]
User=rtorrent
Group=rtorrent
Type=forking
PIDFile=/tmp/rtorrent.pid
ExecStart=/usr/bin/tmux new-session -s rtorrent -d /usr/local/bin/rtorrent
ExecStop=/usr/bin/tmux send-keys -t rtorrent C-q

[Install]
WantedBy=multi-user.target

Flood-UI

Flood-UI是一个现代化的rTorrent界面,用户可以使用web查看、操作rTorrent。

安装依赖

安装依赖需要注意,Ubuntu包管理中的nodejs版本比较低,若想使用最新版本的nodejs,请参考以下链接进行安装:NodeJS安装教程

1
2
3
4
5
6
7
8
9
# 配置安装nodejs 13.x
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs

# 安装其他依赖
sudo apt install \
git \
node-gyp \
mediainfo

下载源代码

1
git clone https://github.com/Flood-UI/flood.git

编译安装

1
2
3
4
5
cd flood
npm install
cp config.template.js config.js
vim config.js # 根据需要编辑配置文件
npm run-script build

启动flood

Flood-UI的默认地址为127.0.0.1:3000,如果需要修改,请在config.js中配置。

1
npm start

运行命令后,在浏览器访问127.0.0.1:3000,之后再网页中配置用户名及密码,rtorrent的cgi地址默认是127.0.0.1:5000,改配置在~/.rtorrent.rc中配置。