diff --git a/07.PVE制作TS服务器.md b/07.PVE制作TS服务器.md index d8016ed..0113664 100644 --- a/07.PVE制作TS服务器.md +++ b/07.PVE制作TS服务器.md @@ -128,7 +128,7 @@ $ sudo apt install unattended-upgrades powermgmt-base python3-gi ## 安装网络工具 $ sudo apt install iperf iperf3 iftop lsof knot-dnsutils dnsmasq conntrack -## 安装 Tailscale +## 安装 TS $ sudo apt install tailscale ## 写入磁盘 @@ -286,3 +286,105 @@ $ sudo systemctl restart systemd-timesyncd.service $ sudo systemctl status systemd-timesyncd.service ``` +### 1.7.配置自动更新 + +配置系统自动更新策略,执行以下命令,使用键盘 `左右方向键` 进行选择,`回车键` 进行确认。 + +```bash +## 配置自动更新策略 +$ sudo dpkg-reconfigure -plow unattended-upgrades + +## 选择 “是” (“YES”) + +#### 系统自动更新示例输出 +Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version +``` + +进一步调整 `20auto-upgrades` 配置文件。 + +```bash +## 编辑 20auto-upgrades 配置文件 +$ sudo nvim /etc/apt/apt.conf.d/20auto-upgrades +``` + +删除里面全部内容,添加以下配置项,并保存。 + +配置文件中,用来控制更新周期的参数为 `APT::Periodic::Unattended-Upgrade` ,`7` 表示更新周期为 `7` 天。 + +```bash +## 系统更新周期配置项 + +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "7"; +APT::Periodic::AutocleanInterval "1"; +APT::Periodic::CleanInterval "1"; + +``` + +进一步调整 `50unattended-upgrades` 配置文件。 + +```bash +## 编辑 50unattended-upgrades 配置文件 +$ sudo nvim /etc/apt/apt.conf.d/50unattended-upgrades +``` + +根据 “注释” 中相关说明,调整配置文件。 + +因为该配置文件很长,完整的配置文件可查看 [debian_ts_50unattended_upgrades.conf](./src/debian/debian_ts_50unattended_upgrades.conf) 以便对比。 + +```bash +## 删除以下行前面的注释符 // ,代表启用 + +"origin=Debian,codename=${distro_codename}-updates"; + +## 添加 TS 更新项目 + +"origin=Tailscale,codename=${distro_codename},label=Tailscale"; + +## 在配置文件末尾增加以下配置项,代表启用,并调整参数 + +Unattended-Upgrade::AutoFixInterruptedDpkg "true"; + +Unattended-Upgrade::Remove-Unused-Kernel-Packages "true"; + +Unattended-Upgrade::Remove-New-Unused-Dependencies "true"; + +Unattended-Upgrade::Remove-Unused-Dependencies "true"; + +Unattended-Upgrade::Automatic-Reboot "true"; + +Unattended-Upgrade::Automatic-Reboot-Time "03:00"; + +``` + +系统自动更新配置文件修改完成后,需要重设自动更新定时器,执行以下命令。 + +```bash +## 配置系统定时器 +$ sudo systemctl edit apt-daily-upgrade.timer +``` + +根据配置文件中的提示,在中间空白处填入以下配置项。 + +```bash +## 定时器配置项 + +[Timer] +OnCalendar= +OnCalendar=02:00 +RandomizedDelaySec=0 + +``` + +设置完成后,重启自动更新定时器并检查其状态,执行以下命令。 + +在输出结果中,看到系统自动更新的触发时间为 `02:00` 则表示设置正确。 + +```bash +## 重启触发器 +$ sudo systemctl restart apt-daily-upgrade.timer + +## 再次检查触发器状态 +$ sudo systemctl status apt-daily-upgrade.timer +``` +