1 #!/usr/bin/perl 2 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. 6 7 $POSTCONF="postconf"; 8 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). 13 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 = ""; 23 } 24 next; 25 } 26 if (/^#/ && $param_name) { 27 $saved_text .= $_; 28 next; 29 } 30 if (/^# The (\S+) (configuration )?parameter/) { 31 $param_name = $1; 32 $saved_text = $_; 33 } 34 } 35 36 # Read all the default parameter values. This also provides us with 37 # a list of all the parameters that postconf knows about. 38 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"; 46 } 47 } 48 close(POSTCONF) || die "$POSTCONF failed: $!\n"; 49 50 # Print all parameter definition text that we found, and warn about 51 # missing definition text. 52 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"; 60 } 61 } 62