]>
Commit | Line | Data |
---|---|---|
895b703e TL |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use lib '../'; | |
7 | ||
4195bf0a TL |
8 | use JSON; |
9 | ||
10 | use PVE::Tools qw(dir_glob_foreach file_get_contents); | |
895b703e TL |
11 | |
12 | my $dnsapi_path = '../acme.sh/dnsapi'; | |
13 | ||
14 | die "cannot find dnsapi path '$dnsapi_path'!\n" if ! -d $dnsapi_path; | |
15 | ||
16 | my $acmesh_plugins = []; | |
17 | dir_glob_foreach($dnsapi_path, qr/dns_(\S+)\.sh/, sub { | |
18 | my ($file, $provider) = @_; | |
19 | push @$acmesh_plugins, $provider; | |
20 | }); | |
21 | ||
4195bf0a TL |
22 | my $DNS_API_CHALLENGE_SCHEMA_FN = '../dns-challenge-schema.json'; |
23 | my $defined_plugins = from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN)); | |
895b703e | 24 | |
a02aae50 TL |
25 | my ($missing_json_proposal, $missing_makefile_proposal) = ('', ''); |
26 | ||
4195bf0a | 27 | my $ok = 1; |
895b703e | 28 | # first check for missing ones, delete from hash so we can easily see if a plug got removed/renamed |
895b703e TL |
29 | for my $provider (sort @$acmesh_plugins) { |
30 | my $schema = delete $defined_plugins->{$provider}; | |
31 | if (!defined($schema)) { | |
a02aae50 TL |
32 | $missing_json_proposal .= " \"$provider\": {},\n"; |
33 | $missing_makefile_proposal .= "\tdnsapi/dns_${provider}.sh \\\n"; | |
895b703e TL |
34 | $ok = 0; |
35 | } | |
36 | } | |
37 | ||
a02aae50 TL |
38 | if (!$ok) { |
39 | print STDERR "\nmissing plugins, add the following to the JSON schema:\n"; | |
40 | print STDERR $missing_json_proposal; | |
41 | ||
42 | print STDERR "\nand to the Makefile:\n"; | |
43 | print STDERR $missing_makefile_proposal; | |
44 | } | |
45 | ||
895b703e TL |
46 | my $printed_extra = 0; |
47 | for my $provider (sort keys %$defined_plugins) { | |
28e3b59f | 48 | print STDERR "\nplugins that got removed or renamed upstream:\n" if !$printed_extra; |
895b703e TL |
49 | print STDERR " $provider\n"; |
50 | $printed_extra = 1; | |
51 | $ok = 0; | |
52 | } | |
53 | ||
28e3b59f | 54 | die "\nERROR: schema not in sync with available plugins!\n\n" if !$ok; |
895b703e TL |
55 | |
56 | print STDERR "OK: DNS challenge schema in sync with available plugins.\n"; | |
57 | exit(0); |