非対話式でdpkg-reconfigureに入力値を提供する

非対話式でdpkg-reconfigureに入力値を提供する

dpkg-reconfigureでUbuntuパッケージを設定し、非対話モード(スクリプトで)で提供されるすべての値を使用したいと思います。

実際に私の場合はFirebird構成でした(http://www.firebirdsql.org/manual/ubusetup.html)、次のコマンドを使用する場合:

sudo dpkg-reconfigure firebird2.5-superclassic -freadline

2つの値を尋ねる質問に対する答えは「Y」と「newpwd」です。

サンプル出力は次のとおりです。

sudo dpkg-reconfigure firebird2.5-superclassic -freadline
 * Firebird 2.5 superclassic server not running
Configuring firebird2.5-superclassic
------------------------------------

Accept if you want Firebird server to start automatically.

If you only need the Firebird client and there are no databases that will be served by this host, decline.

Enable Firebird server? Y


Password for firebird 2.5
-------------------------

Firebird has a special user named SYSDBA, which is the user that has access to all databases. SYSDBA can also create new databases and users. Because of this, it 
is necessary to secure SYSDBA with a password.

The password is stored in /etc/firebird/2.5/SYSDBA.password (readable only by root). You may modify it there (don't forget to update the security database too, 
using the gsec utility), or you may use dpkg-reconfigure to update both.

To keep your existing password, leave this blank.

Password for SYSDBA: 


 * Starting Firebird 2.5 superclassic server...
   ...done.
 * Firebird 2.5 superclassic server already running

here strings次のようなbashスクリプトで試しました。

sudo dpkg-reconfigure firebird2.5-superclassic -f readline << EOF
Y
newpwd
EOF

しかし、何らかの理由でこれは機能せず、値を要求します。

スクリプトに必要な値を提供する方法についてのアイデアはありますか?

ベストアンサー1

Debian パッケージの使い方デブカンファレンスインストール時間設定を収集します。 Debconfは、ユーザーに値を求める複数のフロントエンドをサポートしています。使用する debconf フロントエンドを選択する-fオプションです。dpkg-reconfigure

フロントエンドはreadlineインタラクティブに使用するように設計されています。自動化されたスクリプトでは使用しないでください。

デフォルトが正しい場合はnoninteractiveフロントエンドを使用してください。

別の値を指定したい場合は、2つのオプションがあります。noninteractiveフロントエンドにこだわることができ、事前設定された debconf データベース。最も簡単な方法は、パッケージをコンピュータにインストールし、インタラクティブに構成し、関連する部分を抽出して/var/cache/debconf/config.datそのファイルをdebconfに提供することです。

DEBCONF_DB_OVERRIDE='File {/path/to/config.dat}' dpkg-reconfigure -fnoninteractive firebird2.5-superclassic

editor別のアプローチは、フロントエンドを使用し、現在の設定を含むファイルを引数として使用し、そのファイルを希望の設定で上書きするプログラムに環境変数VISUAL(またはEDITORすでに設定されている場合はVISUAL優先順位)を設定することです。EDITOR

おすすめ記事