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

Re: debconf and program generated config



On Tue, Apr 05, 2005 at 02:57:32AM +0200, Michelle Konzack wrote:
> Hi,
> 
> Am 2005-04-04 20:08:45, schrieb Justin Pryzby:
> 
> >   templates: defines the interactive prompts
> >   config: this is a shell script which asks the questions defined by
> >     templates.  It handles things like "if you answer yes to X, then
> >     ask Y, but not if you answer no".  It exists such that the
> >     package can be "preconfigured" (otherwise config would just be in
> >     postinst).
> >   postinst: this is run after a packages files have been extracted.
> >     It should create any non-conffile configuration files.  It might
> >     read in some values from debconf to do so.
> 
> OK
> 
> > >   __( '/home/michelle.konzack/src/tddyndns-0.9.0/debian/postinst' )_____
> > >  /
> > > | #!/bin/sh -e
> > > | 
> > > | tddyndns >/dev/null 2>&1
> > This creates an initial config file?
> 
> If run as non debian package it output a message,
> that the $ADMIN should edit the file /etc/tddyndns.
> 
> Because I like to use debconf I suppress the output of the program.
Okay, as long as it fails if it should fail.  You might only redirect
stderr or only stdout as necessary, to allow for better diagnostics.
Or maybe |grep -v 'message you don't want'.

Or even |grep '.' && false if you want to assert that no output is
ever generated.

> > And then you have to modify that file based on dd_email_{to,from} and
> > dd_smtp_options?
> 
> yes
Okay.  You might also run the program once, and save that as a
template file in /usr/share/ and simply parse that in postinst.

But, in some sense, the program tddydyns is the "source" of the config
file, and so there is some argument for doing what you are doing.

> > Debconf is the thing that the config script does, and it is the thing
> > from which the postinst script will retrieve the values which you will
> > use to modify the configuration file (with sed, say).
> 
> I have copied the three files from "ssmtp" and modified it.
> Sniplet:
> 
>   __( '/home/michelle.konzack/src/tddyndns-0.9.0/debian/templates' )____
>  /
> | Template: tddyndns/dd_email_to
> | Type: string
> | Default: root
> | Description:The receiving E-Mail for the Notifications.
> |  You can supply more then one, but seperate it with a comma.
> | 
> | Template: tddyndns/dd_email_from
> | Type: string
> | Default: root
> | Description: Where the E-Mail seens to come from.
> <snip>
>  \______________________________________________________________________
> 
>   __( '/home/michelle.konzack/src/tddyndns-0.9.0/debian/config' )_______
>  /
> | #!/bin/sh -e
> | 
> | . /usr/share/debconf/confmodule
> | 
> | if [ -f /etc/tddyndns.conf ]
> | then
> |   for v in `grep -E "^(DD_EMAIL_TO|DD_EMAIL_FROM|DD_SMTP_OPTIONS|IP_SE
> | RVER|DD_ROUTER|DD_ROUTER_USER|DD_ROUTER_PASS|DD_ROUTER_IP|DD_USER|DD_P
> | ASS|DD_HOST|DD_SYSTEM|DD_WILDCARD|DD_MYIP|DD_OFFLINE|DD_MX|DD_BACKMX)=
> | " /etc/tddyndns.conf`
> |   do
> |     export $v
> |   done
> |   db_set tddyndns/dd_email_to     "$DD_EMAIL_TO"
> |   db_set tddyndns/dd_email_from   "$DD_EMAIL_FROM"
> |   db_set tddyndns/dd_smtp_options "$DD_SMTP_OPTIONS"
> |   db_set tddyndns/ip_server       "$IP_SERVER"
> <snip>
> | fi
> | 
> | db_input medium tddyndns/dd_email_to     || true
> | db_go
> | db_input medium tddyndns/dd_email_from   || true
> | db_go
> | db_input medium tddyndns/dd_smtp_options || true
> <snip>
> | # Program End
> | exit 0
>  \______________________________________________________________________
> 
> 
> So, because "config" read first the /etc/tddyndns.conf
> it use the given values as default ?
Yes, it seems so.  By "default", here, it means that if the user fails
to answer the debconf question, that is the value used.

But, the debconf default will be as specified in 'templates'.

> > Justin



Reply to: