Simple Torrent 是基于 Cloud Torrent 二开的应用程序,可以配置在服务器中作为远程下载器使用。搭配自身的 donecmd 功能可以调用外部命令实现下载完成后自动上传到 Onedrive 等网盘中。同时还具有 BT 加密下载、种子订阅等功能。

安装 Simple Torrent

在控制台执行

1
$ bash <(wget -qO- https://raw.githubusercontent.com/boypt/simple-torrent/master/scripts/quickinstall.sh)

即可完成安装,服务将运行在ip:3000端口上

管理 Simple Torrent

命令

1
2
3
4
$ systemctl start cloud-torrent      #启动程序
$ systemctl restart cloud-torrent #重启程序
$ systemctl stop cloud-torrent #停止程序
$ systemctl status cloud-torrent #查看状态

验证相关

在程序更新后可能会出现初始验证失效的情况,可以在/etc/systemd/system/cloud-torrent.service文件中修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Unit]
Description=Cloud torrent download manager
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=~
Environment=AUTH=user:ctorrent #验证内容,用户名:密码
Environment=PORT=3000
ExecStart=/usr/local/bin/cloud-torrent -c ./cloud-torrent.json --host 0.0.0.0 --disable-log-time
Restart=always
RestartPreventExitStatus=42
RestartSec=

[Install]
WantedBy=multi-user.target

修改完成后执行以下命令

1
2
$ systemctl daemon-reload
$ systemctl restart cloud-torrent

使用 Nginx 代理前端应用

在 Nginx 配置文件中写入以下内容

1
2
3
4
5
6
7
8
9
10
11
12
location / {
proxy_pass http://127.0.0.1:3000;
}

location /sync {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}

完整的 conf 配置文件如下

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
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate #;
ssl_certificate_key #;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EEC$
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name #;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
location / {
proxy_pass http://127.0.0.1:3000;
}
location /sync {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}

调用外部指令(配置自动上传)

创建一个调用脚本,up.sh,以下命令适用于 Rclone 挂载的 Onedrive 云盘

1
2
3
4
#!/bin/bash
if [[ ${CLD_TYPE} == "torrent" ]]; then
eval rclone move \'"${CLD_DIR}/${CLD_PATH}"\' "rc:update"; #此处的"rc:update"可按照rclone move命令自行修改远程目录
fi

给与脚本执行权限

1
$ chmod +x up.sh

配置 Simple Torrent 调用外部指令,修改配置文件cloud-torrent.json

1
2
#外部指令地址
"donecmd": "/root/up.sh", #填写刚才配置的脚本地址

重启服务完成设置

1
$ systemctl restart cloud-torrent