On Sun, Nov 28, 1999 at 04:10:14AM -0500, Ivan E. Moore II wrote: > > realistically, every configuration file belongs to the system admin > > and MUST NOT be automatically overwritten without permission. > > ok...I'm working on the packages now..first is horde of course. Would the > following work or am I still missing something? > > Still using debconf. > asks the user if they want auto generation of config scripts via debconf > all this does is ask the q's via debconf and pull the values only > from the debconf database ignoring any templates. > if the above question is false then it pulls all values from a > horde.php3.in template file which must be manually edited as it by > default has defaults. :) > All config files will be automatically generated no matter what..either > from debconf values or from template files which will be marked as > conffiles and managable by admins.
not really. a template isn't just an example config, it's a sample config with tokens which get replaced by config values. the basic idea is that since configuration files are sacred (and so is the right/ability of the system admin to edit them by hand with the One True Editor<tm> of their choice), if you want to generate a config file and populate it with values pulled from a database then you must provide somewhere else for the system admin to do their customisations. your postinst script effectively has a template embedded in it (all those echo statements), but it's not very accessible...so the thing to do is to take the template out of the script and put it into a separate file which is processed with perl or sed or something to do global search and replace of the keyword tokens with the relevant values. this avoids the need to choose between debconf and hand-edited configuration (which is not a solution at all) - the sysadmin can modify the template however they like and their changes will remain after the next time the real config file is generated...and values will still be pulled out of debconf to 'fill in the blanks'. (it's usually a good idea to insert comments at the top of the generated file warning "DO NOT EDIT" and refer to the template file instead. also include brief instructions on how to generate the real conf from the template, or provide a Makefile or script which does it automatically) if you're using perl to configure it, you might want to look at the Text::Template module (packaged as libtext-template-perl). otherwise it's pretty easy to do with sed. a simple example with sed: $default->server = '__SERVER__'; $default->from_server = '__FROM_SERVER__'; $default->port = __PORT__; $default->servtype = '__SERVTYPE__'; pipe that through something like : sed -e 's/__SERVER__/$server/g' -e 's/__FROM_SERVER__/$from_server/g' \ -e 's/__PORT__/$port/g' -e 's/__SERVTYPE__/$servtype/g' doing it with sed is fine when you've only got a handful of variables to replace, but it gets clumsy with a lot of them...better to use plain perl or perl with Text::Template. Text::Template provides a good framework for doing this kind of thing very easily. btw, the libtext-template-perl package has a reasonable description of what a template is: This is a library for generating form letters, building HTML pages, or filling in templates generally. A `template' is a piece of text that has little Perl programs embedded in it here and there. When you `fill in' a template, you evaluate the little programs and replace them with their values. the only thing i'd add to that is that the "little programs" usually consist of just a $variable name (perl vars return their value when evaluated)....but you can do more complex stuff (loops, if/then/else, etc) if required. craig -- craig sanders