DNF アップデート後に任意のアクションを実行する方法

Dandified Yum Enterprise Linux 9
このサイトはアフィリエイト広告(Amazonアソシエイト含む)を掲載しています。
スポンサーリンク

dnf-automatic で夜間に更新を自動化していますが、アップデート後に毎回不具合がおこるため、後から手作業で対応しているアプリケーション(パッケージ)がありました。

DNF の post-transaction-actions プラグイン を使って、アップデートの後処理を自動化したので記録しておきます。

環境

  • OS:AlmaLinux release 9.6 (Sage Margay)
  • DNF:バージョン 4.14.0
  • ホスティング: ConoHa VPS(メモリ 2GB)
ConoHa VPS

アップデートで発生する不具合

OpenLiteSpeed(1.8.4-6)

アップデート後にサービスを再起動しないと、ウェブサイトが 503 エラーで見られない状態になる事態が連続して発生しました。

OpenLiteSpeed をアップデートしたら管理画面が認証不能になった場合の対処法
以前構築した OpenLiteSpeed ウェブサーバーが、dnf-automatic で夜間自動アップデートされたのですが、ウェブサイトにアクセスすると 503 エラー(Service Unavailable)を返して閲覧できない状態にな...

Rspamd(3.13)

設定ファイル置き場(/etc/rspamd/local.d/)の所有者が root に変更され、Web GUI(_rspamd ユーザー)から設定の保存ができない。

Red Hat Enterprise Linux 9 にメールサーバーを構築(後編)
前編では Postfix +Dovecot + PostfixAdmin の設定をしてきました。今回はそこに Rspamd による 迷惑メール対策、ClamAntiVirus によるウイルススキャンを連動させていこうと思います。スパムメール...

DNF プラグインの設定

プラグインをインストールする前に、導入されている DNF 関連パッケージの一覧を確認しておきます。

dnf -v repolist
(out) Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, kpatch, needs-restarting, notify-packagekit, playground, repoclosure, repodiff, repograph, repomanage, reposync, system-upgrade
(out) DNF version: 4.14.0

インストール

post-transaction-actions プラグインが入っていなかったので、インストールを実行します。パッケージ名は python3-dnf-plugin-post-transaction-actions でした。

dnf install python3-dnf-plugin-post-transaction-actions
(out) Dependencies resolved.
(out) ================================================================================================
(out)  Package                                         Arch       Version            Repository  Size
(out) ================================================================================================
(out) Installing:
(out)  python3-dnf-plugin-post-transaction-actions     noarch     4.3.0-20.el9       baseos      17 k
(out) 
(out) Transaction Summary
(out) ================================================================================================
(out) Install  1 Package
(out) 
(out) Total download size: 17 k
(out) Installed size: 14 k
(out) Is this ok [y/N]: y
(out) Downloading Packages:
(out) python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch 1.4 MB/s |  17 kB     00:00
(out) ------------------------------------------------------------------------------------------------
(out) Total                                                            27 kB/s |  17 kB     00:00
(out) Running transaction check
(out) Transaction check succeeded.
(out) Running transaction test
(out) Transaction test succeeded.
(out) Running transaction
(out)   Preparing        :                                                                        1/1
(out)   Installing       : python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch        1/1
(out)   Running scriptlet: python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch        1/1
(out)   Verifying        : python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch        1/1
(out) 
(out) Installed:
(out)   python3-dnf-plugin-post-transaction-actions-4.3.0-20.el9.noarch
(out) 
(out) Complete!

アクションファイルの作成

post-transaction-actions プラグインがインストールされると、/etc/dnf/plugins/post-transaction-actions.d/ ディレクトリが作られます。

このディレクトリ内にアクションファイル(.action)を配置する事で設定を行います。

アクションの書式

コロン(:)で区切って、パッケージ名トランザクションの状態コマンド の順に記述します。

トランザクションの状態には 3 種類あり、in・out・any のいずれかになります。

  • in:パッケージの追加(install・update・reinstall など)
  • out:パッケージの削除(remove など)
DNF post-transaction-actions Plugin — dnf-plugins-core 4.4.2-1 documentation

OpenLiteSpeed

openlitespeedin(upgrade)されたら、サービスを再起動します。

openlitespeed:in:/usr/bin/systemctl restart lshttpd.service

Rspamd

rspamdin(upgrade)されたら、設定用ディレクトリの所有権を変更します。

rspamd:in:/usr/bin/chown _rspamd:_rspamd /etc/rspamd/local.d/

3 番目のフィールド(2 番目のコロン以降)全体がコマンド扱いになるので、コマンドにコロン(:)が含まれていても問題ありません。

ConoHa VPS

コメント

タイトルとURLをコピーしました