0%

重装树莓派系统

前言:树莓派不知道怎么的,很多服务都出问题了,虽然好像还能正常用,不过问题太大了,之前把树莓派当作主力机来使用的,装了太多冗余的东西了,直接重装。打算直接做nas了

设备:PI 4 8GB

系统:Debian 11 bullseye

前期准备

pt相关

把deluge的种子全部转移铺种到tr上

备份tr

备份transmission-daemon:

数据目录位于(apt安装的):

1
/var/lib/transmission-daemon/.config

复制一份

种子迁移:跳过校验

下载相关

备份aria2

备份aria2配置文件,以及service

我的配置文件位于用户目下的.aria2:/home/pi/.aria2

/etc/systemd/system/aria2.service

复制一份

局域网共享相关

smb备份

备份配置文件

配置文件位于:

1
/etc/samba

复制一份

脚本

python脚本备份

bash脚本备份

其余

crontab

latex

重装

镜像下载和系统启动:

2021-10-30-raspios-bullseye-arm64-lite

才注意到Debian版本换成了bullseye,升级换代了。

使用rpi-imager写入sd卡

然后写入错误。。。错误:数据错误(循环冗余检查)

这张卡用了很久了,一扫描果然出了坏道。唉,先屏蔽了凑合着用。。。新的sd卡还要几天才能到。。。

屏蔽完了,测试了一下

1
2
3
4
5
6
 *** 开始测试第 1 圈,共 1 圈 ***

位置 当前速度 平均速度 余量 剩余时间
正在写入 540 MB 3.22 MB/s 3.21 MB/s 29871 MB 02:34:55

无法向文件 F:\HUT00001.BIN 写入数据!

根本不能往里面写数据。。。

含泪使用switch的128g的内存卡,先备份一波switch。TT

写入成功后,为开启ssh功能

在sd卡的/boot上创建空白文件SSH

树莓派在局域网上的域名为:raspberrypi

终端SSH访问:

1
ssh pi@raspberrypi

出现提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:gYQNYVM3QMmcVj+stdH+2cXxo1EuQAz3aoLaMywTcXQ.
Please contact your system administrator.
Add correct host key in C:\\Users\\MY/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\MY/.ssh/known_hosts:4
ECDSA host key for raspberrypi has changed and you have requested strict checking.
Host key verification failed.

用个文本编辑器把用户目录下的.ssh/known_hosts的文件改了,我用的vscode

1
code .\.ssh\known_hosts

树莓派我之前绑定了ip:192.168.1.6,在known_hosts把有关于树莓派的都删了。

1
ssh pi@raspberrypi

默认密码是:raspberry

进入后第一件事就是改密码

1
sudo raspi-config

选择System Options->Password

然后改时区,Locaisation Options->Timezone->Asia->Shanghai

挂载备份盘

1
2
3
4
5
6
7
8
9
10
11
sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 117G 3.0G 110G 3% /
devtmpfs 3.7G 0 3.7G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 1.6G 908K 1.6G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/mmcblk0p1 253M 30M 223M 12% /boot
tmpfs 782M 24K 782M 1% /run/user/1000
/dev/sdb1 3.6T 3.4T 89G 98% /media/pi/84e82e54-9eb3-4645-9b5b-aa7347415905
/dev/sda1 7.3T 3.4T 3.6T 49% /media/pi/6cd86da0-3efc-41c4-adf8-34871490569c

先挂载磁盘分区/dev/sdb1

1
2
3
sudo mount /dev/sdb1 DiskShare/
cd DiskShare/
ls

换源

树莓派上版本了,所以原来备份的buster版本的就不能用了。。

换成清华源

Debian 镜像使用帮助

Debian 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件替换为下面内容,即可使用 TUNA 的软件源镜像。

如果遇到无法拉取 https 源的情况,请先使用 http 源并安装:

1
sudo apt install apt-transport-https ca-certificates

再使用 TUNA 的软件源镜像。


备份一下source.list再改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cp /etc/apt/sources.list ./
sudo nano /etc/apt/sources.list
# 把里面的内容换成

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

更新一下:

1
sudo apt update && sudo apt upgrade

安装v2rayA

先装v2ray

v2rayA 提供的镜像脚本(推荐):

1
curl -Ls https://mirrors.v2raya.org/go.sh | sudo bash

感觉有点满。。

安装后可以关掉服务,因为 v2rayA 不依赖于该 systemd 服务。

1
sudo systemctl disable v2ray --now ### Xray 需要替换服务为 xray

通过软件源安装v2rayA

添加公钥

1
wget -qO - https://apt.v2raya.mzz.pub/key/public-key.asc | sudo apt-key add -

添加 V2RayA 软件源

1
2
echo "deb https://apt.v2raya.mzz.pub/ v2raya main" | sudo tee /etc/apt/sources.list.d/v2raya.list
sudo apt update

安装 V2RayA

1
sudo apt install v2raya

启动 v2rayA / 设置 v2rayA 自动启动

启动:

1
sudo systemctl start v2raya.service

设置开机自动启动:

1
sudo systemctl enable v2raya.service

设置v2rayA

网页访问:http://raspberrypi:2017/

对于 Debian11 用户来说,iptables 已被弃用。使用 nftables 作为 iptables 的后端以进行适配:

1
2
3
4
update-alternatives --set iptables /usr/sbin/iptables-nft
update-alternatives --set ip6tables /usr/sbin/ip6tables-nft
update-alternatives --set arptables /usr/sbin/arptables-nft
update-alternatives --set ebtables /usr/sbin/ebtables-nft

如果你想切换回 legacy 版本:

1
2
3
4
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
update-alternatives --set arptables /usr/sbin/arptables-legacy
update-alternatives --set ebtables /usr/sbin/ebtables-legacy

切换后重启即可。

设置一下暂时代理:

1
2
export http_proxy=http://127.0.0.1:20172
export https_proxy=http://127.0.0.1:20172

安装smb

1
sudo apt install samba

还原配置

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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
sudo cp DiskShare/smb.conf /etc/samba/
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
# - When such options are commented with ";", the proposed setting
# differs from the default Samba behaviour
# - When commented with "#", the proposed setting is the default
# behaviour of Samba but the option is considered important
# enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
; interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself. However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
; bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
max log size = 1000

# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
# Append syslog@1 if you want important messages to be sent to syslog too.
logging = file

# Do something sensible when Samba crashes: mail the admin a backtrace
panic action = /usr/share/samba/panic-action %d


####### Authentication #######

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
server role = standalone server

obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
unix password sync = yes

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<[email protected]> for
# sending the correct chat script for the passwd program in Debian Sarge).
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
map to guest = bad user

########## Domains ###########

#
# The following settings only takes effect if 'server role = classic
# primary domain controller', 'server role = classic backup domain controller'
# or 'domain logons' is set
#

# It specifies the location of the user's
# profile directory from the client point of view) The following
# required a [profiles] share to be setup on the samba server (see
# below)
; logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
# logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
; logon drive = H:
# logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
; logon script = logon.cmd

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe. The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u

# This allows machine accounts to be created on the domain controller via the
# SAMR RPC pipe.
# The following assumes a "machines" group exists on the system
; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.
; add group script = /usr/sbin/addgroup --force-badname %g

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
; include = /home/samba/etc/smb.conf.%m

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
; idmap config * : backend = tdb
; idmap config * : range = 3000-7999
; idmap config YOURDOMAINHERE : backend = tdb
; idmap config YOURDOMAINHERE : range = 100000-999999
; template shell = /bin/bash

# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 means that usershare is disabled.
# usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
usershare allow guests = yes

#======================= Share Definitions =======================

[homes]
comment = Home Directories
browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = yes

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
valid users = %S

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
; comment = Network Logon Service
; path = /home/samba/netlogon
; guest ok = yes
; read only = yes

# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
; comment = Users profiles
; path = /home/samba/profiles
; guest ok = no
; browseable = no
; create mask = 0600
; directory mask = 0700

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
; write list = root, @lpadmin

[8T]
comment = Users profiles
path = /home/pi/share
guest ok = no
browseable = yes
writable = yes
create mask = 0777
directory mask = 0777
valid users = pi
[4T]
comment = Users profiles
path = /home/pi/DiskShare
guest ok = no
browseable = yes
writable = yes
create mask = 0777
directory mask = 0777
valid users = pi

添加用户

1
sudo smbpasswd -a pi
1
sudo systemctl reload smbd.service

编译安装transmission

目前不建议软件源安装

1
sudo apt install transmission-daemon

先检查一下版本。。。(我备份的是2.94)

1
2
transmission-daemon  -V
transmission-daemon 3.00 (bb6b5a062e)

。。。居然变成了3.00,还好升级兼容数据。。。但还是不建议使用3.0 (目前而言,很多pt站会把3.0当成被ban的客户端。。。u2甚至出现了:错误信息: No UA presents! (2)。)

下载源码

1
wget https://raw.githubusercontent.com/transmission/transmission-releases/master/transmission-2.94.tar.xz

下载依赖libevent-2.1-6 (>= 2.1.8-stable)dep: zlib1g (>= 1:1.1.4)

1
2
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz

编译安装

  1. 安装libevent

    1
    2
    3
    4
    5
    6
    tar zxf libevent-2.1.8-stable.tar.gz
    cd ./libevent-2.1.8-stable
    sudo ./configure
    sudo make
    sudo make install
    cd ..
  2. 安装zlib

    1
    2
    3
    4
    5
    6
    tar zxf zlib-1.2.11.tar.gz
    cd ./zlib-1.2.11
    sudo ./configure
    sudo make
    sudo make install
    cd ..
  3. 安装transmission 2.94

    1
    2
    3
    tar xvf transmission-2.94.tar.xz
    cd transmission-2.94
    sudo ./configure

    分割线下都是报错!谨慎按照分割线下的方法操作。(因为啥也不懂,直接乱来)


    结果报错

    No package ‘libcurl’ found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables LIBCURL_CFLAGS
    and LIBCURL_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

    找不到libcurl。阿哲,明明有装curl,先看一下在不在。

    1
    2
    3
    ldconfig -p | grep libcurl
    libcurl.so.4 (libc6,AArch64) => /lib/aarch64-linux-gnu/libcurl.so.4
    libcurl-gnutls.so.4 (libc6,AArch64) => /lib/aarch64-linux-gnu/libcurl-gnutls.so.4

    再检查一下curl

    1
    2
    3
    4
    5
    curl -confg --version
    curl 7.74.0 (aarch64-unknown-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3
    Release-Date: 2020-12-09
    Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
    Features: alt-svc AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

    我。。。。现在还不会配置./configure,再装一个curl

    先退出transmission 2.94安装目录

    1
    cd ..

    编译安装curl

    1
    2
    3
    4
    5
    6
    7
    8
    wget https://github.com/curl/curl/releases/download/curl-7_76_1/curl-7.76.1.tar.gz
    tar zxf curl-7.76.1.tar.gz
    cd curl-7.76.1/
    sudo ./configure
    sudo make
    sudo make install
    cd ..
    rm curl-7.76.1.tar.gz

    继续编译安装transmission 2.94

    1
    2
    cd transmission-2.94
    sudo ./configure

    结果又报错

    checking for OPENSSL… no
    checking for WOLFSSL… no
    checking for CYASSL… no
    checking for MBEDTLS… no
    checking polarssl/version.h usability… no
    checking polarssl/version.h presence… no
    checking for polarssl/version.h… no
    configure: error: Unable to find any supported crypto library.

    (这步不要尝试,下面的才是解决方法)我。。。。。再编译安装openssl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    cd ..
    wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz
    tar xf openssl-1.1.1l.tar.gz
    cd openssl-1.1.1l
    sudo ./configure
    sudo make
    sudo make install
    cd ..
    rm openssl-1.1.1l.tar.gz

    结果一看还是这个错误。。。查了一下资料。。

    The OpenSSL library is usually already installed, but you have to install the header files. Depending on your Linux distribution, you’ll need these packages:

    • Red Hat, Fedora, CentOS - openssl-devel
    • Debian, Ubuntu - libssl-dev
    • Arch - openssl
    1
    sudo apt install libssl-dev

    人裂开。。

    继续安装transmission报错

    ./configure: line 20079: intltool-update: command not found
    checking for intltool >= 0.35.0… found
    configure: error: Your intltool is too old. You need intltool 0.35.0 or later.

    1
    sudo apt install intltool

    继续装transmission去


    执行sudo ./configure后出现

    Configuration:

    Source code location: .
    Compiler: g++

    Build libtransmission: yes

    * optimized for low-resource systems:           no
    * µTP enabled:                                  yes
    * crypto library:                               openssl
    

    Build Command-Line client: no

    Build GTK+ client: no

    * libappindicator for an Ubuntu-style tray:     no
    

    Build Daemon: yes

    Build Mac client: no

    可以继续了

    1
    2
    3
    4
    sudo make
    sudo make install
    cd ..
    transmission-daemon -V

配置transmission服务

  1. 配置进程守护脚本

    1
    sudo nano /etc/systemd/system/transmission-daemon.service

    写入

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [Unit]
    Description=Transmission BitTorrent Daemon
    After=network.target

    [Service]
    User=root
    Type=notify
    ExecStart=/usr/bin/transmission-daemon -f --log-error
    NoNewPrivileges=true

    [Install]
    WantedBy=multi-user.target
  2. 配置 setting文件

    执行sudo systemctl start transmission后,会在/usr/local/share/transmission生成一个settings.json的配置文件

    先停止服务

    1
    2
    sudo systemctl stop transmission.service
    sudo nano /usr/local/share/transmission/settings.json

    还原数据

    1
    sudo cp -r DiskShare/.config/transmission-daemon/* /usr/local/share/transmission

    3.0降级为2.94,要手动跳检,以后写。手动跳过校验后还要注意修改曾经改过目录名的种子

    我是备份的apt安装的数据,所以还要还原设置

    1
    sudo cp DiskShare/transmission-daemon/setting.json /usr/local/share/transmission

    重新启动

    1
    2
    3
    sudo systemctl restart transmission
    ps -aux | grep transmission
    sudo /bin/kill -s HUP 889 # reload

    访问(如果你没有做特殊设置的话):http://raspberrypi:9091/

美化,安装transmission-web-control:

1
2
wget https://github.com/ronggang/transmission-web-control/raw/master/release/install-tr-control-cn.sh
sudo bash install-tr-control-cn.sh

安装Aria2

1
sudo apt install aria2

还原配置

1
2
mv DiskShare/aria2.service /etc/systemd/
mv DiskShare/.aria2/ ./

确认配置

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
cat .aria2/aria2.conf
## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##
## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##

## 文件保存相关 ##

# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=/home/pi/share/Aria2Download
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
disk-cache=32M
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
file-allocation=trunc
# 断点续传
continue=true

## 下载连接相关 ##

# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=5
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=5
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=5
# 整体下载速度限制, 运行时可修改, 默认:0
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0
#max-download-limit=0
# 整体上传速度限制, 运行时可修改, 默认:0
#max-overall-upload-limit=0
# 单个任务上传速度限制, 默认:0
#max-upload-limit=0
# 禁用IPv6, 默认:false
disable-ipv6=true

## 进度保存相关 ##

# 从会话文件中读取下载任务
input-file=/home/pi/.aria2/aria2.session
# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件
save-session=/home/pi/.aria2/aria2.session
# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
save-session-interval=60

## RPC相关设置 ##

# 启用RPC, 默认:false
enable-rpc=true
# 允许所有来源, 默认:false
rpc-allow-origin-all=true
# 允许非外部访问, 默认:false
rpc-listen-all=true
# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同
#event-poll=select
# RPC监听端口, 端口被占用时可以修改, 默认:6800
#rpc-listen-port=6800

## BT/PT下载相关 ##

# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true
#follow-torrent=true
# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999
listen-port=51417
# 单个种子最大连接数, 默认:55
#bt-max-peers=55
# 打开DHT功能, PT需要禁用, 默认:true
enable-dht=true
# 打开IPv6 DHT功能, PT需要禁用
#enable-dht6=false
# DHT网络监听端口, 默认:6881-6999
#dht-listen-port=6881-6999
# 本地节点查找, PT需要禁用, 默认:false
bt-enable-lpd=true
# 种子交换, PT需要禁用, 默认:true
enable-peer-exchange=true
# 每个种子限速, 对少种的PT很有用, 默认:50K
#bt-request-peer-speed-limit=50K
# 客户端伪装, PT需要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0
seed-ratio=0
# 强制保存会话, 话即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
#force-save=false
# BT校验相关, 默认:true
#bt-hash-check-seed=true
# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
bt-save-metadata=false

cat /etc/systemd/system/aria2.service
[Unit]

Description=qBittorrent-nox

After=network.target



[Service]

User=root

Type=forking

RemainAfterExit=yes

ExecStart=/usr/bin/aria2c --conf-path="/home/pi/.aria2/aria2.conf" -D



[Install]

WantedBy=multi-user.target

启动

1
sudo systemctl start aria2.service

查看是否成功

1
sudo systemctl status aria2.service

设置开机启动

1
sudo systemctl enable aria2.service

安装proxychains

为了更好的配置代理

1
2
3
4
5
6
git clone https://github.com/rofl0r/proxychains-ng.git
cd proxychains-ng/
./configure --prefix=/usr --sysconfdir=/etc
sudo make && sudo make install
sudo make install-config
sudo nano /etc/proxychains.conf

拉到最后一行

改成:

1
socks5  127.0.0.1 20170

v2rayA是这么配置的。

安装Flexget

先更新一下pip3的源

1
2
pip3 install pip -U
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装

1
pip3 install flexget

备份还原

1
mv DiskShare/.flexget/ ./

测试

1
2
pip3 install transmission-rpc #我配置文件写的是transmission
flexget --test execute

问题

1
2
WARNING: The script calc-prorate is installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

环境变量没设置

解决:

flexget的启动路径是在/home/pi/.local/bin,把它加到环境变量里面

1
2
echo 'export PATH=/home/pi/.local/bin:$PATH' >>~/.bashrc
source ~/.bashrc

配置Flexget

在当前用户目录下创建

1
2
mkdir .flexget
nano .flexget/config.yml

写入以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tasks:
Kimetsu_no_Yaiba-Mugen_Ressha_Hen:
rss: https://mikanani.me/RSS/Bangumi?bangumiId=2497&subgroupid=562 # pt rss 订阅地址
download: /home/pi/share/transmissionDownload # flexget 下载种子存放位置
transmission:
host: raspberrypi # transmission 主机ip
port: 9091 # transmission 端口
username: user # transmission 用户名
password: password # transmission 密码
content_size: # 识别文件体积
min: 100
max: 1000
strict: yes
# Flexget WebUI 设定,可以不改
web_server:
port: 6566
web_ui: yes
# base_url: /flexget
# base_url 是为了反代设置的,需要使用反代的话就取消这个的注释,然后在安装了 rTorrent 的情况下(不装 rt 的话没有 nginx)
# Flexget WebUI 地址就变成了 https://你盒子的 IP 地址/flexget
# 这里关闭 schedules 功能,也就是说没有启用 RSS,如何启用请看下文
schedules: no

测试是否正常

1
flexget --test  -c /home/pi/.flexget/config.yml execute

写入crontab

1
crontab -e

每周一,0-8点,每两小时执行一次

1
0 0-8/2 * * 1 /home/pi/.local/bin/flexget -c /home/pi/.flexget/config.yml --cron execute

更多详见

https://wiki.ukenn.top/seedbox-wiki-1/untitled-1

https://tool.lu/crontab/

其他

fstab开机挂载磁盘

先查看磁盘

1
sudo fdisk -l

找到对应Device

1
2
3
4
5
6
sudo nano /etc/fstab
# 后面加上
/dev/sda1 /home/pi/share ext4 defaults 1 1
/dev/sdb1 /home/pi/DiskShare ext4 defaults 1 1

sudo mount -a #测试

crontab任务