Merge pull request #3064 from Icinga/feature/var-lib-icingaweb2-2582
Implement ApplicationBootstrap::getStorageDir()
This commit is contained in:
commit
b3c1006eca
|
@ -77,6 +77,13 @@ abstract class ApplicationBootstrap
|
||||||
*/
|
*/
|
||||||
protected $configDir;
|
protected $configDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common storage directory
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $storageDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icinga class loader
|
* Icinga class loader
|
||||||
*
|
*
|
||||||
|
@ -122,10 +129,11 @@ abstract class ApplicationBootstrap
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $baseDir Icinga Web 2 base directory
|
* @param string $baseDir Icinga Web 2 base directory
|
||||||
* @param string $configDir Path to Icinga Web 2's configuration files
|
* @param string $configDir Path to Icinga Web 2's configuration files
|
||||||
|
* @param string $storageDir Path to Icinga Web 2's stored files
|
||||||
*/
|
*/
|
||||||
protected function __construct($baseDir = null, $configDir = null)
|
protected function __construct($baseDir = null, $configDir = null, $storageDir = null)
|
||||||
{
|
{
|
||||||
if ($baseDir === null) {
|
if ($baseDir === null) {
|
||||||
$baseDir = dirname($this->getBootstrapDirectory());
|
$baseDir = dirname($this->getBootstrapDirectory());
|
||||||
|
@ -148,6 +156,17 @@ abstract class ApplicationBootstrap
|
||||||
$canonical = realpath($configDir);
|
$canonical = realpath($configDir);
|
||||||
$this->configDir = $canonical ? $canonical : $configDir;
|
$this->configDir = $canonical ? $canonical : $configDir;
|
||||||
|
|
||||||
|
if ($storageDir === null) {
|
||||||
|
$storageDir = getenv('ICINGAWEB_STORAGEDIR');
|
||||||
|
if ($storageDir === false) {
|
||||||
|
$storageDir = Platform::isWindows()
|
||||||
|
? $baseDir . '/storage'
|
||||||
|
: '/var/lib/icingaweb2';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$canonical = realpath($storageDir);
|
||||||
|
$this->storageDir = $canonical ? $canonical : $storageDir;
|
||||||
|
|
||||||
set_include_path(
|
set_include_path(
|
||||||
implode(
|
implode(
|
||||||
PATH_SEPARATOR,
|
PATH_SEPARATOR,
|
||||||
|
@ -284,6 +303,18 @@ abstract class ApplicationBootstrap
|
||||||
return $this->getDirWithSubDir($this->configDir, $subDir);
|
return $this->getDirWithSubDir($this->configDir, $subDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the common storage directory
|
||||||
|
*
|
||||||
|
* @param string $subDir Optional sub directory to get
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStorageDir($subDir = null)
|
||||||
|
{
|
||||||
|
return $this->getDirWithSubDir($this->storageDir, $subDir);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Icinga library directory
|
* Get the Icinga library directory
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue