]> git.proxmox.com Git - pmg-docs.git/blob - gen-pmg.conf.5-opts.pl
1aff46ad4739f250fa0de5c988442e506111ec35
[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 greylistmask4 => 1,
34 greylist6 => 1,
35 greylistmask6 => 1,
36 spf => 1,
37 hide_received => 1,
38 dwarning => 1,
39 conn_count_limit => 1,
40 conn_rate_limit => 1,
41 message_rate_limit => 1,
42 banner => 1,
43 before_queue_filtering => 1,
44 ndr_on_block => 1,
45 smtputf8 => 1,
46 }],
47 'mail-tls' => [
48 'mail' , {
49 tls => 1,
50 tlsheader => 1,
51 tlslog => 1,
52 }],
53 'mail-ports' => [
54 'mail' , {
55 int_port => 1,
56 ext_port => 1,
57 }],
58 'mail-relaying' => [
59 'mail' , {
60 relay => 1,
61 relaynomx => 1,
62 relayport => 1,
63 relayprotocol => 1,
64 smarthost => 1,
65 smarthostport => 1,
66 }],
67 'admin-dkim' => [
68 'admin' , {
69 dkim_selector => 1,
70 dkim_sign => 1,
71 dkim_sign_all_mail => 1,
72 }],
73 };
74
75 if (1) {
76 # verify if we document all mail settings
77 my $plugin = PMG::Config::Base->lookup('mail');
78 my $schema = $plugin->updateSchema(1);
79 my $properties = $schema->{properties};
80
81 my $found_mail_keys = {};
82 foreach my $group (keys %$key_groups) {
83 my ($sec, $hash) = @{$key_groups->{$group}};
84 next if $sec ne 'mail';
85 foreach my $k (keys %$hash) {
86 if (!defined($properties->{$k})) {
87 warn "\n WARNING: unknown key '$k'";
88 next;
89 }
90 $found_mail_keys->{$k} = 1;
91 }
92 }
93 foreach my $k (keys %$properties) {
94 next if $skiped_keys->{$k};
95 next if $k =~ m/^max_(filters|policy|smtpd_in|smtpd_out)$/;
96
97 if (!defined($found_mail_keys->{$k})) {
98 die "undocumented key '$k'" if !$ENV{PMG_DOCS_IGNORE_MISSING_KEY};
99 warn "WARNING: undocumented key '$k'\n";
100 }
101 }
102 }
103
104
105 my $select_keys;
106
107 if ($single_section) {
108 if (my $a = $key_groups->{$single_section}) {
109 my ($sec, $hash) = @$a;
110 $single_section = $sec;
111 $select_keys = $hash;
112 }
113 }
114
115
116 foreach my $section (@$types) {
117 my $plugin = PMG::Config::Base->lookup($section);
118 my $schema = $plugin->updateSchema(1);
119 my $properties = $schema->{properties};
120
121 if (defined($single_section)) {
122 next if $section ne $single_section;
123 } else {
124 print ".Section '$section'\n\n";
125 }
126
127 $found = 1;
128
129 my $filter = sub {
130 my ($key, $phash) = @_;
131 return 1 if $skiped_keys->{$key};
132 return 1 if $select_keys && !$select_keys->{$key};
133 return 0;
134 };
135
136 print PVE::RESTHandler::dump_properties(
137 $properties, 'asciidoc', 'config', $filter);
138 }
139
140 if (defined($single_section)) {
141 die "no such section '$single_section'" if !$found;
142 }
143
144 exit(0);