]>
Commit | Line | Data |
---|---|---|
f872534d DM |
1 | #!/usr/bin/perl |
2 | ||
3 | use lib '.'; | |
4 | use strict; | |
5 | use warnings; | |
6 | use PVE::RESTHandler; | |
7 | ||
8 | use Data::Dumper; | |
9 | ||
10 | use PMG::Config; | |
11 | ||
12 | my $types = PMG::Config::Base->lookup_types; | |
13 | ||
7608b70c DM |
14 | my $single_section = shift; |
15 | my $found = 0; | |
16 | ||
cbb2b879 DM |
17 | my $skiped_keys = { |
18 | 'delete' => 1, | |
19 | digest => 1, | |
20 | }; | |
21 | ||
e09057ab | 22 | my $key_groups = { |
e3d778e0 DM |
23 | 'mail-options' => [ |
24 | 'mail' , { | |
25 | maxsize => 1, | |
26 | rejectunknown => 1, | |
27 | rejectunknownsender => 1, | |
28 | helotests => 1, | |
29 | dnsbl_sites => 1, | |
30 | verifyreceivers => 1, | |
31 | greylist => 1, | |
32 | spf => 1, | |
33 | hide_received => 1, | |
34 | dwarning => 1, | |
35 | conn_count_limit => 1, | |
36 | conn_rate_limit => 1, | |
37 | message_rate_limit => 1, | |
38 | banner => 1, | |
39 | }], | |
cbb2b879 DM |
40 | 'mail-tls' => [ |
41 | 'mail' , { | |
42 | tls => 1, | |
43 | tlsheader => 1, | |
44 | tlslog => 1, | |
45 | }], | |
d9c56b22 DM |
46 | 'mail-ports' => [ |
47 | 'mail' , { | |
48 | int_port => 1, | |
49 | ext_port => 1, | |
50 | }], | |
e09057ab DM |
51 | 'mail-relaying' => [ |
52 | 'mail' , { | |
53 | relay => 1, | |
54 | relaynomx => 1, | |
55 | relayport => 1, | |
56 | smarthost => 1, | |
57 | }], | |
58 | }; | |
59 | ||
cbb2b879 DM |
60 | if (1) { |
61 | # verify if we document all mail settings | |
62 | my $plugin = PMG::Config::Base->lookup('mail'); | |
63 | my $schema = $plugin->updateSchema(1); | |
64 | my $properties = $schema->{properties}; | |
65 | ||
66 | my $found_mail_keys = {}; | |
67 | foreach my $group (keys %$key_groups) { | |
68 | my ($sec, $hash) = @{$key_groups->{$group}}; | |
69 | next if $sec ne 'mail'; | |
70 | foreach my $k (keys %$hash) { | |
71 | die "unknown key '$k'" if !defined($properties->{$k}); | |
72 | $found_mail_keys->{$k} = 1; | |
73 | } | |
74 | } | |
75 | foreach my $k (keys %$properties) { | |
76 | next if $skiped_keys->{$k}; | |
77 | next if $k =~ m/^max_(filters|policy|smtpd_in|smtpd_out)$/; | |
78 | die "undocumented key '$k'" if !defined($found_mail_keys->{$k}); | |
79 | } | |
80 | } | |
81 | ||
82 | ||
e09057ab DM |
83 | my $select_keys; |
84 | ||
85 | if ($single_section) { | |
86 | if (my $a = $key_groups->{$single_section}) { | |
87 | my ($sec, $hash) = @$a; | |
88 | $single_section = $sec; | |
89 | $select_keys = $hash; | |
90 | } | |
91 | } | |
92 | ||
93 | ||
f872534d DM |
94 | foreach my $section (@$types) { |
95 | my $plugin = PMG::Config::Base->lookup($section); | |
96 | my $schema = $plugin->updateSchema(1); | |
97 | my $properties = $schema->{properties}; | |
7608b70c DM |
98 | |
99 | if (defined($single_section)) { | |
100 | next if $section ne $single_section; | |
101 | } else { | |
102 | print ".Section '$section'\n\n"; | |
103 | } | |
104 | ||
105 | $found = 1; | |
a18c67c0 DM |
106 | |
107 | my $filter = sub { | |
108 | my ($key, $phash) = @_; | |
cbb2b879 | 109 | return 1 if $skiped_keys->{$key}; |
e09057ab | 110 | return 1 if $select_keys && !$select_keys->{$key}; |
a18c67c0 DM |
111 | return 0; |
112 | }; | |
f872534d | 113 | |
a18c67c0 DM |
114 | print PVE::RESTHandler::dump_properties( |
115 | $properties, 'asciidoc', 'config', $filter); | |
f872534d | 116 | } |
7608b70c DM |
117 | |
118 | if (defined($single_section)) { | |
119 | die "no such section '$single_section'" if !$found; | |
120 | } | |
f872534d DM |
121 | |
122 | exit(0); |