Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search certificates for sub domains during dns reload #30

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/usr/lib/alternc/reload.d/alternc-certbot
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,32 @@ $admin->enabled=1;

if ($argv[1] == "dns_reload_zone" && !empty($argv[2])) {
$domain_name = $argv[2];
$info = $dom->get_sub_domain_id_and_member_by_name($domain_name);

$err->log("certbot", "dns_reload_zone ".$domain_name);

$mem->su($info['member_id']);
$db->query('select id, compte from domaines where domaine = ?',
array($domain_name));
if (!$db->next_record()) {
$err->log('certbot', 'reload.d - dns_reload_z<one - Unable to find domain information for ' . $domain_name);
exit -1;
}
$mem->su($db->f('compte'));

$dom->lock();
$domains = $dom->get_domain_all($domain_name);
$sub_domains = array();
$certbot->import($domain_name);
// Build a list of fqdns to import, excluding dns only entries.
// This reduces repeat calls to import for duplicate sub domains.
foreach ($domains['sub'] as $index => $sub_domain) {
if (!$sub_domain['name'] || $sub_domain['only_dns']) {
continue;
}
$fqdn = "${sub_domain['name']}.${domain_name}";
if (!in_array($fqdn, $sub_domains)) {
$sub_domains[] = $fqdn;
}
}
foreach ($sub_domains as $fqdn) {
$certbot->import($fqdn);
}
$dom->unlock();

$mem->unsu();
}
2 changes: 1 addition & 1 deletion src/usr/share/alternc/panel/class/m_certbot.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function import($fqdn)

$output = array();
$return_var = -1;
exec("certbot --agree-tos --non-interactive --webroot -w /var/lib/letsencrypt/ certonly -d ".$fqdn." 2>/dev/null", $output, $return_var);
exec("certbot --agree-tos --non-interactive --webroot -w /var/lib/letsencrypt/ certonly -d ".$fqdn." 2>&1", $output, $return_var);

// Add certificate to panel
if ($return_var == 0) {
Expand Down