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.
 
 

34 lines
972 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 = ( "$DomainName" );
foreach my $domain ($d->domains, $d->get_all_by_prop(type => 'vhost')){
next if ($domain->key eq $DomainName);
my $le = $domain->prop('Letsencrypt') || 'enabled';
push @names, $domain->key unless $le ne 'enabled';
}
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));
}