Added config logs.path and cache.path to improve custom data structure.

Benefits cPanel integration #697
This commit is contained in:
the-djmaze 2022-11-25 08:19:44 +01:00
parent 2634edd842
commit dee6f6af7e
4 changed files with 16 additions and 7 deletions

View file

@ -509,7 +509,10 @@ class Actions
switch (true) { switch (true) {
default: default:
case $bForceFile: case $bForceFile:
$oDriver = new \MailSo\Cache\Drivers\File(APP_PRIVATE_DATA . 'cache', $sKey); $oDriver = new \MailSo\Cache\Drivers\File(
\trim($this->oConfig->Get('cache', 'path', APP_PRIVATE_DATA . 'cache')),
$sKey
);
break; break;
case ('APCU' === $sDriver) && case ('APCU' === $sDriver) &&
@ -566,8 +569,8 @@ class Actions
if ($this->oConfig->Get('logs', 'auth_logging', false)) { if ($this->oConfig->Get('logs', 'auth_logging', false)) {
// $this->oLoggerAuth->SetLevel(\LOG_WARNING); // $this->oLoggerAuth->SetLevel(\LOG_WARNING);
$sAuthLogFileFullPath = \APP_PRIVATE_DATA . 'logs/' . $this->compileLogFileName( $sAuthLogFileFullPath = \trim($this->oConfig->Get('logs', 'path', \APP_PRIVATE_DATA . 'logs'))
$this->oConfig->Get('logs', 'auth_logging_filename', '')); . '/' . $this->compileLogFileName($this->oConfig->Get('logs', 'auth_logging_filename', ''));
$sLogFileDir = \dirname($sAuthLogFileFullPath); $sLogFileDir = \dirname($sAuthLogFileFullPath);
if (!\is_dir($sLogFileDir)) { if (!\is_dir($sLogFileDir)) {
\mkdir($sLogFileDir, 0755, true); \mkdir($sLogFileDir, 0755, true);

View file

@ -283,6 +283,8 @@ Values:
'enable' => array(false, 'Enable logging'), 'enable' => array(false, 'Enable logging'),
'path' => array('', 'Path where log files will be stored'),
'level' => array(4, 'Log messages of set RFC 5424 section 6.2.1 Severity level and higher (0 = highest, 7 = lowest). 'level' => array(4, 'Log messages of set RFC 5424 section 6.2.1 Severity level and higher (0 = highest, 7 = lowest).
0 = Emergency 0 = Emergency
1 = Alert 1 = Alert
@ -343,6 +345,8 @@ Examples:
Enables caching in the system'), Enables caching in the system'),
'path' => array('', 'Path where cache files will be stored'),
'index' => array('v1', 'Additional caching key. If changed, cache is purged'), 'index' => array('v1', 'Additional caching key. If changed, cache is purged'),
'fast_cache_driver' => array('files', 'Can be: files, APCU, memcache, redis (beta)'), 'fast_cache_driver' => array('files', 'Can be: files, APCU, memcache, redis (beta)'),

View file

@ -13,6 +13,8 @@ if (defined('APP_PLUGINS_PATH') && !empty($_ENV['CPANEL']) && !is_dir(APP_PLUGIN
$oConfig->Set('plugins', 'enable', true); $oConfig->Set('plugins', 'enable', true);
$oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList))); $oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList)));
$oConfig->Set('login', 'default_domain', 'cpanel'); $oConfig->Set('login', 'default_domain', 'cpanel');
$oConfig->Set('logs', 'path', $_ENV['HOME'] . '/logs/snappymail');
$oConfig->Set('cache', 'path', $_ENV['HOME'] . '/tmp/snappymail');
$oConfig->Save(); $oConfig->Save();
$sFile = APP_PRIVATE_DATA.'domains/cpanel.json'; $sFile = APP_PRIVATE_DATA.'domains/cpanel.json';

View file

@ -55,8 +55,7 @@ date_default_timezone_set('UTC');
$sCustomDataPath = ''; $sCustomDataPath = '';
$sCustomConfiguration = ''; $sCustomConfiguration = '';
if (is_file(APP_INDEX_ROOT_PATH.'include.php')) if (is_file(APP_INDEX_ROOT_PATH.'include.php')) {
{
include_once APP_INDEX_ROOT_PATH.'include.php'; include_once APP_INDEX_ROOT_PATH.'include.php';
} }
@ -72,8 +71,9 @@ unset($sPrivateDataFolderInternalName);
if (!defined('APP_DATA_FOLDER_PATH')) { if (!defined('APP_DATA_FOLDER_PATH')) {
// cPanel https://github.com/the-djmaze/snappymail/issues/697 // cPanel https://github.com/the-djmaze/snappymail/issues/697
if (!empty($_ENV['CPANEL']) && isset($_ENV['TMPDIR'])) { if (!empty($_ENV['CPANEL']) && isset($_ENV['HOME'])) {
$sCustomDataPath = $_ENV['TMPDIR'] . '/snappymail'; $sCustomDataPath = $_ENV['HOME'] . '/var/snappymail';
// $sCustomDataPath = $_ENV['TMPDIR'] . '/snappymail';
} else { } else {
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath; $sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
} }