Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 21 additions & 6 deletions Lib/GetSslConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Modules\ModuleGetSsl\Lib;

use MikoPBX\Common\Models\LanInterfaces;
use MikoPBX\Core\System\PBX;
use MikoPBX\Core\System\Processes;
use MikoPBX\Core\System\Util;
use MikoPBX\Modules\Config\ConfigClass;
Expand Down Expand Up @@ -120,9 +121,13 @@ public function onAfterPbxStarted(): void
Util::createUpdateSymlink($busyBoxPath, self::NS_LOOKUP_BIN, true);

}

Processes::mwExec("{$mountPath} -o remount,ro /offload 2> /dev/null");
file_put_contents("$confDir/getssl.cfg", $conf);
$extHostname = $this->getHostname();

file_put_contents("$confDir/$extHostname/getssl.cfg", $conf);
if(!empty($extHostname)){
Util::createUpdateSymlink("$confDir/getssl.cfg", "$confDir/$extHostname/getssl.cfg", true);
}
}

/**
Expand All @@ -146,6 +151,7 @@ public function onAfterModuleDisable(): void
public function onAfterModuleEnable(): void
{
$this->onAfterPbxStarted();
PBX::managerReload();
}

/**
Expand All @@ -160,7 +166,7 @@ public function createCronTasks(&$tasks): void
}
$workerPath = $this->moduleDir.'/db/getssl';
$getSslPath = self::GET_SSL_BIN;
$tasks[] = "0 1 * * * {$getSslPath} -a -u -q -w '$workerPath' > /dev/null 2> /dev/null".PHP_EOL;
$tasks[] = "0 1 * * * {$getSslPath} -a -U -q -w '$workerPath' > /dev/null 2> /dev/null".PHP_EOL;
}

/**
Expand All @@ -178,9 +184,8 @@ public function getModuleDir():string
*/
public function startGetCertSsl():PBXApiResult
{
$result = new PBXApiResult();
$res = LanInterfaces::findFirst("internet = '1'")->toArray();
$extHostname = $res['exthostname']??'';
$result = new PBXApiResult();
$extHostname = $this->getHostname();

if(empty($extHostname)){
// Имя хост не заполнено.
Expand All @@ -197,6 +202,7 @@ public function startGetCertSsl():PBXApiResult
$result->data = [
'pid' => $pid
];
PBX::managerReload();
$result->success = true;
return $result;
}
Expand Down Expand Up @@ -225,4 +231,13 @@ public function checkResult():PBXApiResult
return $result;
}

/**
* Возвращает имя хост.
* @return string
*/
private function getHostname():string
{
$res = LanInterfaces::findFirst("internet = '1'")->toArray();
return $res['exthostname']??'';
}
}
Loading