最近想把Alist和qbittorrent从OpenWRT旁路由转移到Ubuntu上以提高可维护性。Alist比较简单,用官方脚本装好恢复一下设置就行了,还自动添加了开机自启;qbittorrent就比较麻烦了,下面简单记录一下。

qBittorrent-nox安装

正常来讲的话是:

apt update  
apt install qbittorrent-nox

但这样的版本太老,我不太喜欢。
于是尝试编译,折腾了半天以失败告终。
之后发现Github上有已经编译好的,附上连接:
qBittorrent:
https://github.com/userdocs/qbittorrent-nox-static
qBittorrent-Enhanced-Edition:
https://github.com/c0re100/qBittorrent-Enhanced-Edition
按照readme中的步骤操作就行了,但我是要将文件下载到OpenWRT提供的smb网络磁盘中,使用普通用户qb在下载时会报Permission Denied错误,所以需要安装到root用户下:
1.将qBittorrent-nox文件下载到/root/bin文件夹下:

wget -qO root/bin/qbittorrent-nox https://github.com/userdocs/qbittorrent-nox-static/releases/latest/download/x86-qbittorrent-nox

2.将bin文件夹添加到.bashrc:

#通过修改.bashrc文件:
vim ~/.bashrc 
#在最后一行添上:
export PATH=/root/bin:$PATH
#生效方法:(有以下两种)
#1、关闭当前终端窗口,重新打开一个新终端窗口就能生效
#2、输入“source ~/.bashrc”命令,立即生效
#有效期限:永久有效
#用户局限:仅对当前用户

3.切换到root用户即可使用qBittorrent-nox命令,若需后台运行,则执行:

qBittorrent-nox -d

设置开机自启

不知道为什么,网上查到的很多方法都不好用,偶尔好用的也没法运行root的指令,下面提供一种有效的方法。

vim  /etc/systemd/system/qbittorrent-nox.service

输入以下文本保存:

[Unit]
Description=qBittorrent-nox
After=network.target

[Service]
User=root
Type=exec
Restart=always
RestartSec=5
ExecStart=/root/bin/qbittorrent-nox

[Install]
WantedBy=multi-user.target

输入以下命令启动 qbittorrent-nox 并创建服务配置:

systemctl start qbittorrent-nox  

设置开机自启:

systemctl enable qbittorrent-nox 

数据转移

  1. 由于有很多的设置和种子需要配置,因此直接转移配置文件。我openwrt中的qbittorrent配置文件存在/opt/qBittorrent文件夹中(我改过,初始应该不是这个位置),有data和config两个文件夹。
  2. 在复制之前可以修改config/qbittorrent.config文件,确保相关文件路径与目标系统匹配。
  3. 将data文件夹下的内容复制到/root/.local/share/qBittorrent文件夹下;将config文件夹下的内容复制到/root/.config/qBittorrent文件夹下即可。

参考文章:
安装qBittorrent-nox 并设置开机自启
linux可执行文件添加到PATH环境变量的方法Ubuntu
Linux 服务器安装 qBittorrent