"Affiche les informations d'utilisation", 'install=s' => "Installe et configure", ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } //Usage if (isset($opts->help)) { echo $opts->getUsageMessage(); exit; } if ($opts->install) { echo date('Y-m-d H:i:s')." - Démarrage de la configuration.\n"; // --- Copy configuration $configDir = realpath(dirname(__FILE__)).'/profil'; $appconfigDir = APPLICATION_PATH.'/configs'; $profil = $opts->install; $result = copy($configDir.'/'.$profil.'/application.ini', $appconfigDir.'/application.ini'); if ($result !== true) { echo date('Y-m-d H:i:s')." - Impossible de copier la configuration.\n"; exit(1); } // --- Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $c = new Zend_Config($application->getOptions()); // Generate cache file // genCache.php passthru('php '.realpath(dirname(__FILE__)).'/genCache.php --generate Evenements'); // genCodeRatios.php if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) { // --- Copy files passthru('cp -rv '.realpath(dirname(__FILE__)).'/files/* '.$c->profil->path->shared.'/files/'); // --- Modification des permissions passthru('chown -R www-data: '.APPLICATION_PATH.'/../'); // --- Check WKHTMLTOPDF $wkhtml = exec('echo $(which wkhtmltopdf)'); if ( empty(trim($wkhtml)) ) { echo date('Y-m-d H:i:s')." - Warning : WKHTMLTOPDF non installé.\n"; } } // --- Create data directory and all his children $path = $c->profil->path->shared; $dirToCreate = array( $path.'/cache', $path.'/files', $path.'/log', $path.'/sessions', $path.'/wsdl', ); foreach ($dirToCreate as $dir) { if (in_array($dir, array('sessions', 'wsdl')) ) { passthru('rm -rf '.$dir); } if ( ! file_exists($dir) ) { mkdir($dir, 0777, true); // --- Modification des permissions passthru('chown -Rv www-data: '.$dir); } } // --- Release $projectPath = str_replace('/shared', '', $c->profil->path->shared); $releasePath = realpath(str_replace('/application', '', APPLICATION_PATH)); passthru("rm -v ".$projectPath."/current"); passthru("ln -sv ".$releasePath." ".$projectPath."/current"); echo date('Y-m-d H:i:s')." - Fin de la configuration.\n"; }