VPSをいくつか契約しています。システムのアップグレードは手動で行っています。
でも数日PCに触れないことなんかもあり最近の情勢からすると不安。ということでシステムの自動アップグレードを設定しました。
今回の対象はDebian trixie amd64環境。これまではapticronを動かしてパッケージの更新とダウンロードは自動化していました。
以前はcron-aptを使っていましたが、今回 unattended-upgradesを試してみました.
unattended-upgrades を導入
aptでunattended-upgradesを導入して設定します。
$ sudo apt install unattended-upgrades (1) $ sudo dpkg-reconfigure unattended-upgrades (2) Package configuration ┌───────────────────┤ Configuring unattended-upgrades ├───────────────────┐ │ │ │ Applying updates on a frequent basis is an important part of keeping │ │ systems secure. By default, updates need to be applied manually using │ │ package management tools. Alternatively, you can choose to have this │ │ system automatically download and install important updates. │ │ │ │ Automatically download and install stable updates? │ │ │ │ <Yes> <No> │ │ │ └─────────────────────────────────────────────────────────────────────────┘ Replacing config file /etc/apt/apt.conf.d/20auto-upgrades with new version $ cat /etc/apt/apt.conf.d/20auto-upgrades APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";
unattended-upgradesパッケージを導入
dpkg-reconfigure で
<Yes>を選択

メール通知を有効にする
$ sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
$ sudo git -C /etc diff /etc/apt/apt.conf.d/50unattended-upgrades
diff --git a/apt/apt.conf.d/50unattended-upgrades b/apt/apt.conf.d/50unattended-upgrades
index 26f84e133..007af9182 100644
--- a/apt/apt.conf.d/50unattended-upgrades
+++ b/apt/apt.conf.d/50unattended-upgrades
@@ -92,13 +92,13 @@ Unattended-Upgrade::Package-Blacklist {
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed. E.g. "user@example.com"
-//Unattended-Upgrade::Mail "";
+Unattended-Upgrade::Mail "user@example.com"; (1)
// Set this value to one of:
// "always", "only-on-error" or "on-change"
// If this is not set, then any legacy MailOnlyOnError (boolean) value
// is used to chose between "only-on-error" and "on-change"
-//Unattended-Upgrade::MailReport "on-change";
+Unattended-Upgrade::MailReport "always"; (2)
// Remove unused automatically installed kernel-related packages
// (kernel images, kernel headers and kernel version locked tools).
$ sudo unattended-upgrade --dry-run --debug (3)
$ sudo unattended-upgrade --debug通知を送るメールアドレス
実行舞に通知。しばらく動かしたら
on-changeに変更予定動作確認
apticronはアンインストール
$ sudo apt remove apticron
しばらく動かして見て問題なければ別のVPSにも反映しようと思います。
環境
$ dpkg-query -W unattended-upgrades unattended-upgrades 2.12 $ lsb_release -dr Description: Debian GNU/Linux 13 (trixie) Release: 13 $ arch x86_64
Reposts