diff --git a/library/Icinga/Application/Installation/MakeDirStep.php b/library/Icinga/Application/Installation/MakeDirStep.php new file mode 100644 index 000000000..3d9232d0e --- /dev/null +++ b/library/Icinga/Application/Installation/MakeDirStep.php @@ -0,0 +1,102 @@ +paths = $paths; + $this->dirmode = octdec($dirmode) | octdec('111'); // Make sure that the directories can be traversed + $this->errors = array(); + } + + public function apply() + { + $success = true; + foreach ($this->paths as $path) { + if (false === file_exists($path)) { + if (false === @mkdir($path)) { + $this->errors[$path] = error_get_last(); + $success = false; + } else { + $this->errors[$path] = null; + $old = umask(0); + chmod($path, $this->dirmode); + umask($old); + } + } + } + + return $success; + } + + public function getSummary() + { + $pageHtml = ''; + $pageTitle = t('Directory Creation'); + $createMsg = t('The setup will create the following directories:'); + $existsMsg = t('The setup does not need to create the following already existing directories:'); + + $toBeCreated = array_filter($this->paths, function ($p) { return false === file_exists($p); }); + if (false === empty($toBeCreated)) { + $pageHtml .= '
' . $createMsg . '
'; + + $pageHtml .= '' . $existsMsg . '
'; + + $pageHtml .= '' . sprintf($failMessage, basename($path), dirname($path)) . '
' + . '' . $this->errors[$path]['message'] . '
'; + } else { + $report .= '' . sprintf($okMessage, basename($path), dirname($path)) . '
'; + } + } else { + $report .= '' . sprintf($existsMessage, basename($path), dirname($path)) . '
'; + } + } + + return $report; + } +} diff --git a/library/Icinga/Application/WebSetup.php b/library/Icinga/Application/WebSetup.php index c2a609f23..770a0b14f 100644 --- a/library/Icinga/Application/WebSetup.php +++ b/library/Icinga/Application/WebSetup.php @@ -19,6 +19,7 @@ use Icinga\Form\Setup\RequirementsPage; use Icinga\Form\Setup\GeneralConfigPage; use Icinga\Form\Setup\AuthenticationPage; use Icinga\Form\Setup\DatabaseCreationPage; +use Icinga\Application\Installation\MakeDirStep; use Icinga\Application\Installation\DatabaseStep; use Icinga\Application\Installation\GeneralConfigStep; use Icinga\Application\Installation\ResourceStep; @@ -313,6 +314,18 @@ class WebSetup extends Wizard implements SetupWizard ); } + $configDir = $this->getConfigDir(); + $installer->addStep( + new MakeDirStep( + array( + $configDir . '/modules', + $configDir . '/preferences', + $configDir . '/enabledModules' + ), + $pageData['setup_general_config']['global_filemode'] + ) + ); + foreach ($this->getPage('setup_modules')->getWizards() as $wizard) { if ($wizard->isFinished()) { $installer->addSteps($wizard->getInstaller()->getSteps()); @@ -410,7 +423,6 @@ class WebSetup extends Wizard implements SetupWizard $pgsqlAdapterFound ? t('The Zend database adapter for PostgreSQL is available.') : ( t('The Zend database adapter for PostgreSQL is missing.') ) - ); $defaultTimezone = Platform::getPhpConfig('date.timezone');