]> git.proxmox.com Git - pmg-docs.git/blob - gen-pmg.conf.5-opts.pl
gen-pmg.conf.5: allow to overwrite undocumented key error for bootstrapping
[pmg-docs.git] / gen-pmg.conf.5-opts.pl
1 #!/usr/bin/perl
2
3 use lib '.';
4
5 use strict;
6 use warnings;
7
8 use PVE::RESTHandler;
9
10 use PMG::Config;
11
12 my $types = PMG::Config::Base->lookup_types;
13
14 my $single_section = shift;
15 my $found = 0;
16
17 my $skiped_keys = {
18 'delete' => 1,
19 digest => 1,
20 };
21
22 my $key_groups = {
23 'mail-options' => [
24 'mail' , {
25 maxsize => 1,
26 rejectunknown => 1,
27 rejectunknownsender => 1,
28 helotests => 1,
29 dnsbl_sites => 1,
30 dnsbl_threshold => 1,
31 verifyreceivers => 1,
32 greylist => 1,
33 spf => 1,
34 hide_received => 1,
35 dwarning => 1,
36 conn_count_limit => 1,
37 conn_rate_limit => 1,
38 message_rate_limit => 1,
39 banner => 1,
40 before_queue_filtering => 1,
41 ndr_on_block => 1,
42 }],
43 'mail-tls' => [
44 'mail' , {
45 tls => 1,
46 tlsheader => 1,
47 tlslog => 1,
48 }],
49 'mail-ports' => [
50 'mail' , {
51 int_port => 1,
52 ext_port => 1,
53 }],
54 'mail-relaying' => [
55 'mail' , {
56 relay => 1,
57 relaynomx => 1,
58 relayport => 1,
59 relayprotocol => 1,
60 smarthost => 1,
61 smarthostport => 1,
62 }],
63 'admin-dkim' => [
64 'admin' , {
65 dkim_selector => 1,
66 dkim_sign => 1,
67 dkim_sign_all_mail => 1,
68 }],
69 };
70
71 if (1) {
72 # verify if we document all mail settings
73 my $plugin = PMG::Config::Base->lookup('mail');
74 my $schema = $plugin->updateSchema(1);
75 my $properties = $schema->{properties};
76
77 my $found_mail_keys = {};
78 foreach my $group (keys %$key_groups) {
79 my ($sec, $hash) = @{$key_groups->{$group}};
80 next if $sec ne 'mail';
81 foreach my $k (keys %$hash) {
82 if (!defined($properties->{$k})) {
83 warn "\n WARNING: unknown key '$k'";
84 next;
85 }
86 $found_mail_keys->{$k} = 1;
87 }
88 }
89 foreach my $k (keys %$properties) {
90 next if $skiped_keys->{$k};
91 next if $k =~ m/^max_(filters|policy|smtpd_in|smtpd_out)$/;
92
93 if (!defined($found_mail_keys->{$k})) {
94 die "undocumented key '$k'" if !$ENV{PMG_DOCS_IGNORE_MISSING_KEY};
95 warn "WARNING: undocumented key '$k'\n";
96 }
97 }
98 }
99
100
101 my $select_keys;
102
103 if ($single_section) {
104 if (my $a = $key_groups->{$single_section}) {
105 my ($sec, $hash) = @$a;
106 $single_section = $sec;
107 $select_keys = $hash;
108 }
109 }
110
111
112 foreach my $section (@$types) {
113 my $plugin = PMG::Config::Base->lookup($section);
114 my $schema = $plugin->updateSchema(1);
115 my $properties = $schema->{properties};
116
117 if (defined($single_section)) {
118 next if $section ne $single_section;
119 } else {
120 print ".Section '$section'\n\n";
121 }
122
123 $found = 1;
124
125 my $filter = sub {
126 my ($key, $phash) = @_;
127 return 1 if $skiped_keys->{$key};
128 return 1 if $select_keys && !$select_keys->{$key};
129 return 0;
130 };
131
132 print PVE::RESTHandler::dump_properties(
133 $properties, 'asciidoc', 'config', $filter);
134 }
135
136 if (defined($single_section)) {
137 die "no such section '$single_section'" if !$found;
138 }
139
140 exit(0);