Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / mantools / makepostconf
blob7aa741ab3f4bb40c7449db16ecf2a045193406e6
1 #!/usr/bin/perl
3 # Extract parameter definitions from the sample-mumble.cf files in
4 # order to build the postconf raw data file from which everything
5 # will be regenerated.
7 $POSTCONF="postconf";
9 # Suck in the parameter definition text. Skip non-parameter blocks.
10 # Strip all but the body text (i.e. strip off the non-comment line
11 # that shows the default, since we will use postconf output to supply
12 # the actual values).
14 while(<>) {
15 if (/^[^#]/) {
16 if ($param_name && $saved_text) {
17 $saved_text =~ s/^(\n|#|\s)+//;
18 $saved_text =~ s/(\n|#|\s)+$//;
19 $saved_text =~ s/^# ?/\n/;
20 $saved_text =~ s/\n# ?/\n/g;
21 $definition{$param_name} = $saved_text;
22 $param_name = $saved_text = "";
24 next;
26 if (/^#/ && $param_name) {
27 $saved_text .= $_;
28 next;
30 if (/^# The (\S+) (configuration )?parameter/) {
31 $param_name = $1;
32 $saved_text = $_;
36 # Read all the default parameter values. This also provides us with
37 # a list of all the parameters that postconf knows about.
39 open(POSTCONF, "$POSTCONF -d|") || die "cannot run $POSTCONF: !$\n";
40 while(<POSTCONF>) {
41 chop;
42 if (($name, $value) = split(/\s+=\s+/, $_, 2)) {
43 $defaults{$name} = $value;
44 } else {
45 warn "unexpected $POSTCONF output: $_\n";
48 close(POSTCONF) || die "$POSTCONF failed: $!\n";
50 # Print all parameter definition text that we found, and warn about
51 # missing definition text.
53 for $param_name (sort keys %defaults) {
54 if (defined($definition{$param_name})) {
55 print "#DEFINE $param_name\n\n";
56 print $definition{$param_name};
57 print "\n\n";
58 } else {
59 warn "No definition found for $param_name\n";