Project

General

Profile

Revision 0e8eed1f

ID0e8eed1f1b0b621f4725d7a7b791d924a9bcdf21
Parent 7225125e
Child 166be9d2

Added by Francois POIROTTE about 7 years ago

Dossier de conf "configurable"

Plutôt que de redéfinir le dossier de conf à plusieurs endroits, on
définit la racine via une constante (qui peut être configurée par le
serveur web via une variable d'environnement).

Change-Id: I8ee3f37ce791a5d8331f5f86eec7103f784983e3
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2372
Tested-by: Build system <>
Reviewed-by: Francois POIROTTE <>

View differences:

src/hook.php
4 4
require(__DIR__ . DIRECTORY_SEPARATOR . 'Vigilo' . DIRECTORY_SEPARATOR . 'VigiloSoftwareList.php');
5 5
require(__DIR__ . DIRECTORY_SEPARATOR . 'vigilo_hooks.php');
6 6

  
7
$confdir = getenv('VIGILO_CONFDIR', true);
8
if (!$confdir || !file_exists($confdir)) {
9
    $confdir = implode(DIRECTORY_SEPARATOR, array('etc', 'vigilo', 'vigiconf', 'conf.d'));
10
}
11
define('VIGILO_CONFDIR', $confdir);
7 12
spl_autoload_register('vigilo_autoloader');
src/inc/vigilotemplate.class.php
4 4
{
5 5
    public static function getAllTemplates()
6 6
    {
7
        $hosttdir = "/etc/vigilo/vigiconf/conf.d/hosttemplates";
7
        $hosttdir = VIGILO_CONFDIR . DIRECTORY_SEPARATOR . 'hosttemplates');
8 8
        $hosttemplates_files = scandir($hosttdir);
9 9
        $templates = array();
10 10
        $pattern = "<template name=\"(\w*)\">";
src/vigilo_hooks.php
2 2

  
3 3
class VigiloHooks
4 4
{
5
    private $confdir;
6

  
7
    public function __construct($confdir = "/etc/vigilo/vigiconf/conf.d")
8
    {
9
        $this->confdir = $confdir;
10
    }
11

  
12 5
    public function saveHost($host, $dir_type)
13 6
    {
14
        $dirs       = array($this->confdir, $dir_type, "managed");
7
        $dirs       = array(VIGILO_CONFDIR, $dir_type, "managed");
15 8
        $confdir    = implode(DIRECTORY_SEPARATOR, $dirs);
16 9
        $file       = $confdir . DIRECTORY_SEPARATOR . $host->getName() . ".xml";
17 10

  
......
106 99

  
107 100
    public function unmonitor($host)
108 101
    {
109
        $dirs = array($this->confdir, "hosts", "managed", $host . ".xml");
102
        $dirs = array(VIGILO_CONFDIR, "hosts", "managed", $host . ".xml");
110 103
        $filename = implode(DIRECTORY_SEPARATOR, $dirs);
111 104
        if (file_exists($filename)) {
112 105
            unlink($filename);

Also available in: Unified diff