From f19db0de9fbdd15c0b30a8b77cceb173eebc37b8 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 26 Nov 2014 14:05:39 +0000 Subject: [PATCH] New configure method, use profil to duplicate more easily on servers --- scripts/build/configure.php | 65 +++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/scripts/build/configure.php b/scripts/build/configure.php index 0816140f..dbd885d9 100644 --- a/scripts/build/configure.php +++ b/scripts/build/configure.php @@ -15,19 +15,6 @@ set_include_path(implode(PATH_SEPARATOR, array( get_include_path(), ))); -//Copy configuration -$configDir = realpath(dirname(__FILE__)).'/config'; -$appconfigDir = APPLICATION_PATH.'/configs'; -$hostname = exec('echo $(hostname)'); - -if ( !file_exists( $appconfigDir.'/application.ini') ) { - $result = copy($configDir.'/'.$hostname.'/application.ini', $appconfigDir.'/application.ini'); - if ($result !== true) { - echo date('Y-m-d H:i:s')." - Erreur lors de la configuration\n"; - exit(1); - } -} - //Use classmap autoloader - useful with opcode and realpath cache require_once 'Zend/Loader/AutoloaderFactory.php'; require_once 'Zend/Loader/ClassMapAutoloader.php'; @@ -54,18 +41,12 @@ Zend_Loader_AutoloaderFactory::factory(array( // Zend_Application - Use it if you don't have autoloaders //require_once 'Zend/Application.php'; -// Create application, bootstrap, and run -$application = new Zend_Application( - APPLICATION_ENV, - APPLICATION_PATH . '/configs/application.ini' -); - try { $opts = new Zend_Console_Getopt( //Options array( 'help|?' => "Affiche les informations d'utilisation", - 'install' => "Installe et configure", + 'install=s' => "Installe et configure", ) ); $opts->parse(); @@ -75,16 +56,38 @@ try { } //Usage -if(isset($opts->help)) +if (isset($opts->help)) { echo $opts->getUsageMessage(); exit; } -if(isset($opts->install)) + +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; + + if ( !file_exists( $appconfigDir.'/application.ini') ) { + $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); + } + } else { + echo date('Y-m-d H:i:s')." - Le profil de configuration existe déja.\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()); //Create data directory and all his children @@ -98,6 +101,11 @@ if(isset($opts->install)) mkdir(APPLICATION_PATH.'/../data/cache'); } + if ( !file_exists(APPLICATION_PATH.'/../data/cache') ) + { + mkdir(APPLICATION_PATH.'/../data/log'); + } + if ( !file_exists(APPLICATION_PATH.'/../data/files') ) { mkdir(APPLICATION_PATH.'/../data/files'); @@ -117,17 +125,18 @@ if(isset($opts->install)) // genCache.php // genCodeRatios.php - - if ( substr(strtoupper(PHP_OS),0,3) == 'WIN' ) { - - } else { - + if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) { //Copy files - passthru('cp -rv '.realpath(dirname(__FILE__)).'/config/_files/* '.$c->profil->path->files.'/'); + passthru('cp -rv '.realpath(dirname(__FILE__)).'/files/* '.$c->profil->path->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"; + } } //Check persistent data directories