Skip to content

Commit

Permalink
Add config.ini (preferences) installation routine
Browse files Browse the repository at this point in the history
refs #3761
  • Loading branch information
Johannes Meyer committed Oct 11, 2013
1 parent 34206ef commit 169abd5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
1 change: 1 addition & 0 deletions installer/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
require_once realpath(__DIR__ . '/../../library/Icinga/Config/IniEditor.php');
require_once realpath(__DIR__ . '/../../library/Icinga/Config/PreservingIniWriter.php');
require_once realpath(__DIR__ . '/../../library/Icinga/Application/Installer.php');
require_once realpath(__DIR__ . '/../../library/Icinga/Application/Config.php');

use \Zend_Config;
use \Zend_Session;
Expand Down
60 changes: 51 additions & 9 deletions library/Icinga/Application/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public function run()
$this->setupResources();
$this->setupAuthentication();
$this->setupPreferences();
$this->setupDefaultAdmin();
$this->setupBackend();
$this->setupDatabase();
$this->setupDefaultAdmin();
} catch (Exception $error) {
// TODO: Log this exception? (To the logfile, not $this->log()!)
$this->failed = true;
Expand Down Expand Up @@ -182,8 +183,8 @@ private function setupResources()

$iniWriter = new PreservingIniWriter(
array(
'filename' => $configPath,
'config' => new Zend_Config($iniContent)
'config' => new Zend_Config($iniContent),
'filename' => $configPath
)
);

Expand Down Expand Up @@ -238,8 +239,8 @@ private function setupAuthentication()

$iniWriter = new PreservingIniWriter(
array(
'filename' => $configPath,
'config' => new Zend_Config($iniContent)
'config' => new Zend_Config($iniContent),
'filename' => $configPath
)
);

Expand All @@ -257,22 +258,63 @@ private function setupAuthentication()
* Set up the preferences (config.ini)
*/
private function setupPreferences()
{
$configPath = $this->configDir . '/config.ini';

try {
$config = new Config($configPath);
} catch (Exception $error) {
$this->log('Preference configuration', 'Error while reading INI file: ' . $error->getMessage());
throw $error;
}

$preferenceType = $this->options->authConfig->auth_preference_store;
if ($preferenceType === 'type_ini') {
$config->preferences->type = 'ini';
} elseif ($preferenceType === 'type_db') {
$config->preferences->type = 'db';
$config->preferences->resource = $this->options->dbConfig->db_resource;
} elseif (isset($config->preferences)) { // $preferenceType === 'type_none'
$config->preferences->type = 'null';
}

$iniWriter = new PreservingIniWriter(
array(
'filename' => $configPath,
'config' => $config
)
);

try {
$iniWriter->write();
} catch (Exception $error) {
$this->log('Preference configuration', 'Error while writing INI file: ' . $error->getMessage());
throw $error;
}

$this->log('Preference configuration', 'Configuration successfully written to: ' . $configPath);
}

/**
* Set up the initial backend
*/
private function setupBackend()
{

}

/**
* Set up the default admin user
* Set up the database structure
*/
private function setupDefaultAdmin()
private function setupDatabase()
{

}

/**
* Set up the initial backend
* Set up the default admin user
*/
private function setupBackend()
private function setupDefaultAdmin()
{

}
Expand Down

0 comments on commit 169abd5

Please sign in to comment.