From 00a09284efa406c1f704a5a22048eeffe3f28505 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:28:23 +0100 Subject: [PATCH 01/44] lib: Add NonEmptyFileIterator Add iterator for iterating over non-empty files. --- library/Icinga/File/NonEmptyFileIterator.php | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 library/Icinga/File/NonEmptyFileIterator.php diff --git a/library/Icinga/File/NonEmptyFileIterator.php b/library/Icinga/File/NonEmptyFileIterator.php new file mode 100644 index 000000000..c5c7fda45 --- /dev/null +++ b/library/Icinga/File/NonEmptyFileIterator.php @@ -0,0 +1,49 @@ + + * + */ +class NonEmptyFileIterator extends FilterIterator +{ + /** + * Accept non-empty files + * + * @return bool Whether the current element of the iterator is acceptable + * through this filter + */ + public function accept() + { + $current = $this->current(); + /** @type $current \SplFileInfo */ + if (! $current->isFile() + || $current->getSize() === 0 + ) { + return false; + } + return true; + } +} From 1afc2a0b1dd86469c124d90b9913fd72a3c5ff94 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:28:49 +0100 Subject: [PATCH 02/44] lib: Add FileExtensionFilterIterator Add iterator for iterating over files having a specific file extension. --- .../File/FileExtensionFilterIterator.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 library/Icinga/File/FileExtensionFilterIterator.php diff --git a/library/Icinga/File/FileExtensionFilterIterator.php b/library/Icinga/File/FileExtensionFilterIterator.php new file mode 100644 index 000000000..909156749 --- /dev/null +++ b/library/Icinga/File/FileExtensionFilterIterator.php @@ -0,0 +1,71 @@ + + * + */ +class FileExtensionFilterIterator extends FilterIterator +{ + /** + * The extension to filter for + * + * @type string + */ + protected $extension; + + /** + * Create a new FileExtensionFilterIterator + * + * @param Iterator $iterator Apply filter to this iterator + * @param string $extension The file extension to filter for. The file extension may not contain the leading dot + */ + public function __construct(Iterator $iterator, $extension) + { + $this->extension = '.' . ltrim(strtolower((string) $extension), '.'); + parent::__construct($iterator); + } + + /** + * Accept files which match the file extension to filter for + * + * @return bool Whether the current element of the iterator is acceptable + * through this filter + */ + public function accept() + { + $current = $this->current(); + /* @var $current \SplFileInfo */ + if (! $current->isFile()) { + return false; + } + // SplFileInfo::getExtension() is only available since PHP 5 >= 5.3.6 + $filename = $current->getFilename(); + $sfx = substr($filename, -strlen($this->extension)); + return $sfx === false ? false : strtolower($sfx) === $this->extension; + } +} From 5f772c36202422162ab4e40884f0b9a79759c040 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:29:48 +0100 Subject: [PATCH 03/44] doc: Use Icinga Web 2's iterators --- modules/doc/library/Doc/DocIterator.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/doc/library/Doc/DocIterator.php b/modules/doc/library/Doc/DocIterator.php index 43a9c7727..3045b6309 100644 --- a/modules/doc/library/Doc/DocIterator.php +++ b/modules/doc/library/Doc/DocIterator.php @@ -9,6 +9,8 @@ use Countable; use IteratorAggregate; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; +use Icinga\File\NonEmptyFileIterator; +use Icinga\File\FileExtensionFilterIterator; /** * Iterator over non-empty Markdown files ordered by the case insensitive "natural order" of file names @@ -29,12 +31,14 @@ class DocIterator implements Countable, IteratorAggregate */ public function __construct($path) { - $it = new RecursiveIteratorIterator( + $it = new FileExtensionFilterIterator( new NonEmptyFileIterator( - new MarkdownFileIterator( - new RecursiveDirectoryIterator($path) + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($path), + RecursiveIteratorIterator::SELF_FIRST ) - ) + ), + 'md' ); // Unfortunately we have no chance to sort the iterator $fileInfo = iterator_to_array($it); From 001eba73e73e83b53ac5ff344f3ab64622834109 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:30:08 +0100 Subject: [PATCH 04/44] doc: Remove iterators because they are superseded by iterators from Icinga Web 2's library --- .../doc/library/Doc/MarkdownFileIterator.php | 31 ------------------- .../doc/library/Doc/NonEmptyFileIterator.php | 31 ------------------- 2 files changed, 62 deletions(-) delete mode 100644 modules/doc/library/Doc/MarkdownFileIterator.php delete mode 100644 modules/doc/library/Doc/NonEmptyFileIterator.php diff --git a/modules/doc/library/Doc/MarkdownFileIterator.php b/modules/doc/library/Doc/MarkdownFileIterator.php deleted file mode 100644 index 6f317ce6a..000000000 --- a/modules/doc/library/Doc/MarkdownFileIterator.php +++ /dev/null @@ -1,31 +0,0 @@ -getInnerIterator()->current(); - /* @var $current \SplFileInfo */ - if (! $current->isFile()) { - return false; - } - $filename = $current->getFilename(); - $sfx = substr($filename, -3); - return $sfx === false ? false : strtolower($sfx) === '.md'; - } -} diff --git a/modules/doc/library/Doc/NonEmptyFileIterator.php b/modules/doc/library/Doc/NonEmptyFileIterator.php deleted file mode 100644 index 71bf5acfa..000000000 --- a/modules/doc/library/Doc/NonEmptyFileIterator.php +++ /dev/null @@ -1,31 +0,0 @@ -getInnerIterator()->current(); - /* @var $current \SplFileInfo */ - if (! $current->isFile() - || $current->getSize() === 0 - ) { - return false; - } - return true; - } -} From ca8dbdb9386e8a23ae246eac3f532039c31dd31c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:50:29 +0100 Subject: [PATCH 05/44] doc: Make path to Icinga Web 2's doc configureable refs #7196 --- .../controllers/IcingawebController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index 5740f50a9..d052d8268 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -8,12 +8,20 @@ use Icinga\Module\Doc\DocController; class Doc_IcingawebController extends DocController { + /** + * Get the path to Icinga Web 2's documentation + */ + protected function getDocPath() + { + return $this->Config()->get('documentation', 'path', Icinga::app()->getBaseDir('doc')); + } + /** * View the toc of Icinga Web 2's documentation */ public function tocAction() { - return $this->renderToc(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderToc($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -31,7 +39,7 @@ class Doc_IcingawebController extends DocController ); } return $this->renderChapter( - Icinga::app()->getApplicationDir('/../doc'), + $this->getDocPath(), $chapterId, 'doc/icingaweb/toc', 'doc/icingaweb/chapter' @@ -43,6 +51,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf(Icinga::app()->getApplicationDir('/../doc'), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderPdf($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From cc619e0a7b8c1d27d14ababa3f5cc6d921b8f59e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:53:44 +0100 Subject: [PATCH 06/44] doc/configuration.php: Prefer @type over @var --- modules/doc/configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/configuration.php b/modules/doc/configuration.php index 87e5da77a..6e924e964 100644 --- a/modules/doc/configuration.php +++ b/modules/doc/configuration.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/* @var $this \Icinga\Application\Modules\Module */ +/** @type $this \Icinga\Application\Modules\Module */ $section = $this->menuSection($this->translate('Documentation'), array( 'title' => 'Documentation', From da575910e6c844067adb37c6bccb143266ea029f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:54:41 +0100 Subject: [PATCH 07/44] doc/run.php: Remove superfluous newline --- modules/doc/run.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/doc/run.php b/modules/doc/run.php index 7392e4c22..31aff8ff0 100644 --- a/modules/doc/run.php +++ b/modules/doc/run.php @@ -47,4 +47,3 @@ $this->addRoute('doc/module/chapter', $docModuleChapter); $this->addRoute('doc/icingaweb/chapter', $docIcingaWebChapter); $this->addRoute('doc/module/toc', $docModuleToc); $this->addRoute('doc/module/pdf', $docModulePdf); - From 19d89f0a67de95ce5314dd6a15d39b0917d05597 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:55:12 +0100 Subject: [PATCH 08/44] monitoring/configuration.php: Prefer @type over @var --- modules/monitoring/configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index d61e32858..b1cdee2de 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/** @var $this \Icinga\Application\Modules\Module */ +/** @type $this \Icinga\Application\Modules\Module */ $this->providePermission( 'monitoring/command/*', From 51b47df4c5bb67337e333a505e330e59ac878fe3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:55:29 +0100 Subject: [PATCH 09/44] doc: Set version to 2.0.0 --- modules/doc/module.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/module.info b/modules/doc/module.info index 2826d72de..1689fd940 100644 --- a/modules/doc/module.info +++ b/modules/doc/module.info @@ -1,4 +1,4 @@ Module: doc -Version: 2.0.0~alpha4 +Version: 2.0.0 Description: Documentation module Extracts, shows and exports documentation for Icinga Web 2 and it's modules. From 7edb1217c6ac936e1a351eb2a76caaa44404aa0d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 12:57:16 +0100 Subject: [PATCH 10/44] doc: Use sprintf for "Missing parameter x" exceptions --- modules/doc/application/controllers/ModuleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 1e9cf43b1..adc46a991 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -37,7 +37,7 @@ class Doc_ModuleController extends DocController { if (empty($moduleName)) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'moduleName\''), + sprintf($this->translate('Missing parameter \'%s\''), 'moduleName'), 404 ); } From 40b709848005098f6a0e20db27392f2326101f9d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:24:11 +0100 Subject: [PATCH 11/44] doc/parser: Fix PHPDoc indentation --- modules/doc/library/Doc/DocParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/library/Doc/DocParser.php b/modules/doc/library/Doc/DocParser.php index c63532dc1..6cfeca418 100644 --- a/modules/doc/library/Doc/DocParser.php +++ b/modules/doc/library/Doc/DocParser.php @@ -31,7 +31,7 @@ class DocParser /** * Create a new documentation parser for the given path * - * @param string $path Path to the documentation + * @param string $path Path to the documentation * * @throws DocException If the documentation directory does not exist * @throws NotReadableError If the documentation directory is not readable From 823d338f73cd1470315bffb5c4d83f8728e2de93 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:24:45 +0100 Subject: [PATCH 12/44] doc/Controller: Do not use 'void' results --- modules/doc/library/Doc/DocController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/library/Doc/DocController.php b/modules/doc/library/Doc/DocController.php index bc782953f..0d12f58df 100644 --- a/modules/doc/library/Doc/DocController.php +++ b/modules/doc/library/Doc/DocController.php @@ -28,7 +28,7 @@ class DocController extends ModuleActionController $urlParams ); $this->view->title = $chapterId; - return $this->render('chapter', null, true); + $this->render('chapter', null, true); } /** @@ -46,7 +46,7 @@ class DocController extends ModuleActionController $name = ucfirst($name); $this->view->docName = $name; $this->view->title = sprintf($this->translate('%s Documentation'), $name); - return $this->render('toc', null, true); + $this->render('toc', null, true); } /** @@ -71,6 +71,6 @@ class DocController extends ModuleActionController ); $this->view->docName = $name; $this->_request->setParam('format', 'pdf'); - return $this->render('pdf', null, true); + $this->render('pdf', null, true); } } From 08bbe596790285aa7eee78a75f0b8df05a774e3d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:27:02 +0100 Subject: [PATCH 13/44] doc: Throw an exception if Icinga Web 2's documentation is not avaiable refs #7196 --- .../controllers/IcingawebController.php | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index d052d8268..b989bc883 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -10,10 +10,26 @@ class Doc_IcingawebController extends DocController { /** * Get the path to Icinga Web 2's documentation + * + * @return string + * + * @throws Zend_Controller_Action_Exception If Icinga Web 2's documentation is not available */ - protected function getDocPath() + protected function getPath() { - return $this->Config()->get('documentation', 'path', Icinga::app()->getBaseDir('doc')); + if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) { + if (is_dir($path)) { + return $path; + } + } + $path = Icinga::app()->getBaseDir('doc'); + if (is_dir($path)) { + return $path; + } + throw new Zend_Controller_Action_Exception( + $this->translate('Documentation for Icinga Web 2 is not available'), + 404 + ); } /** @@ -21,7 +37,7 @@ class Doc_IcingawebController extends DocController */ public function tocAction() { - return $this->renderToc($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -39,7 +55,7 @@ class Doc_IcingawebController extends DocController ); } return $this->renderChapter( - $this->getDocPath(), + $this->getPath(), $chapterId, 'doc/icingaweb/toc', 'doc/icingaweb/chapter' @@ -51,6 +67,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf($this->getDocPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + return $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From 7605076dc525832eea119eb2520abe22f8cf7a64 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:28:10 +0100 Subject: [PATCH 14/44] doc/IcingawebController: Use sprintf for "Missing parameter x" exceptions --- modules/doc/application/controllers/IcingawebController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index b989bc883..b51c126ae 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -50,7 +50,7 @@ class Doc_IcingawebController extends DocController $chapterId = $this->getParam('chapterId'); if ($chapterId === null) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'chapterId\''), + sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), 404 ); } From e901e545c3b78e376bb653dcf446b0415ed56100 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:28:58 +0100 Subject: [PATCH 15/44] doc/IcingawebController: Do not use 'void' results --- modules/doc/application/controllers/IcingawebController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index b51c126ae..c07b65798 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -37,7 +37,7 @@ class Doc_IcingawebController extends DocController */ public function tocAction() { - return $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + $this->renderToc($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } /** @@ -54,7 +54,7 @@ class Doc_IcingawebController extends DocController 404 ); } - return $this->renderChapter( + $this->renderChapter( $this->getPath(), $chapterId, 'doc/icingaweb/toc', @@ -67,6 +67,6 @@ class Doc_IcingawebController extends DocController */ public function pdfAction() { - return $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); + $this->renderPdf($this->getPath(), 'Icinga Web 2', 'doc/icingaweb/chapter'); } } From c7e6252acab649bb0a2f21a296cb13255b36dfa5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:30:10 +0100 Subject: [PATCH 16/44] doc: Make path to module documentations configureable refs #7196 --- .../controllers/ModuleController.php | 81 +++++++++++++------ 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index adc46a991..12c4a9246 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -9,6 +9,40 @@ use Icinga\Module\Doc\Exception\DocException; class Doc_ModuleController extends DocController { + /** + * Get the path to a module documentation + * + * @param string $module The name of the module + * @param string $default The default path + * @param bool $suppressErrors Whether to not throw an exception if the module documentation is not + * available + * + * @return string|null Path to the documentation or null if the module documentation is not + * available and errors are suppressed + * + * @throws Zend_Controller_Action_Exception If the module documentation is not available and errors are not + * suppressed + */ + protected function getPath($module, $default, $suppressErrors = false) + { + if (($path = $this->Config()->get('documentation', 'modules')) !== null) { + $path = str_replace('{module}', $module, $path); + if (is_dir($path)) { + return $path; + } + } + if (is_dir($default)) { + return $default; + } + if ($suppressErrors) { + return null; + } + throw new Zend_Controller_Action_Exception( + sprintf($this->translate('Documentation for module \'%s\' is not available'), $module), + 404 + ); + } + /** * List modules which are enabled and having the 'doc' directory */ @@ -16,10 +50,10 @@ class Doc_ModuleController extends DocController { $moduleManager = Icinga::app()->getModuleManager(); $modules = array(); - foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $enabledModule) { - $docDir = $moduleManager->getModuleDir($enabledModule, '/doc'); - if (is_dir($docDir)) { - $modules[] = $enabledModule; + foreach (Icinga::app()->getModuleManager()->listEnabledModules() as $module) { + $path = $this->getPath($module, $moduleManager->getModuleDir($module, '/doc'), true); + if ($path !== null) { + $modules[] = $module; } } $this->view->modules = $modules; @@ -63,16 +97,15 @@ class Doc_ModuleController extends DocController */ public function tocAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); - $this->view->moduleName = $moduleName; - $moduleManager = Icinga::app()->getModuleManager(); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); + $this->view->moduleName = $module; try { return $this->renderToc( - $moduleManager->getModuleDir($moduleName, '/doc'), - $moduleName, + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), + $module, 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } catch (DocException $e) { throw new Zend_Controller_Action_Exception($e->getMessage(), 404); @@ -88,24 +121,23 @@ class Doc_ModuleController extends DocController */ public function chapterAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); $chapterId = $this->getParam('chapterId'); if ($chapterId === null) { throw new Zend_Controller_Action_Exception( - $this->translate('Missing parameter \'chapterId\''), + sprintf($this->translate('Missing parameter \'%s\''), 'chapterId'), 404 ); } - $this->view->moduleName = $moduleName; - $moduleManager = Icinga::app()->getModuleManager(); + $this->view->moduleName = $module; try { return $this->renderChapter( - $moduleManager->getModuleDir($moduleName, '/doc'), + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $chapterId, - $this->_helper->url->url(array('moduleName' => $moduleName), 'doc/module/toc'), + $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'), 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } catch (DocException $e) { throw new Zend_Controller_Action_Exception($e->getMessage(), 404); @@ -119,14 +151,13 @@ class Doc_ModuleController extends DocController */ public function pdfAction() { - $moduleName = $this->getParam('moduleName'); - $this->assertModuleEnabled($moduleName); - $moduleManager = Icinga::app()->getModuleManager(); + $module = $this->getParam('moduleName'); + $this->assertModuleEnabled($module); return $this->renderPdf( - $moduleManager->getModuleDir($moduleName, '/doc'), - $moduleName, + $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), + $module, 'doc/module/chapter', - array('moduleName' => $moduleName) + array('moduleName' => $module) ); } } From 3120a0c090b7d54775cef12d93c772e2835fc122 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:30:57 +0100 Subject: [PATCH 17/44] doc/ModuleController: Do not use 'void' results --- modules/doc/application/controllers/ModuleController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 12c4a9246..cf9ddea16 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -101,7 +101,7 @@ class Doc_ModuleController extends DocController $this->assertModuleEnabled($module); $this->view->moduleName = $module; try { - return $this->renderToc( + $this->renderToc( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $module, 'doc/module/chapter', @@ -132,7 +132,7 @@ class Doc_ModuleController extends DocController } $this->view->moduleName = $module; try { - return $this->renderChapter( + $this->renderChapter( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $chapterId, $this->_helper->url->url(array('moduleName' => $module), 'doc/module/toc'), @@ -153,7 +153,7 @@ class Doc_ModuleController extends DocController { $module = $this->getParam('moduleName'); $this->assertModuleEnabled($module); - return $this->renderPdf( + $this->renderPdf( $this->getPath($module, Icinga::app()->getModuleManager()->getModuleDir($module, '/doc')), $module, 'doc/module/chapter', From d2a7254a37ebdeefd3b176d69f66fc54582591a6 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:55:24 +0100 Subject: [PATCH 18/44] doc: Prefer "root" doc path over configured path If the "root" doc path, i.e. application/doc exists, it is preferred over the configured one. refs #4075 --- .../doc/application/controllers/IcingawebController.php | 8 ++++---- modules/doc/application/controllers/ModuleController.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index c07b65798..60c5da5ee 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -17,15 +17,15 @@ class Doc_IcingawebController extends DocController */ protected function getPath() { + $path = Icinga::app()->getBaseDir('doc'); + if (is_dir($path)) { + return $path; + } if (($path = $this->Config()->get('documentation', 'icingaweb2')) !== null) { if (is_dir($path)) { return $path; } } - $path = Icinga::app()->getBaseDir('doc'); - if (is_dir($path)) { - return $path; - } throw new Zend_Controller_Action_Exception( $this->translate('Documentation for Icinga Web 2 is not available'), 404 diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index cf9ddea16..a4d14cf61 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -25,15 +25,15 @@ class Doc_ModuleController extends DocController */ protected function getPath($module, $default, $suppressErrors = false) { + if (is_dir($default)) { + return $default; + } if (($path = $this->Config()->get('documentation', 'modules')) !== null) { $path = str_replace('{module}', $module, $path); if (is_dir($path)) { return $path; } } - if (is_dir($default)) { - return $default; - } if ($suppressErrors) { return null; } From bca2335aa341836f1c102a8ba7e3bcf90755590c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:58:18 +0100 Subject: [PATCH 19/44] doc: Add module documentation --- modules/doc/doc/1-module-documentation.md | 59 ++++++++++++++++++++++ modules/doc/public/img/doc/markdown.png | Bin 0 -> 2180 bytes 2 files changed, 59 insertions(+) create mode 100644 modules/doc/doc/1-module-documentation.md create mode 100644 modules/doc/public/img/doc/markdown.png diff --git a/modules/doc/doc/1-module-documentation.md b/modules/doc/doc/1-module-documentation.md new file mode 100644 index 000000000..968dd32d7 --- /dev/null +++ b/modules/doc/doc/1-module-documentation.md @@ -0,0 +1,59 @@ +# Writing Module Documentation + +![Markdown](/img/doc/doc/markdown.png) + +Icinga Web 2 is capable of viewing your module's documentation, if the documentation is written in +[Markdown](http://en.wikipedia.org/wiki/Markdown). Please refer to +[Markdown Syntax Documentation](http://daringfireball.net/projects/markdown/syntax) for Markdown's formatting syntax. + +## Where to Put Module Documentation? + +By default, your module's Markdown documentation files must be placed in the `doc` directory beneath your module's root +directory, e.g.: + + example-module/doc + +## Chapters + +Each Markdown documentation file represents a chapter of your module's documentation. The first found heading inside +each file is the chapter's title. The order of chapters is based on the case insensitive "Natural Order" of your files' +names. Natural Order means that the file names are ordered in the way which seems natural to humans. +It is best practice to prefix Markdown documentation file names with numbers to ensure that they appear in the correct +order, e.g.: + + 1-about.md + 2-installation.md + 3-configuration.md + +## Table Of Contents + +The table of contents for your module's documentation is auto-generated based on all found headings inside each +Markdown documentation file. + +## Linking Between Headings + +For linking between headings, place an anchor where you want to link to, e.g.: + + # Heading + +Now you can reference the anchor either in the same or **in another** Markdown documentation file, e.g.: + + This is a link to [Heading](#heading). + +## Including Images + +Images must placed in the `img` directory beneath your module's `public` directory, e.g.: + + example-module/public/img/doc + +Module images can be accessed using the following URL: + + {baseURL}/img/{moduleName}/{file} e.g. icingaweb/img/example-module/doc/example.png + +Markdown's image syntax is very similar to Markdown's link syntax, but prefixed with an exclamation mark, e.g.: + + ![Alt text](http://path/to/img.png "Optional Title") + +URLs to images inside your Markdown documentation files must be specified without the base URL, e.g.: + + ![Example](/img/example-module/doc/example.png) diff --git a/modules/doc/public/img/doc/markdown.png b/modules/doc/public/img/doc/markdown.png new file mode 100644 index 0000000000000000000000000000000000000000..93e729bc77ca37a36b97509e4cd552e1033973f9 GIT binary patch literal 2180 zcmaJ@3pCSxAD^wcY}Rs*WtD5G;fWbxQ?n;Z>?w^%R6I%eyW|avwnDTzlpgZBtwM^W z$&fc$p0XlZVkGpJ%9=})+uYyj>FGV^J@0wX@BDth^Z8yr-|z2ozQ11@)qNKVp@)D# zAShQC=Y8^7DDMnqMfn(SHgsM-DIVRk%Neq~(%AL4Ga(RVJ6Go&p0RnOeIBWSURr{2 zV9NH=6SaIdWsU6zYpF*>w^r?SPJ8+5^CpE~4C*p6D4tIbHc`%DUNAB?veYywr;e#^ zaz?4Cq&-PC+*Haouxvm2{sx1AYzT)DwFiqExY&4%=43HC+dds?#|>&h%xi^ zx;6p^oiWdh=I8VE`M9QZo$(Po7!aOhnQsZFP=G)5(%X|~By~=Fx_lO@0(H6fcjZ<{(!+q{M7 zL%a|jm|;W^eX>Z+2pb&>WxVuf6&!N%q75st9Gx}3Q_&xzMt`HSqJro z=%-qo`Uky~8XXLd8(}89bD>p%pY+T+uzIl$FBBc8OCTI?yA%ZPf+E(Vaz}doW~Y<1 zX6lV+Kiz{{drp-KLw>pkdUMIiS$`+v#&ciXRrd?z5=^O#DOo^RZ*8I8 zn39t$x64;()pZw=%nK<6kNl+3e3*sOdh~bFR-Jm$nF9xz(E1$M5aT54{a2{h_-um5 z*pMM*Y^a?KloXT@o!8nscnXD1qV_Gq*X9~?3AHgBx5Uc)<1OEMZGZ>U<7{6jW}-44 zCu#gV*-1_ISDtx5^4Dr}r{*u8E_V#_k#Hg)i9hn2Z#rPJI({T93Mgt*{`&UNvsduX z6>9z0^WO{=g$R!UnR$(^OeBApgWT8=!K7xMD$lkUSUqunHu{krPhb%(-@D)M@dS_^ z@79xSB?80v@7rlJ3*qURsglq4EH>5lf{`b91>MqLwvo{Ig8SE?`z7|U5gl1g7AGMK zAaY(;bgIhSlLfb?=4^7&MlWBHFPm;H=6B4EDTZsxW}1eZKD-a_G zBF7ze){N?3Hl+mm>0)){4D%{1oTXPnaSEa(MUgXqnTs6JD&A;X7-0p&3b zTyyPGyO}!gaytCE(LYMpSXr-~5CY`_WJmr<$HVsl1IhJM3_j5_RbTH?+!sPh7ml>q z_f)wiTRH2-PKn=R$0^L8@3IOzaNB7JYS965^17O&NfDrG;hPv0`kK3sVSvM!g>IL# zihy#FTo|?@w6VmR6{(_{9Hud4omqvB691u{3OzzgPnVT2qXgP0j`Xlb?7i7Z<*~~W zvV}fIpmA^{_iLNcbN<{eUE^ z&}U^G8;+L%=m6x--fhz~VUtnK@2uGsJ9%{8-hkkt7G3QtF>2{~K{ucQ2 zoI6vwN`gZ# zKMW;V<~MuSy6m~FJT&>>Y0$tit47L`8RomPY+Pl%{Qa=!pJkY0bPOxQ%wd4)#8@WZ zpK0IIX;_J$X3oI6E)e$l!yk9t!(QQh3j((zbGSW7u-de3;TBTxpAw02RWW#WF@b|}A1v5Hkbm`Ii v0@|%qBtaQNUf$8&Gpzv{H;#JK<}AKdSfrDxI5YBZ1;mx&?tE`&z`1_|&HV@> literal 0 HcmV?d00001 From 28f08078f05e6f422d72a55d14b5a7373aa35ed8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 14:58:39 +0100 Subject: [PATCH 20/44] doc: Add module config.ini for packaging resolves #7196 --- packages/files/modules/doc/config.ini | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/files/modules/doc/config.ini diff --git a/packages/files/modules/doc/config.ini b/packages/files/modules/doc/config.ini new file mode 100644 index 000000000..80df20784 --- /dev/null +++ b/packages/files/modules/doc/config.ini @@ -0,0 +1,3 @@ +[documentation] +icingaweb2 = /usr/share/doc/icingaweb2/markdown +modules = /usr/share/doc/icingaweb2/modules/{module}/markdown From 7d00f68660af4f54652e1f7bfd7941c9ca9a20d2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:27:04 +0100 Subject: [PATCH 21/44] Revert "Load core modules also when bootstrapping the CLI" This reverts commit f12473d34bf55b2acea2a196d5455ad851dbf86b. The CLI must not load core modules, i.e. setup. --- library/Icinga/Application/Cli.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index abf46262f..7d1a98eec 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -43,8 +43,7 @@ class Cli extends ApplicationBootstrap ->parseBasicParams() ->setupLogger() ->setupResourceFactory() - ->setupModuleManager() - ->loadCoreModules(); + ->setupModuleManager(); } protected function setupLogging() From 916868a051755bdacc899c9d61557b1d11e54014 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:28:05 +0100 Subject: [PATCH 22/44] Revert "Add support for "core" modules and make the setup module such a module" This reverts commit 8af13f564b3f8e69c2c1abcda5d7e2e5266c3c7d. The setup module must only be loaded when necessary not always. --- .../Application/ApplicationBootstrap.php | 15 --------- .../Icinga/Application/Modules/Manager.php | 32 ++----------------- library/Icinga/Application/Web.php | 1 - .../Util/GettextTranslationHelper.php | 2 +- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 7f1667e5b..733cdbf83 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -378,21 +378,6 @@ abstract class ApplicationBootstrap return $this; } - /** - * Load all core modules - * - * @return self - */ - protected function loadCoreModules() - { - try { - $this->moduleManager->loadCoreModules(); - } catch (NotReadableError $e) { - Logger::error(new IcingaException('Cannot load core modules. An exception was thrown:', $e)); - } - return $this; - } - /** * Load all enabled modules * diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 6469d3929..7ee2461f9 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -68,18 +68,6 @@ class Manager */ private $modulePaths = array(); - /** - * The core modules - * - * Core modules do not need to be enabled to load and cannot be disabled - * by the user. This must not be writable programmatically! - * - * @var array - */ - private $coreModules = array( - 'setup' - ); - /** * Create a new instance of the module manager * @@ -170,21 +158,7 @@ class Manager } /** - * Try to set all core modules in loaded state - * - * @return self - * @see Manager::loadModule() - */ - public function loadCoreModules() - { - foreach ($this->coreModules as $name) { - $this->loadModule($name); - } - return $this; - } - - /** - * Try to set all enabled modules in loaded state + * Try to set all enabled modules in loaded sate * * @return self * @see Manager::loadModule() @@ -239,8 +213,6 @@ class Manager 'Cannot enable module "%s". Module is not installed.', $name ); - } elseif (in_array($name, $this->coreModules)) { - return $this; } clearstatcache(true); @@ -458,7 +430,7 @@ class Manager } $installed = $this->listInstalledModules(); - foreach (array_diff($installed, $this->coreModules) as $name) { + foreach ($installed as $name) { $info[$name] = (object) array( 'name' => $name, 'path' => $this->installedBaseDirs[$name], diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 37ec5138a..a21f21025 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -104,7 +104,6 @@ class Web extends ApplicationBootstrap ->setupZendMvc() ->setupFormNamespace() ->setupModuleManager() - ->loadCoreModules() ->loadEnabledModules() ->setupRoute() ->setupPagination(); diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 0d5a950e1..5702def85 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -101,7 +101,7 @@ class GettextTranslationHelper */ public function __construct(ApplicationBootstrap $bootstrap, $locale) { - $this->moduleMgr = $bootstrap->getModuleManager()->loadCoreModules()->loadEnabledModules(); + $this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules(); $this->appDir = $bootstrap->getApplicationDir(); $this->locale = $locale; } From d0e8718d619f7a6671e23aa23a6cc9c7e2d348e4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 9 Dec 2014 16:56:06 +0100 Subject: [PATCH 23/44] packages: Rename icingaweb.conf to icingaweb2.conf --- packages/files/apache/{icingaweb.conf => icingaweb2.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/files/apache/{icingaweb.conf => icingaweb2.conf} (100%) diff --git a/packages/files/apache/icingaweb.conf b/packages/files/apache/icingaweb2.conf similarity index 100% rename from packages/files/apache/icingaweb.conf rename to packages/files/apache/icingaweb2.conf From ef00765ff0828c9225c97f353fbcb57b20245c8e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:29:38 +0100 Subject: [PATCH 24/44] packages: Use 'icingaweb2' as the web path refs #4075 --- packages/files/apache/icingaweb2.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/files/apache/icingaweb2.conf b/packages/files/apache/icingaweb2.conf index 2c52b73e3..6bf0b7a66 100644 --- a/packages/files/apache/icingaweb2.conf +++ b/packages/files/apache/icingaweb2.conf @@ -1,4 +1,4 @@ -Alias /icingaweb "/usr/share/icingaweb2/public" +Alias /icingaweb2 "/usr/share/icingaweb2/public" Options SymLinksIfOwnerMatch @@ -23,7 +23,7 @@ Alias /icingaweb "/usr/share/icingaweb2/public" RewriteEngine on - RewriteBase /icingaweb/ + RewriteBase /icingaweb2/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d From 2b5fe7baf4a8e0cd50eefe834e061c8dd5696d87 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:30:12 +0100 Subject: [PATCH 25/44] Set default config dir to '/etc/icingaweb2' --- library/Icinga/Application/ApplicationBootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 733cdbf83..5e2a787c7 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -133,7 +133,7 @@ abstract class ApplicationBootstrap if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; } else { - $configDir = '/etc/icingaweb'; + $configDir = '/etc/icingaweb2'; } } $canonical = realpath($configDir); From 613cbae5bfc7d278da24923ab3970c43a289cf95 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:30:35 +0100 Subject: [PATCH 26/44] packages: Fix base dir path in the icingacli refs #4075 --- packages/files/bin/icingacli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/files/bin/icingacli b/packages/files/bin/icingacli index 10b4857aa..5b41e4e8c 100755 --- a/packages/files/bin/icingacli +++ b/packages/files/bin/icingacli @@ -3,4 +3,4 @@ require_once '/usr/share/php/Icinga/Application/Cli.php'; -Icinga\Application\Cli::start('/usr/share/icingaweb')->dispatch(); +Icinga\Application\Cli::start('/usr/share/icingaweb2')->dispatch(); From 888fa90fe209edcd19b278ced262e70c5a638f6a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:31:37 +0100 Subject: [PATCH 27/44] Fix typo in PHPDoc in EmbeddedWeb --- library/Icinga/Application/EmbeddedWeb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 23cb365f0..72a4ec919 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/ApplicationBootstrap.php'; use Icinga\Exception\ProgrammingError; /** - * Use this if you want to make use of Icinga funtionality in other web projects + * Use this if you want to make use of Icinga functionality in other web projects * * Usage example: * From 68e460b5d12e468e95ad058f649153fa96a59cdd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 10 Dec 2014 09:32:02 +0100 Subject: [PATCH 28/44] Remove unused use in EmbeddedWeb --- library/Icinga/Application/EmbeddedWeb.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 72a4ec919..b9ed067a2 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -6,8 +6,6 @@ namespace Icinga\Application; require_once dirname(__FILE__) . '/ApplicationBootstrap.php'; -use Icinga\Exception\ProgrammingError; - /** * Use this if you want to make use of Icinga functionality in other web projects * From 7d36a59c67dba7b177f53361f479929c5e19ccd5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:01:19 +0100 Subject: [PATCH 29/44] Use '@return $this' instead of '@return self' for document fluent interfaces in ApplicationBootstrap.php --- .../Icinga/Application/ApplicationBootstrap.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 81230a7fb..86dcef8c4 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -333,7 +333,7 @@ abstract class ApplicationBootstrap /** * Setup Icinga auto loader * - * @return self + * @return $this */ public function setupAutoloader() { @@ -366,7 +366,7 @@ abstract class ApplicationBootstrap /** * Setup module manager * - * @return self + * @return $this */ protected function setupModuleManager() { @@ -381,7 +381,7 @@ abstract class ApplicationBootstrap /** * Load all enabled modules * - * @return self + * @return $this */ protected function loadEnabledModules() { @@ -396,7 +396,7 @@ abstract class ApplicationBootstrap /** * Setup default logging * - * @return self + * @return $this */ protected function setupLogging() { @@ -413,7 +413,7 @@ abstract class ApplicationBootstrap /** * Load Configuration * - * @return self + * @return $this */ protected function loadConfig() { @@ -432,7 +432,7 @@ abstract class ApplicationBootstrap /** * Error handling configuration * - * @return self + * @return $this */ protected function setupErrorHandling() { @@ -458,7 +458,7 @@ abstract class ApplicationBootstrap /** * Set up logger * - * @return self + * @return $this */ protected function setupLogger() { @@ -475,7 +475,7 @@ abstract class ApplicationBootstrap /** * Set up the resource factory * - * @return self + * @return $this */ protected function setupResourceFactory() { From 611d01788f787bd4c2451bb75c05f224174ff984 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:29:31 +0100 Subject: [PATCH 30/44] Add setup related utility functions to ApplicationBootstrap.php --- .../Application/ApplicationBootstrap.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 86dcef8c4..92e97ba39 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -113,6 +113,13 @@ abstract class ApplicationBootstrap */ protected $isWeb = false; + /** + * Whether Icinga Web 2 requires setup + * + * @type bool + */ + protected $requiresSetup = false; + /** * Constructor * @@ -393,6 +400,40 @@ abstract class ApplicationBootstrap return $this; } + /** + * Load the setup module if Icinga Web 2 requires setup + * + * @return $this + */ + protected function loadSetupModuleIfNecessary() + { + if (! @file_exists($this->config->resolvePath('config.ini'))) { + $this->requiresSetup = true; + $this->moduleManager->loadModule('setup'); + } + return $this; + } + + /** + * Get whether Icinga Web 2 requires setup + * + * @return bool + */ + public function requiresSetup() + { + return $this->requiresSetup; + } + + /** + * Get whether the setup token exists + * + * @return bool + */ + public function setupTokenExists() + { + return @file_exists($this->config->resolvePath('setup.token')); + } + /** * Setup default logging * From 9d8fab51b1c4f147d70cef111c5cdd360b66fe6f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:30:06 +0100 Subject: [PATCH 31/44] Use the setup related utility functions in AuthenticationController.php --- application/controllers/AuthenticationController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 00dae1c6d..d2c9d4873 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -15,6 +15,7 @@ use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; use Icinga\User; use Icinga\Web\Url; +use Icinga\Application\Icinga; /** * Application wide controller for authentication @@ -33,7 +34,8 @@ class AuthenticationController extends ActionController */ public function loginAction() { - if (@file_exists(Config::resolvePath('setup.token')) && !@file_exists(Config::resolvePath('config.ini'))) { + $icinga = Icinga::app(); + if ($icinga->setupTokenExists() && $icinga->requiresSetup()) { $this->redirectNow(Url::fromPath('setup')); } @@ -139,7 +141,7 @@ class AuthenticationController extends ActionController $this->view->errorInfo = $e->getMessage(); } - $this->view->configMissing = is_dir(Config::$configDir) === false; + $this->view->requiresSetup = Icinga::app()->requiresSetup(); } /** From 250e05f2e81d448f9f03e6e20fbbfd42331038dd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:30:47 +0100 Subject: [PATCH 32/44] Optimize imports in AuthenticationController.php --- .../controllers/AuthenticationController.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index d2c9d4873..2d7926819 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -4,18 +4,18 @@ # namespace Icinga\Application\Controllers; -use Icinga\Authentication\Backend\AutoLoginBackend; -use Icinga\Web\Controller\ActionController; -use Icinga\Forms\Authentication\LoginForm; -use Icinga\Authentication\AuthChain; use Icinga\Application\Config; -use Icinga\Application\Logger; -use Icinga\Exception\AuthenticationException; -use Icinga\Exception\NotReadableError; -use Icinga\Exception\ConfigurationError; -use Icinga\User; -use Icinga\Web\Url; use Icinga\Application\Icinga; +use Icinga\Application\Logger; +use Icinga\Authentication\AuthChain; +use Icinga\Authentication\Backend\AutoLoginBackend; +use Icinga\Exception\AuthenticationException; +use Icinga\Exception\ConfigurationError; +use Icinga\Exception\NotReadableError; +use Icinga\Forms\Authentication\LoginForm; +use Icinga\User; +use Icinga\Web\Controller\ActionController; +use Icinga\Web\Url; /** * Application wide controller for authentication From 74ce666cd85a4ca3b1abf38874cf78b686986a19 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:31:07 +0100 Subject: [PATCH 33/44] Use the requiresSetup variable instead of configMissing in login.phtml --- application/views/scripts/authentication/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 416e651d1..a3d8fcfa9 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -15,7 +15,7 @@ form ?> - +
Date: Mon, 29 Dec 2014 14:31:34 +0100 Subject: [PATCH 34/44] Web: Load setup module if necessary --- library/Icinga/Application/Web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index a21f21025..5b18f1be8 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -104,6 +104,7 @@ class Web extends ApplicationBootstrap ->setupZendMvc() ->setupFormNamespace() ->setupModuleManager() + ->loadSetupModuleIfNecessary() ->loadEnabledModules() ->setupRoute() ->setupPagination(); From 19387b24ab726529d3a7fb7cd25b7bfc83c44f55 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:32:20 +0100 Subject: [PATCH 35/44] Do not use a new function for getting the configuration directory in our web wizard --- modules/setup/library/Setup/WebWizard.php | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index faa123fe8..8dff112f5 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -9,6 +9,7 @@ use Icinga\Web\Form; use Icinga\Web\Wizard; use Icinga\Web\Request; use Icinga\Application\Config; +use Icinga\Application\Icinga; use Icinga\Application\Platform; use Icinga\Module\Setup\Forms\ModulePage; use Icinga\Module\Setup\Forms\WelcomePage; @@ -343,7 +344,7 @@ class WebWizard extends Wizard implements SetupWizard ); } - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $setup->addStep( new MakeDirStep( array( @@ -528,7 +529,7 @@ class WebWizard extends Wizard implements SetupWizard ) ); - $configDir = $this->getConfigDir(); + $configDir = Icinga::app()->getConfigDir(); $requirements->addMandatory( mt('setup', 'Writable Config Directory'), mt( @@ -551,21 +552,4 @@ class WebWizard extends Wizard implements SetupWizard return $requirements; } - - /** - * Return the configuration directory of Icinga Web 2 - * - * @return string - */ - protected function getConfigDir() - { - if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) { - $configDir = $_SERVER['ICINGAWEB_CONFIGDIR']; - } else { - $configDir = '/etc/icingaweb'; - } - - $canonical = realpath($configDir); - return $canonical ? $canonical : $configDir; - } } From daaf242145fb2d75209d0917e528fedc526421dc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:33:07 +0100 Subject: [PATCH 36/44] Fix the default configuration path in our web wizard --- modules/setup/library/Setup/WebWizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/library/Setup/WebWizard.php b/modules/setup/library/Setup/WebWizard.php index 8dff112f5..e4d61dfd7 100644 --- a/modules/setup/library/Setup/WebWizard.php +++ b/modules/setup/library/Setup/WebWizard.php @@ -534,7 +534,7 @@ class WebWizard extends Wizard implements SetupWizard mt('setup', 'Writable Config Directory'), mt( 'setup', - 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb", if' . + 'The Icinga Web 2 configuration directory defaults to "/etc/icingaweb2", if' . ' not explicitly set in the environment variable "ICINGAWEB_CONFIGDIR".' ), is_writable($configDir), From 2bd9d27e054fcf86970e07f59127b19bf676688a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 14:33:37 +0100 Subject: [PATCH 37/44] Do not validate the mode of the setup.token Relying on the mode of the configuration directory must be sufficient. --- .../Setup/Web/Form/Validator/TokenValidator.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php b/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php index 7dc2ea2f9..fa858f531 100644 --- a/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php +++ b/modules/setup/library/Setup/Web/Form/Validator/TokenValidator.php @@ -38,10 +38,6 @@ class TokenValidator extends Zend_Validate_Abstract mt('setup', 'Cannot validate token, file "%s" is empty. Please define a token.'), $tokenPath ), - 'TOKEN_FILE_PUBLIC' => sprintf( - mt('setup', 'Cannot validate token, file "%s" must only be accessible by the webserver\'s user.'), - $tokenPath - ), 'TOKEN_INVALID' => mt('setup', 'Invalid token supplied.') ); } @@ -56,12 +52,6 @@ class TokenValidator extends Zend_Validate_Abstract */ public function isValid($value, $context = null) { - $tokenStats = @stat($this->tokenPath); - if (($tokenStats['mode'] & 4) === 4) { - $this->_error('TOKEN_FILE_PUBLIC'); - return false; - } - try { $file = new File($this->tokenPath); $expectedToken = trim($file->fgets()); From 94a4b4425f82412dead4a26c57af9763b53d12cd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 15:42:24 +0100 Subject: [PATCH 38/44] puppet: Use icingaweb2 instead of icingaweb in paths and database setup --- .puppet/hiera/common.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.puppet/hiera/common.yaml b/.puppet/hiera/common.yaml index 0a85ba63a..c76b904bf 100644 --- a/.puppet/hiera/common.yaml +++ b/.puppet/hiera/common.yaml @@ -1,7 +1,7 @@ --- -icingaweb2::config: /etc/icingaweb -icingaweb2::log: /var/log/icingaweb/icingaweb.log -icingaweb2::web_path: icingaweb -icingaweb2::db_user: icingaweb -icingaweb2::db_pass: icingaweb -icingaweb2::db_name: icingaweb +icingaweb2::config: /etc/icingaweb2 +icingaweb2::log: /var/log/icingaweb2/icingaweb2.log +icingaweb2::web_path: icingaweb2 +icingaweb2::db_user: icingaweb2 +icingaweb2::db_pass: icingaweb2 +icingaweb2::db_name: icingaweb2 From 5bc2144b18670fdc98756b87ecfc979be97c5808 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:01:07 +0100 Subject: [PATCH 39/44] Use 'icingaweb2' as default application prefix for logging to syslog --- application/forms/Config/General/LoggingConfigForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index deed06011..bb9bea33a 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -67,7 +67,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('Application Prefix'), 'description' => t('The name of the application by which to prefix syslog messages.'), - 'value' => 'icingaweb', + 'value' => 'icingaweb2', 'validators' => array( array( 'Regex', From f0fe6246acf8e3b1c0d1b9c8b7524ac450b7d99c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:02:40 +0100 Subject: [PATCH 40/44] Use '/var/log/icingaweb2/icingaweb2.log' as default path when logging to file --- .../forms/Config/General/LoggingConfigForm.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index bb9bea33a..759c2a6e3 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -106,7 +106,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => t('File path'), 'description' => t('The full path to the log file to write messages to.'), - 'value' => $this->getDefaultLogDir(), + 'value' => '/var/log/icingaweb2/icingaweb2.log', 'validators' => array(new WritablePathValidator()) ) ); @@ -114,14 +114,4 @@ class LoggingConfigForm extends Form return $this; } - - /** - * Return the default logging directory for type 'file' - * - * @return string - */ - protected function getDefaultLogDir() - { - return realpath(Icinga::app()->getApplicationDir('../var/log/icingaweb.log')); - } } From ff17c3729cfa1b073277f8f5c4278c554a5c26a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:06:34 +0100 Subject: [PATCH 41/44] setup: Use 'icingaweb2' as default authentication backend name --- modules/setup/application/forms/AuthBackendPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index fac2a7bbd..bd820d352 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -112,7 +112,7 @@ class AuthBackendPage extends Form } $this->addElements($backendForm->getElements()); - $this->getElement('name')->setValue('icingaweb'); + $this->getElement('name')->setValue('icingaweb2'); } /** From 0b8ab18243da17af6c128da18ad691491013a144 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:30:44 +0100 Subject: [PATCH 42/44] Parsedown: Rename LICENSE.txt to LICENSE --- library/vendor/Parsedown/{LICENSE.txt => LICENSE} | 0 library/vendor/Parsedown/SOURCE | 1 + 2 files changed, 1 insertion(+) rename library/vendor/Parsedown/{LICENSE.txt => LICENSE} (100%) diff --git a/library/vendor/Parsedown/LICENSE.txt b/library/vendor/Parsedown/LICENSE similarity index 100% rename from library/vendor/Parsedown/LICENSE.txt rename to library/vendor/Parsedown/LICENSE diff --git a/library/vendor/Parsedown/SOURCE b/library/vendor/Parsedown/SOURCE index c5a2c7c28..43ee6c61c 100644 --- a/library/vendor/Parsedown/SOURCE +++ b/library/vendor/Parsedown/SOURCE @@ -4,3 +4,4 @@ DESTINATION=. wget -O ${FILENAME}.tar.gz https://github.com/erusev/parsedown/archive/${RELEASE}.tar.gz tar xfz ${FILENAME}.tar.gz -C $DESTINATION/ --strip-components 1 $FILENAME/Parsedown.php $FILENAME/LICENSE.txt chmod 644 $DESTINATION/Parsedown.php +mv LICENSE.txt LICENSE From 57121bf0ea1ddfb099e80286a2d8a65d7316f3a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:31:21 +0100 Subject: [PATCH 43/44] dompdf: Rename LICENSE.LGPL to LICENSE --- library/vendor/dompdf/{LICENSE.LGPL => LICENSE} | 0 library/vendor/dompdf/SOURCE | 1 + 2 files changed, 1 insertion(+) rename library/vendor/dompdf/{LICENSE.LGPL => LICENSE} (100%) diff --git a/library/vendor/dompdf/LICENSE.LGPL b/library/vendor/dompdf/LICENSE similarity index 100% rename from library/vendor/dompdf/LICENSE.LGPL rename to library/vendor/dompdf/LICENSE diff --git a/library/vendor/dompdf/SOURCE b/library/vendor/dompdf/SOURCE index 9343b58cf..c26253e30 100644 --- a/library/vendor/dompdf/SOURCE +++ b/library/vendor/dompdf/SOURCE @@ -1,6 +1,7 @@ curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.6.1 -o dompdf-0.6.1.tar.gz tar xzf dompdf-0.6.1.tar.gz --strip-components 1 dompdf-0.6.1/{include/*.php,lib,dompdf*.php,LICENSE.LGPL} rm dompdf-0.6.1.tar.gz +mv LICENSE.LGPL LICENSE curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.3.1 -o php-font-lib-0.3.1.tar.gz mkdir lib/php-font-lib/classes From 2d0153464d20ebf3bbb43b1c486757ad33616201 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 29 Dec 2014 16:48:18 +0100 Subject: [PATCH 44/44] Add spec file for RHEL (CentOS and Fedora) packages refs #6401 fixes #6894 --- icingaweb2.spec | 398 ++++++++++++++++++++++++------------------------ 1 file changed, 198 insertions(+), 200 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index fb628f995..0b4813bc4 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,237 +1,235 @@ -#/** -# * This file is part of Icinga Web 2. -# * -# * Icinga Web 2 - Head for multiple monitoring backends. -# * Copyright (C) 2014 Icinga Development Team -# * -# * This program is free software; you can redistribute it and/or -# * modify it under the terms of the GNU General Public License -# * as published by the Free Software Foundation; either version 2 -# * of the License, or (at your option) any later version. -# * -# * This program is distributed in the hope that it will be useful, -# * but WITHOUT ANY WARRANTY; without even the implied warranty of -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# * GNU General Public License for more details. -# * -# * You should have received a copy of the GNU General Public License -# * along with this program; if not, write to the Free Software -# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# * -# * @copyright 2014 Icinga Development Team -# * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 -# * @author Icinga Development Team -# * -# */ - -%define revision 1 - -%define configdir %{_sysconfdir}/%{name} -%define sharedir %{_datadir}/%{name} -%define prefixdir %{_datadir}/%{name} -%define usermodparam -a -G -%define logdir %{_localstatedir}/log/%{name} -%define docdir %{sharedir}/doc - -%if "%{_vendor}" == "suse" -%define phpname php5 -%define phpzendname php5-ZendFramework -%define apache2modphpname apache2-mod_php5 -%endif -# SLE 11 = 1110 -%if 0%{?suse_version} == 1110 -%define phpname php53 -%define apache2modphpname apache2-mod_php53 -%define usermodparam -A -%endif - -%if "%{_vendor}" == "redhat" -%define phpname php -%define phpzendname php-ZendFramework -%endif - -# el5 requires newer php53 rather than php (5.1) -%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" -%define phpname php53 -%endif - -%if "%{_vendor}" == "suse" -%define apacheconfdir %{_sysconfdir}/apache2/conf.d -%define apacheuser wwwrun -%define apachegroup www -%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd -%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus -%endif -%if "%{_vendor}" == "redhat" -%define apacheconfdir %{_sysconfdir}/httpd/conf.d -%define apacheuser apache -%define apachegroup apache -%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd -%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus -%endif - -Summary: Open Source host, service and network monitoring Web UI Name: icingaweb2 -Version: 0.0.1 -Release: %{revision}%{?dist} -License: GPLv2 +Version: 2.0.0 +Release: 1.beta2%{?dist} +Summary: Icinga Web 2 Group: Applications/System -URL: http://www.icinga.org +License: GPL +URL: https://icinga.org +Source0: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} +Packager: Icinga Team -%if "%{_vendor}" == "suse" -AutoReqProv: Off +%if 0%{?fedora} || 0%{?rhel} +%define wwwconfigdir %{_sysconfdir}/httpd/conf.d +%define wwwuser apache +%if 0%{?rhel} == 5 +%define php php53 +%define php_cli php53-cli +%else +%define php php +%define php_cli php-cli +%endif +%if 0%{rhel} == 6 +%define zend php-ZendFramework +%else +%define zend %{name}-vendor-Zend +%endif %endif -Source: icingaweb2-%{version}.tar.gz - -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root - -BuildRequires: %{phpname} >= 5.3.0 -BuildRequires: %{phpname}-devel >= 5.3.0 -BuildRequires: %{phpname}-ldap -BuildRequires: %{phpname}-pdo -BuildRequires: %{phpzendname} -%if "%{_vendor}" != "suse" -BuildRequires: %{phpzendname}-Db-Adapter-Pdo -BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Mysql -BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Pgsql -%endif - -%if "%{_vendor}" == "redhat" -%endif -%if "%{_vendor}" == "suse" -Requires: %{phpname}-devel >= 5.3.0 -BuildRequires: %{phpname}-json -BuildRequires: %{phpname}-sockets -BuildRequires: %{phpname}-dom -%endif - -Requires: %{phpname} >= 5.3.0 -Requires: %{phpzendname} -Requires: %{phpname}-ldap -Requires: %{phpname}-pdo -%if "%{_vendor}" == "redhat" -Requires: %{phpname}-common -Requires: %{phpzendname}-Db-Adapter-Pdo -Requires: %{phpzendname}-Db-Adapter-Pdo-Mysql -Requires: php-pear -%endif -%if "%{_vendor}" == "suse" -Requires: %{phpname}-pear -Requires: %{phpname}-dom -Requires: %{phpname}-tokenizer -Requires: %{phpname}-gettext -Requires: %{phpname}-ctype -Requires: %{phpname}-json -Requires: %{apache2modphpname} -%endif - -Requires: php-Icinga +Requires(pre): shadow-utils +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{name}-vendor-dompdf +Requires: %{name}-vendor-HTMLPurifier +Requires: %{name}-vendor-JShrink +Requires: %{name}-vendor-lessphp +Requires: %{name}-vendor-Parsedown +Requires: %{zend} %description -Icinga Web 2 for Icinga 2 or Icinga 1.x using multiple backends -for example DB IDO. +Icinga Web 2 + + +%define basedir %{_datadir}/%{name} +%define bindir %{_bindir} +%define configdir %{_sysconfdir}/%{name} +%define logdir %{_localstatedir}/log/%{name} +%define phpdir %{_datadir}/php +%define icingawebgroup icingaweb2 + + +%package common +Summary: Common files for Icinga Web 2 and the Icinga CLI +Group: Applications/System + +%description common +Common files for Icinga Web 2 and the Icinga CLI + + +%package -n php-Icinga +Summary: Icinga Web 2 PHP library +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description -n php-Icinga +Icinga Web 2 PHP library + %package -n icingacli Summary: Icinga CLI Group: Applications/System -Requires: %{name} = %{version}-%{release} -Requires: php-Icinga +Requires: %{name}-common = %{version}-%{release} +Requires: php-Icinga = %{version}-%{release} +Requires: %{php_cli} >= 5.3.0 %description -n icingacli -Icinga CLI using php-Icinga Icinga Web 2 backend. - -%package -n php-Icinga -Summary: Icinga Web 2 PHP Libraries -Group: Applications/System -Requires: %{name} = %{version}-%{release} -Requires: %{phpname} >= 5.3.0 -Requires: %{phpzendname} +Icinga CLI -%description -n php-Icinga -Icinga Web 2 PHP Libraries required by the web frontend and cli tool. +%package vendor-dompdf +Version: 0.6.1 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library dompdf +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-dompdf +Icinga Web 2 vendor library dompdf + + +%package vendor-HTMLPurifier +Version: 4.6.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library HTMLPurifier +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-HTMLPurifier +Icinga Web 2 vendor library HTMLPurifier + + +%package vendor-JShrink +Version: 1.0.1 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library JShrink +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-JShrink +Icinga Web 2 vendor library JShrink + + +%package vendor-lessphp +Version: 0.4.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library lessphp +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-lessphp +Icinga Web 2 vendor library lessphp + + +%package vendor-Parsedown +Version: 1.0.0 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library Parsedown +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-Parsedown +Icinga Web 2 vendor library Parsedown + + +%package vendor-Zend +Version: 1.12.9 +Release: 1%{?dist} +Summary: Icinga Web 2 vendor library Zend Framework +Group: Development/Libraries +Requires: %{php} >= 5.3.0 + +%description vendor-Zend +Icinga Web 2 vendor library Zend %prep -#VERSION=0.0.1; git archive --format=tar --prefix=icingaweb2-$VERSION/ HEAD | gzip >icingaweb2-$VERSION.tar.gz -%setup -q -n %{name}-%{version} +%setup -q %build %install -[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} - -# prepare configuration for sub packages - -# install rhel apache config -install -D -m0644 packages/files/apache/icingaweb.conf %{buildroot}/%{apacheconfdir}/icingaweb.conf - -# install public, library, modules -%{__mkdir} -p %{buildroot}/%{sharedir} -%{__mkdir} -p %{buildroot}/%{logdir} -%{__mkdir} -p %{buildroot}/%{docdir} -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name} -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/dashboard -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules/monitoring -%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/enabledModules - -# make sure to install local icingacli for setup wizard token generation & webserver config -%{__cp} -r application doc library modules public bin %{buildroot}/%{sharedir}/ - -# enable the monitoring module by default -ln -s %{sharedir}/modules/monitoring %{buildroot}/%{_sysconfdir}/%{name}/enabledModules/monitoring -## config - -# symlink icingacli -mkdir -p %{buildroot}/usr/bin -ln -sf %{sharedir}/bin/icingacli %{buildroot}/usr/bin/icingacli +rm -rf %{buildroot} +mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir}} +cp -prv application doc var %{buildroot}/%{basedir} +cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules +cp -prv library/Icinga %{buildroot}/%{phpdir} +cp -prv library/vendor %{buildroot}/%{basedir}/library +cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public +cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icingaweb2.conf +cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir} +cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public %pre -# Add apacheuser in the icingacmd group -# If the group exists, add the apacheuser in the icingacmd group. -# It is not neccessary that icinga2-web is installed on the same system as -# icinga and only on systems with icinga installed the icingacmd -# group exists. In all other cases the user used for ssh access has -# to be added to the icingacmd group on the remote icinga server. -getent group icingacmd > /dev/null - -if [ $? -eq 0 ]; then -%{_sbindir}/usermod %{usermodparam} icingacmd %{apacheuser} -fi - -%preun - -%post +getent group icingacmd >/dev/null || groupadd -r icingacmd +usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser} +exit 0 %clean -[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} +rm -rf %{buildroot} %files -# main dirs %defattr(-,root,root) -%doc etc/schema doc packages/RPM.md -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/public -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/modules -# configs +%{basedir}/application/controllers +%{basedir}/application/fonts +%{basedir}/application/forms +%{basedir}/application/layouts +%{basedir}/application/views +%{basedir}/doc +%{basedir}/modules +%{basedir}/public +%{wwwconfigdir}/icingaweb2.conf +%attr(2775,root,%{icingawebgroup}) %dir %{logdir} + + +%pre common +getent group %{icingawebgroup} >/dev/null || groupadd -r %{icingawebgroup} +exit 0 + +%files common %defattr(-,root,root) -%config(noreplace) %attr(-,root,root) %{apacheconfdir}/icingaweb.conf -%config(noreplace) %attr(-,%{apacheuser},%{apachegroup}) %{configdir} -# logs -%attr(2775,%{apacheuser},%{apachegroup}) %dir %{logdir} -# shipped docs -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/doc +%{basedir}/application/locale +%dir %{basedir}/modules +%attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir} + %files -n php-Icinga -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/application -%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/library +%defattr(-,root,root) +%{phpdir}/Icinga + %files -n icingacli -%attr(0755,root,root) /usr/bin/icingacli -%attr(0755,root,root) %{sharedir}/bin/icingacli -%attr(0755,root,root) %{sharedir}/bin/license_writer.py +%defattr(-,root,root) +%{basedir}/application/clicommands +%attr(0755,root,root) %{bindir}/icingacli -%changelog + +%files vendor-dompdf +%defattr(-,root,root) +%{basedir}/library/vendor/dompdf + + +%files vendor-HTMLPurifier +%defattr(-,root,root) +%{basedir}/library/vendor/HTMLPurifier + + +%files vendor-JShrink +%defattr(-,root,root) +%{basedir}/library/vendor/JShrink + + +%files vendor-lessphp +%defattr(-,root,root) +%{basedir}/library/vendor/lessphp + + +%files vendor-Parsedown +%defattr(-,root,root) +%{basedir}/library/vendor/Parsedown + + +%files vendor-Zend +%defattr(-,root,root) +%{basedir}/library/vendor/Zend