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

Regenerating package configuration non-interactively?



Hello,

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.

My best guess is: the noninteractive frontend is saying "nope, this setting has not been changed".

What I'm trying to avoid is duplicating all the config generation logic from the postinst script.  Whereas with postfix it would be a relatively simple job of writing out /etc/mailname and running "postconf" for a few settings, with other packages it's much more tricky (e.g. request-tracker4 is another one I'm working on)

So in summary: is there a general way for an already-installed package, to tell debconf either that specific setting(s) should be considered changed, or to reconfigure the package from scratch as if it were a new installation?

Thanks,

Brian.

P.S. The authoritative documentation I found was:

https://manpages.debian.org/testing/debconf-doc/debconf.7.en.html
https://manpages.debian.org/testing/debconf/dpkg-reconfigure.8.en.html
https://manpages.debian.org/testing/debconf-doc/debconf-devel.7.en.html

The latter mentions flags (FSET/FGET), and the "seen" flag in particular, but not the "changed" flag.


Reply to: