File: makepostconf

package info (click to toggle)
postfix 3.10.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,976 kB
  • sloc: ansic: 134,721; makefile: 17,984; sh: 6,971; perl: 2,796; python: 1,448; awk: 158
file content (61 lines) | stat: -rwxr-xr-x 1,643 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl

# Extract parameter definitions from the sample-mumble.cf files in
# order to build the postconf raw data file from which everything
# will be regenerated.

$POSTCONF="postconf";

# Suck in the parameter definition text. Skip non-parameter blocks.
# Strip all but the body text (i.e. strip off the non-comment line
# that shows the default, since we will use postconf output to supply
# the actual values).

while(<>) {
    if (/^[^#]/) {
	if ($param_name && $saved_text) {
	    $saved_text =~ s/^(\n|#|\s)+//;
	    $saved_text =~ s/(\n|#|\s)+$//;
	    $saved_text =~ s/^# ?/\n/;
	    $saved_text =~ s/\n# ?/\n/g;
	    $definition{$param_name} = $saved_text;
	    $param_name = $saved_text = "";
	}
	next;
    }
    if (/^#/ && $param_name) {
	$saved_text .= $_;
	next;
    }
    if (/^# The (\S+) (configuration )?parameter/) {
	$param_name = $1;
	$saved_text = $_;
    }
}

# Read all the default parameter values. This also provides us with
# a list of all the parameters that postconf knows about.

open(POSTCONF, "$POSTCONF -d|") || die "cannot run $POSTCONF: !$\n";
while(<POSTCONF>) {
    chop;
    if (($name, $value) = split(/\s+=\s+/, $_, 2)) {
	$defaults{$name} = $value;
    } else {
	warn "unexpected $POSTCONF output: $_\n";
    }
}
close(POSTCONF) || die "$POSTCONF failed: $!\n"; 

# Print all parameter definition text that we found, and warn about
# missing definition text.

for $param_name (sort keys %defaults) {
   if (defined($definition{$param_name})) {
	print "#DEFINE $param_name\n\n";
	print $definition{$param_name};
	print "\n\n";
   } else {
	warn "No definition found for $param_name\n";
   }
}