diff --git a/templates/nginx-maindomain.php b/templates/nginx-maindomain.php index 9924b96..55a91d3 100644 --- a/templates/nginx-maindomain.php +++ b/templates/nginx-maindomain.php @@ -18,7 +18,9 @@ server { server_name www.e($domain)?>; include h5bp/tls/ssl_engine.conf; - include h5bp/tls/certificate_files.conf; + ssl_certificate /etc/letsencrypt/live/e($domain)?>/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/e($domain)?>/key.pem; + ssl_trusted_certificate /etc/letsencrypt/live/e($domain)?>/ca.pem; include h5bp/tls/policy_strict.conf; return 301 $scheme://e($domain)?>$request_uri; @@ -33,7 +35,13 @@ server { server_name e($domain)?>; include h5bp/tls/ssl_engine.conf; + include h5bp/tls/certificate_files.conf; + + ssl_certificate /etc/letsencrypt/live/e($domain)?>/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/e($domain)?>/key.pem; + ssl_trusted_certificate /etc/letsencrypt/live/e($domain)?>/ca.pem; + include h5bp/tls/policy_strict.conf; # Path for static files diff --git a/utils.inc.php b/utils.inc.php index b971c73..b7f958f 100644 --- a/utils.inc.php +++ b/utils.inc.php @@ -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; }