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