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