-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic structure for the installation routine
refs #3761
- Loading branch information
Johannes Meyer
committed
Oct 11, 2013
1 parent
c38ae72
commit 8fe60fd
Showing
4 changed files
with
327 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
/** | ||
* This file is part of Icinga 2 Web. | ||
* | ||
* Icinga 2 Web - Head for multiple monitoring backends. | ||
* Copyright (C) 2013 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 2013 Icinga Development Team <info@icinga.org> | ||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 | ||
* @author Icinga Development Team <info@icinga.org> | ||
*/ | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Installer\Pages; | ||
|
||
/** | ||
* Wizard-Page that shows the user an installation result/report | ||
*/ | ||
class EndForm extends WizardForm | ||
{ | ||
/** | ||
* Whether the installation succeeded | ||
* | ||
* @var bool | ||
*/ | ||
private $success; | ||
|
||
/** | ||
* The result to present | ||
* | ||
* @var array | ||
*/ | ||
private $result; | ||
|
||
/** | ||
* Set the result that is shown to the user | ||
* | ||
* @param array $result The result to show | ||
*/ | ||
public function setResult(array $result) | ||
{ | ||
$this->result = $result; | ||
} | ||
|
||
public function create() | ||
{ | ||
$this->addNote('End', 1); | ||
|
||
foreach ($this->result as $title => $lines) { | ||
$this->addNote($title, 2); | ||
$this->addNote(implode('<br />', $lines)); | ||
} | ||
|
||
if ($this->success) { | ||
$this->addNote( | ||
'<span style="font-weight:bold;">The installation has successfully completed!</span>' . | ||
' You can now start exploring icingaweb by clicking "Finish". (Remember the default' . | ||
' admin user you have defined earlier!)' | ||
); | ||
$this->setSubmitLabel('Finish'); | ||
} else { | ||
$this->addNote( | ||
'<span style="font-weight:bold;">The installation seems to have failed!</span>' . | ||
' Please fix the issues and retry the installation.' | ||
); | ||
$this->setSubmitLabel('Retry installation'); | ||
} | ||
} | ||
|
||
/** | ||
* Inform the user that the installation has failed | ||
*/ | ||
public function retryInstallation() | ||
{ | ||
$this->success = false; | ||
$this->stayOnPage(); | ||
} | ||
|
||
/** | ||
* Inform the user that the installation was successful | ||
*/ | ||
public function finishInstallation() | ||
{ | ||
$this->success = true; | ||
$this->endWizard(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
/** | ||
* This file is part of Icinga 2 Web. | ||
* | ||
* Icinga 2 Web - Head for multiple monitoring backends. | ||
* Copyright (C) 2013 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 2013 Icinga Development Team <info@icinga.org> | ||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 | ||
* @author Icinga Development Team <info@icinga.org> | ||
*/ | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Application; | ||
|
||
use \Exception; | ||
use \Zend_Config; | ||
|
||
class Installer | ||
{ | ||
/** | ||
* The configuration directory to use | ||
* | ||
* @var string | ||
*/ | ||
private $configDir; | ||
|
||
/** | ||
* The installation options to use | ||
* | ||
* @var Zend_Config | ||
*/ | ||
private $options; | ||
|
||
/** | ||
* The installation "log" | ||
* | ||
* @var array | ||
*/ | ||
private $result; | ||
|
||
/** | ||
* Whether the installation failed | ||
* | ||
* @var bool | ||
*/ | ||
private $failed; | ||
|
||
/** | ||
* Initialise a new icingaweb installer | ||
* | ||
* @param string $configDir The configuration directory to use | ||
* @param Zend_Config $options The installation options to use | ||
*/ | ||
public function __construct($configDir, Zend_Config $options) | ||
{ | ||
$this->configDir = $configDir; | ||
$this->options = $options; | ||
$this->result = array(); | ||
$this->failed = false; | ||
} | ||
|
||
/** | ||
* Get the installation result | ||
* | ||
* @return array | ||
*/ | ||
public function getResult() | ||
{ | ||
return $this->result; | ||
} | ||
|
||
/** | ||
* Return whether the installation failed | ||
* | ||
* @return bool | ||
*/ | ||
public function hasFailed() | ||
{ | ||
return $this->failed; | ||
} | ||
|
||
/** | ||
* Run the installation | ||
* | ||
* @return array | ||
*/ | ||
public function run() | ||
{ | ||
try { | ||
$this->setupResources(); | ||
$this->setupAuthentication(); | ||
$this->setupPreferences(); | ||
$this->setupDefaultAdmin(); | ||
$this->setupBackend(); | ||
} catch (Exception $error) { | ||
// TODO: Log this exception? (To the logfile, not $this->log()!) | ||
$this->failed = true; | ||
return; | ||
} | ||
|
||
$this->finalize(); | ||
} | ||
|
||
/** | ||
* Log a result message | ||
* | ||
* @param string $section The section/title for which the message is for | ||
* @param string $message The message | ||
*/ | ||
private function log($section, $message) | ||
{ | ||
if (!array_key_exists($section, $this->result)) { | ||
$this->result[$section] = array(); | ||
} | ||
|
||
array_push($this->result[$section], $message); | ||
} | ||
|
||
/** | ||
* Set up the resources.ini | ||
*/ | ||
private function setupResources() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Set up the authentication.ini | ||
*/ | ||
private function setupAuthentication() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Set up the preferences (config.ini) | ||
*/ | ||
private function setupPreferences() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Set up the default admin user | ||
*/ | ||
private function setupDefaultAdmin() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Set up the initial backend | ||
*/ | ||
private function setupBackend() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Do any finalization steps | ||
*/ | ||
private function finalize() | ||
{ | ||
|
||
} | ||
} |