read certificate data folder from acme.sh.env file, fixes #846
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -6,6 +6,7 @@ use Froxlor\Settings;
|
|||||||
use Froxlor\Database\Database;
|
use Froxlor\Database\Database;
|
||||||
use Froxlor\PhpHelper;
|
use Froxlor\PhpHelper;
|
||||||
use Froxlor\Domain\Domain;
|
use Froxlor\Domain\Domain;
|
||||||
|
use Froxlor\FileDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of the Froxlor project.
|
* This file is part of the Froxlor project.
|
||||||
@@ -490,7 +491,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
|
|
||||||
private static function checkFsFilesAreNewer($domain, $cert_date = 0)
|
private static function checkFsFilesAreNewer($domain, $cert_date = 0)
|
||||||
{
|
{
|
||||||
$certificate_folder = dirname(self::$acmesh) . "/" . $domain;
|
$certificate_folder = self::getWorkingDirFromEnv($domain);
|
||||||
if (Settings::Get('system.leecc') > 0) {
|
if (Settings::Get('system.leecc') > 0) {
|
||||||
$certificate_folder .= "_ecc";
|
$certificate_folder .= "_ecc";
|
||||||
}
|
}
|
||||||
@@ -506,6 +507,27 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getWorkingDirFromEnv($domain = "")
|
||||||
|
{
|
||||||
|
$env_file = FileDir::makeCorrectFile(dirname(self::$acmesh) . '/acme.sh.env');
|
||||||
|
if (file_exists($env_file)) {
|
||||||
|
$output = [];
|
||||||
|
$cut = <<<EOC
|
||||||
|
cut -d'"' -f2
|
||||||
|
EOC;
|
||||||
|
exec('grep "LE_WORKING_DIR" ' . escapeshellarg($env_file) . ' | ' . $cut, $output);
|
||||||
|
if (is_array($output) && ! empty($output) && isset($output[0]) && ! empty($output[0])) {
|
||||||
|
return FileDir::makeCorrectDir($output[0] . "/" . $domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FileDir::makeCorrectDir(dirname(self::$acmesh) . "/" . $domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAcmeSh()
|
||||||
|
{
|
||||||
|
return self::$acmesh;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get certificate files from filesystem and store in $return array
|
* get certificate files from filesystem and store in $return array
|
||||||
*
|
*
|
||||||
@@ -515,7 +537,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
*/
|
*/
|
||||||
private static function readCertificateToVar($domain, &$return, &$cronlog)
|
private static function readCertificateToVar($domain, &$return, &$cronlog)
|
||||||
{
|
{
|
||||||
$certificate_folder = dirname(self::$acmesh) . "/" . $domain;
|
$certificate_folder = self::getWorkingDirFromEnv($domain);
|
||||||
$certificate_folder_noecc = null;
|
$certificate_folder_noecc = null;
|
||||||
if (Settings::Get('system.leecc') > 0) {
|
if (Settings::Get('system.leecc') > 0) {
|
||||||
$certificate_folder_noecc = \Froxlor\FileDir::makeCorrectDir($certificate_folder);
|
$certificate_folder_noecc = \Froxlor\FileDir::makeCorrectDir($certificate_folder);
|
||||||
|
|||||||
@@ -329,9 +329,9 @@ class Domain
|
|||||||
public static function doLetsEncryptCleanUp($domainname = null)
|
public static function doLetsEncryptCleanUp($domainname = null)
|
||||||
{
|
{
|
||||||
// @ see \Froxlor\Cron\Http\LetsEncrypt\AcmeSh.php
|
// @ see \Froxlor\Cron\Http\LetsEncrypt\AcmeSh.php
|
||||||
$acmesh = "/root/.acme.sh/acme.sh";
|
$acmesh = \Froxlor\Cron\Http\LetsEncrypt\AcmeSh::getAcmeSh();
|
||||||
if (file_exists($acmesh)) {
|
if (file_exists($acmesh)) {
|
||||||
$certificate_folder = dirname($acmesh) . "/" . $domainname;
|
$certificate_folder = \Froxlor\Cron\Http\LetsEncrypt\AcmeSh::getWorkingDirFromEnv($domainname);
|
||||||
if (\Froxlor\Settings::Get('system.leecc') > 0) {
|
if (\Froxlor\Settings::Get('system.leecc') > 0) {
|
||||||
$certificate_folder .= "_ecc";
|
$certificate_folder .= "_ecc";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user