A dehydrated (ACME client) integration on SME Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
1009 B

{
use esmith::DomainsDB;
use esmith::HostsDB;
use List::MoreUtils qw(uniq);
my $d = esmith::DomainsDB->open_ro || die "Couldn't open DomainsDB\n";
my $h = esmith::HostsDB->open_ro || die "Couldn't open HostsDB\n";
my @names = ();
foreach my $domain ($d->domains, $d->get_all_by_prop(type => 'vhost')){
my $le = $domain->prop('Letsencrypt') || 'enabled';
next if ($le ne 'enabled');
if ($domain->key eq $DomainName){
unshift @names, $DomainName;
}
else{
push @names, $domain->key;
}
}
foreach my $host ($h->hosts){
my $name = $host->key;
my $dom = $DomainName;
if ($name =~ m/[a-z0-9]*\.(.*)/i){
$dom = $1;
}
my $type = $host->prop('HostType') || 'Self';
my $le = $host->prop('Letsencrypt') || 'default';
if ((($le =~ m/^enabled|yes|1|on$/i) && (($d->get_prop($d, 'Letsencrypt') || 'enabled') eq 'enabled')) ||
($type eq 'Self' && $dom eq $DomainName) && ($le !~ m/^disabled|no|0|off$/)){
push @names, $host->key;
}
}
$OUT .= join(" ", uniq(@names));
}