Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 64851b7

Browse files
author
Jamie Snape
committed
Allow writable folder locations to be specified by environment vars
1 parent cfdb680 commit 64851b7

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

core/constant/global.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,24 @@
1919
=========================================================================*/
2020

2121
define('CORE_CONFIGS_PATH', BASE_PATH . '/core/configs');
22-
define('LOCAL_CONFIGS_PATH', CORE_CONFIGS_PATH);
23-
define('LOGS_PATH', BASE_PATH . '/log');
22+
23+
if(getenv('midas_local_configs_path') !== false)
24+
{
25+
define('LOCAL_CONFIGS_PATH', getenv('midas_local_configs_path'));
26+
}
27+
else
28+
{
29+
define('LOCAL_CONFIGS_PATH', CORE_CONFIGS_PATH);
30+
}
31+
32+
if(getenv('midas_logs_path') !== false)
33+
{
34+
define('LOGS_PATH', getenv('midas_logs_path'));
35+
}
36+
else
37+
{
38+
define('LOGS_PATH', BASE_PATH . '/log');
39+
}
2440

2541
if(file_exists(LOCAL_CONFIGS_PATH . '/core.local.ini'))
2642
{

core/controllers/components/UtilityComponent.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,14 @@ public static function getDataDirectory($subdir = '')
406406
}
407407
if(!isset($dataDirectory) || empty($dataDirectory))
408408
{
409-
$dataDirectory = BASE_PATH.'/data';
409+
if(getenv('midas_data_path') !== false)
410+
{
411+
$dataDirectory = getenv('midas_data_path');
412+
}
413+
else
414+
{
415+
$dataDirectory = BASE_PATH.'/data';
416+
}
410417
}
411418
if($subdir == '')
412419
{
@@ -441,7 +448,14 @@ public static function getTempDirectory($subdir = "misc")
441448
}
442449
if(!isset($tempDirectory) || empty($tempDirectory))
443450
{
444-
$tempDirectory = BASE_PATH.'/tmp';
451+
if(getenv('midas_temp_path') !== false)
452+
{
453+
$tempDirectory = getenv('midas_temp_path');
454+
}
455+
else
456+
{
457+
$tempDirectory = BASE_PATH.'/tmp';
458+
}
445459
}
446460
return $tempDirectory .'/'.$subdir.'/';
447461
}

0 commit comments

Comments
 (0)