feat(cli) : add certificate for domains WIP

This commit is contained in:
mrflos 2022-09-06 17:10:16 +03:00
parent 8a62a447a8
commit 521f5b6be8
2 changed files with 25 additions and 2 deletions

View file

@ -155,7 +155,17 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
$herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT)
);
}
echo 'DIR:'.dirname(__FILE__);
$subDomain = preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0);
if (!$subDomain) {
exec('acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 -w /home/'.$user.'/'.$domain, $output);
exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output);
exec('acme.sh --install-cert -d '.$domain.' --ecc \
--cert-file /etc/letsencrypt/live/'.$domain.'/cert.pem \
--key-file /etc/letsencrypt/live/'.$domain.'/key.pem \
--fullchain-file /etc/letsencrypt/live/'.$domain.'/fullchain.pem \
--ca-file /etc/letsencrypt/live/'.$domain.'/ca.pem \
--reloadcmd "systemctl restart nginx.service"', $output);
}
$templates = new League\Plates\Engine(dirname(__FILE__).'/templates');
file_put_contents(
$nginxFile,
@ -166,6 +176,7 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
'user' => $user,
'herseUser' => $herseUser,
'hersePass' => $hersePass,
'subdomain' => $subDomain,
]
)
);
@ -200,6 +211,10 @@ function copyYesWikiFiles($domain, $user)
{
$destDir = '/home'.'/'.$user.'/'.$domain;
exec('mkdir -p '.$destDir, $output);
exec('mkdir -p '.$destDir.'/cache', $output);
exec('mkdir -p '.$destDir.'/custom', $output);
exec('mkdir -p '.$destDir.'/files', $output);
exec('mkdir -p '.$destDir.'/files', $output);
// TODO : handle errors
return;
}