Skip to content
Open
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
4 changes: 4 additions & 0 deletions etc/apache2-nagvis.conf-sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Alias @NAGVIS_WEB@ "@NAGVIS_PATH@"

<Directory "@NAGVIS_PATH@">

# If want to customize config location
#SetEnv NAGVIS_CONFIG "@NAGVIS_PATH@/../etc/nagvis.ini.php"

Options FollowSymLinks
AllowOverride None

Expand Down
2 changes: 2 additions & 0 deletions etc/nagvis.ini.php-sample
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@
;htmlbase="/nagvis"
; absolute html NagVis cgi path
;htmlcgi="/nagios/cgi-bin"
; absolute etc NagVis path
;data="/usr/local/nagvis/etc"

; Default values which get inherited to the maps and its objects
[defaults]
Expand Down
41 changes: 32 additions & 9 deletions share/server/core/classes/GlobalMainCfg.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,10 @@ public function __construct() {
'editable' => 1,
'default' => '',
'match' => MATCH_STRING_PATH),
'data' => Array('must' => 0,
'editable' => 1,
'default' => '',
'match' => MATCH_STRING_PATH),
'local_base' => Array('must' => 0,
'editable' => 1,
'default' => '',
Expand Down Expand Up @@ -1494,7 +1498,14 @@ public function __construct() {

// Try to get the base path via $_SERVER['SCRIPT_FILENAME']
$this->validConfig['paths']['base']['default'] = $this->getBasePath();
$this->setPathsByBase($this->getValue('paths','base'), $this->getValue('paths','htmlbase'));
$base = $this->getValue('paths', 'base');
$htmlBase = $this->getValue('paths', 'htmlbase');
$data = $this->getValue('paths', 'data');
if (empty($data)) {
$data = $base;
}

$this->setPathsByBase($base, $htmlBase, $data);

// Define the main configuration files
$this->setConfigFiles($this->getConfigFiles());
Expand Down Expand Up @@ -1579,11 +1590,23 @@ public function init($onlyUserConfig = false, $cacheSuffix = '') {
$this->useCache = $this->CACHE->isCached(false);

// want to reduce the paths in the NagVis config, but don't want to hardcode the paths relative from the bases
$this->setPathsByBase($this->getValue('paths','base'),$this->getValue('paths','htmlbase'));
$base = $this->getValue('paths', 'base');
$htmlBase = $this->getValue('paths', 'htmlbase');
$data = $this->getValue('paths', 'data');
if (empty($data)) {
$data = $base;
}
$this->setPathsByBase($base, $htmlBase, $data);
}
catch (Exception $e) {
// Try our best to set the correct paths - even in case of exceptions
$this->setPathsByBase($this->getValue('paths','base'),$this->getValue('paths','htmlbase'));
$base = $this->getValue('paths', 'base');
$htmlBase = $this->getValue('paths', 'htmlbase');
$data = $this->getValue('paths', 'data');
if (empty($data)) {
$data = $base;
}
$this->setPathsByBase($base, $htmlBase, $data);
throw $e;
}

Expand Down Expand Up @@ -1638,12 +1661,12 @@ private function getBackendValidConf() {
* @param Boolean $printErr
* @author Lars Michelsen <lm@larsmichelsen.com>
*/
private function setPathsByBase($base, $htmlBase) {
$this->validConfig['paths']['cfg']['default'] = $base.'etc/';
$this->validConfig['paths']['mapcfg']['default'] = $base.'etc/maps/';
$this->validConfig['paths']['geomap']['default'] = $base.'etc/geomap';
$this->validConfig['paths']['profiles']['default'] = $base.'etc/profiles';
$this->validConfig['global']['authorisation_group_perms_file']['default'] = $base.'etc/perms.db';
private function setPathsByBase($base, $htmlBase, $data) {
$this->validConfig['paths']['cfg']['default'] = $data.'etc/';
$this->validConfig['paths']['mapcfg']['default'] = $data.'etc/maps/';
$this->validConfig['paths']['geomap']['default'] = $data.'etc/geomap';
$this->validConfig['paths']['profiles']['default'] = $data.'etc/profiles';
$this->validConfig['global']['authorisation_group_perms_file']['default'] = $data.'etc/perms.db';

$this->validConfig['paths']['var']['default'] = $base.'var/';
$this->validConfig['paths']['sharedvar']['default'] = $base.HTDOCS_DIR.'/var/';
Expand Down
17 changes: 13 additions & 4 deletions share/server/core/defines/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@
// The last value wins.
//
// Path to the main configuration file
define('CONST_MAINCFG', '../../../etc/nagvis.ini.php');



if (getenv('NAGVIS_CONFIG') !== false && getenv('NAGVIS_CONFIG') !== '') {
$nagvis_config = getenv('NAGVIS_CONFIG');
$nagvis_config_dir = dirname($nagvis_config);
define('CONST_MAINCFG', $nagvis_config);
define('CONST_MAINCFG_DIR', $nagvis_config_dir . '/conf.d');
} else {
define('CONST_MAINCFG', '../../../etc/nagvis.ini.php');
// Path to the main configuration conf.d directory
define('CONST_MAINCFG_DIR', '../../../etc/conf.d');
}
define('CONST_MAINCFG_CACHE', '../../../var/nagvis-conf');

// Path to the main configuration conf.d directory
define('CONST_MAINCFG_DIR', '../../../etc/conf.d');

// The directory below the NagVis root which is shared by the webserver
define('HTDOCS_DIR', 'share');

Expand Down