Call Certbot before adding to DB

This commit is contained in:
Miraty 2023-05-04 02:20:29 +02:00
parent 13bfd8e9be
commit f3752163af

View file

@ -30,12 +30,12 @@ checkAuthToken($matches[1], $matches[2]);
rateLimit();
addSite($_SESSION['id'], $_POST['dir'], $_POST['domain'], 'dns');
exec('2>&1 ' . CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' certonly' . (($_SESSION['type'] === 'approved') ? '' : ' --test-cert') . ' --domain ' . $_POST['domain'], $output, $returnCode);
if ($returnCode !== 0)
output(500, 'Certbot failed to get a Let\'s Encrypt certificate.', $output);
addSite($_SESSION['id'], $_POST['dir'], $_POST['domain'], 'dns');
htRelativeSymlink('../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . $_POST['domain']);
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));