[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Regenerating package configuration non-interactively?



Hi Brian,

Quoting Brian Candler (2019-09-30 13:08:23)
> After cloning virtual machines, I want to reconfigure packages in a 
> fully automated fashion.  In short, I've tried using 
> "debian-set-selections" followed by "dpkg-reconfigure -f 
> noninteractive", but it isn't actually changing the configuration.
> 
> Here's a concrete example.
> 
> Suppose I have installed postfix, preseeded in a particular way, then I 
> want to reconfigure it for a new hostname.  If I do the following 
> interactively:
> 
>      dpkg-reconfigure -p high postfix
> 
> then everything is fine: I get prompted with dialogs for the new mail 
> server configuration type and mailname, and then the relevant files get 
> updated and written out.
> 
>      root@foo1:~# dpkg-reconfigure -p high postfix
> *    changing /etc/mailname to foo2.lxd**
> **    setting myorigin**
> **    setting relayhost:**
> **    setting inet_interfaces: all*
> 
> *Postfix is now set up with the changes above.* If you need to make 
> changes, edit
>      /etc/postfix/main.cf (and others) as needed.  To view Postfix 
> configuration
>      values, see postconf(1).
> ...
> 
> Now I want to do this in a non-interactive script.  So I try:
> 
>      root@foo1:~# debconf-set-selections <<EOS
>      > postfix postfix/mailname string foo3.lxd
>      > EOS
>      root@foo1:~# dpkg-reconfigure -f noninteractive postfix
> 
> *    Postfix configuration was untouched.*  If you need to make changes, 
> edit
>      /etc/postfix/main.cf (and others) as needed.  To view Postfix 
> configuration
>      values, see postconf(1).
>      ...
> 
> Nothing is updated.  I have tried tracing the code through and I've 
> got stuck.  I can see these messages come from 
> /var/lib/dpkg/info/postfix.postinst.  It does some magic to check if a 
> particular attribute has changed (e.g. "db_fget postfix/mailname 
> changed").  The db_fget and db_fset functions are from 
> /usr/share/debconf/confmodule which is doing some very low-level 
> _db_cmd stuff.  It seems to be talking over FD 3 to set or test which 
> attributes have changed.

The missing piece is /var/lib/dpkg/postfix/config

Hope that helps you get further in your tracing what exactly debconf 
does with this particular package.

Nice and detailed yet dry (no interleaved cursing or other distractions) 
post.  Thanks!


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

Attachment: signature.asc
Description: signature


Reply to: