예제 #1
0
파일: Install.php 프로젝트: rk4an/centreon
 /**
  * 
  */
 public static function installCentreon()
 {
     if (Migrate::checkForMigration()) {
         Migrate::migrateCentreon();
     } else {
         // Initialize configuration
         $di = Di::getDefault();
         $config = $di->get('config');
         $centreonPath = $config->get('global', 'centreon_path');
         $dbName = $config->get('db_centreon', 'dbname');
         // Check Php Dependencies
         $phpDependencies = json_decode(file_get_contents(rtrim($centreonPath, '/') . '/install/dependencies.json'));
         PhpDependencies::checkDependencies($phpDependencies);
         echo Colorize::colorizeMessage("Starting to install Centreon 3.0", "info") . "\n";
         echo "Creating " . Colorize::colorizeText('centreon', 'blue', 'black', true) . " database... ";
         // Install DB
         $migrationManager = new Manager('core', 'production');
         $migrationManager->generateConfiguration();
         $cmd = self::getPhinxCallLine() . 'migrate ';
         $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
         $cmd .= ' -e core';
         shell_exec($cmd);
         //Db::update('core');
         echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
         $modulesToInstall = self::getCoreModules();
         $dependencyResolver = new Dependency($modulesToInstall['modules']);
         $installOrder = $dependencyResolver->resolve();
         foreach ($installOrder as $moduleName) {
             $currentModule = $modulesToInstall['modules'][$moduleName];
             $moduleInstaller = new $currentModule['classCall']($currentModule['directory'], $currentModule['infos'], 'console');
             $moduleInstaller->install();
         }
         echo Colorize::colorizeMessage("Centreon 3.0 has been successfully installed", "success") . "\n";
     }
 }
예제 #2
0
 /**
  * Perform upgrade operation for module
  * 
  * @throws NotInstalledException
  */
 public function upgrade()
 {
     if (!Informations::isModuleInstalled($this->moduleSlug)) {
         $exceptionMessage = _("The given module is not installed");
         throw new NotInstalledException($this->colorizeMessage($exceptionMessage, 'danger'), 1109);
     }
     // Starting Message
     $message = _("Starting upgrade of %s module");
     $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'info'));
     // Performing pre operation check
     $this->checkOperationValidity('upgrade');
     // Set TemporaryVersion
     $this->versionManager->setTemporaryVersion('upgrade', true);
     $this->moduleId = Informations::getModuleIdByName($this->moduleSlug);
     // Install DB
     $migrationManager = new Manager($this->moduleSlug, 'production');
     $cmd = $this->getPhinxCallLine() . 'migrate ';
     $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
     $cmd .= ' -e ' . $this->moduleSlug;
     shell_exec($cmd);
     // Install menu
     $this->installMenu();
     // Install Forms
     $this->deployForms();
     // Install Hooks
     //$this->installHooks();
     // Deploy Children Menus and Forms
     if ($this->forceMode) {
         foreach ($this->chidlrenModules as $childrenModule) {
             $childrenModuleDirectory = Informations::getModulePath($childrenModule['name']);
             $this->deployChildrenForms($childrenModule, $childrenModuleDirectory);
             $this->installChildrenMenu($childrenModule, $childrenModuleDirectory);
         }
     }
     // Remove old static files and deploy new ones
     $this->removeStaticFiles();
     $this->deployStaticFiles();
     // Set Final Version
     $this->versionManager->setVersion($this->moduleInfo['version']);
     $this->versionManager->updateVersionInDb($this->moduleInfo['version']);
     // Ending Message
     $message = _("Upgrade of %s module complete");
     $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'success'));
 }
예제 #3
0
 /**
  * 
  * @cmdObject string module the module name
  * @cmdParam string class required 
  */
 public function createAction($object, $param)
 {
     $module = $object['module'];
     $class = $param['class'];
     $migrationManager = new Manager($module, 'development');
     $cmd = $this->getPhinxCallLine() . 'create ';
     $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
     $cmd .= ' ' . $class;
     shell_exec($cmd);
 }