Utilisation de profil pour la configuration

This commit is contained in:
Michael RICOIS 2014-12-18 15:58:10 +00:00
parent 7a3052aea9
commit d76c91833f
6 changed files with 44 additions and 117 deletions

View File

@ -1,60 +0,0 @@
[production]
phpSettings.date.timezone = "Europe/Paris"
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.soap.wsdl_cache_dir = APPLICATION_PATH "/../data/wsdl"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.session.save_path = APPLICATION_PATH "/../data/sessions"
resources.useragent.mobile.features.path = APPLICATION_PATH "/../library/Zend/Http/UserAgent/Features/Adapter/Browscap.php"
resources.useragent.mobile.features.classname = "Zend_Http_UserAgent_Features_Adapter_Browscap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
resources.frontController.plugins.Theme = "Application_Controller_Plugin_Theme"
resources.frontController.plugins.Lang = "Application_Controller_Plugin_Lang"
resources.frontController.plugins.Menu = "Application_Controller_Plugin_Menu"
resources.frontController.plugins.Pdf = "Application_Controller_Plugin_Pdf"
resources.frontController.plugins.Xml = "Application_Controller_Plugin_Xml"
resources.frontController.plugins.Cgu = "Application_Controller_Plugin_Cgu"
resources.frontController.params.displayExceptions = 0
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/views/default"
resources.view.basePath = APPLICATION_PATH "/views/default"
; Scores configuration
profil.server.name = sd-13408
profil.webservice.location = celeste
profil.mail.method = sendmail
profil.mail.smtp_host =
profil.mail.username = yourusername
profil.mail.password = yourpassword
profil.mail.email.support = support@scores-decisions.com
profil.mail.email.supportdev = supportdev@scores-decisions.com
profil.mail.email.contact = contact@scores-decisions.com
profil.mail.email.production = production@scores-decisions.com
profil.path.cache = APPLICATION_PATH "/../data/cache"
profil.path.files = APPLICATION_PATH "/../data/files"
profil.path.pages = APPLICATION_PATH "/../data/pages"
profil.path.data = "/var/www/data"
profil.wkhtmltopdf.path = "/var/www/data/wkhtml/linux/wkhtmltopdf-i386"
profil.db.sdv1.adapter=mysqli
profil.db.sdv1.params.host=localhost
profil.db.sdv1.params.username=extranet
profil.db.sdv1.params.password=bGPZ9qYZQFHMYCnJ
profil.db.sdv1.params.dbname=sdv1
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
[staging : production]
resources.frontController.params.displayExceptions = 0
phpSettings.soap.wsdl_cache_enabled = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.soap.wsdl_cache_enabled = 0
resources.frontController.params.displayExceptions = 1
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

View File

@ -15,30 +15,12 @@ set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
)));
//Copie de la configuration
$configDir = realpath(dirname(__FILE__)).'/config';
$appconfigDir = APPLICATION_PATH.'/configs';
$hostname = exec('echo $(hostname)');
if ( !file_exists( $appconfigDir.'/application.ini') ) {
copy($configDir.'/'.$hostname.'/application.ini', $appconfigDir.'/application.ini');
}
/** Zend_Application */
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",
'incron' => "Create incron file",
'cron' => "Create cron file",
)
@ -58,45 +40,50 @@ if(isset($opts->help))
if(isset($opts->install))
{
echo "Démarrage de la configuration.\n";
echo date('Y-m-d H:i:s')." - Démarrage de la configuration.\n";
$c = new Zend_Config($application->getOptions());
//Copy configuration
$configDir = realpath(dirname(__FILE__)).'/profil';
$appconfigDir = APPLICATION_PATH.'/configs';
$profil = $opts->install;
//Create data directory and all his children
if ( !file_exists(APPLICATION_PATH.'/../data') ) {
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);
}
if ( !file_exists(APPLICATION_PATH.'/../data/cache') ) {
mkdir(APPLICATION_PATH.'/../data/cache');
}
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$c = new Zend_Config($application->getOptions());
if ( !file_exists(APPLICATION_PATH.'/../data/cache/giant') ) {
mkdir(APPLICATION_PATH.'/../data/cache/giant');
}
if ( !file_exists(APPLICATION_PATH.'/../data/files') ) {
mkdir(APPLICATION_PATH.'/../data/files');
}
if ( !file_exists(APPLICATION_PATH.'/../data/infogreffe') ) {
mkdir(APPLICATION_PATH.'/../data/infogreffe');
}
if ( !file_exists(APPLICATION_PATH.'/../data/log') ) {
mkdir(APPLICATION_PATH.'/../data/log');
}
if ( !file_exists(APPLICATION_PATH.'/../data/rss') ) {
mkdir(APPLICATION_PATH.'/../data/rss');
}
if ( !file_exists(APPLICATION_PATH.'/../data/sessions') ) {
mkdir(APPLICATION_PATH.'/../data/sessions');
}
if ( !file_exists(APPLICATION_PATH.'/../data/wsdl') ) {
mkdir(APPLICATION_PATH.'/../data/wsdl');
//Create data directory and all his children
//Create data directory and all his children
$dirToCreate = array(
APPLICATION_PATH.'/../data',
APPLICATION_PATH.'/../data/cache',
APPLICATION_PATH.'/../data/cache/giant',
APPLICATION_PATH.'/../data/files',
APPLICATION_PATH.'/../data/infogreffe',
APPLICATION_PATH.'/../data/log',
APPLICATION_PATH.'/../data/rss',
APPLICATION_PATH.'/../data/sessions',
APPLICATION_PATH.'/../data/wsdl',
APPLICATION_PATH.'/../data/sessions',
APPLICATION_PATH.'/../data/wsdl',
);
foreach ($dirToCreate as $dir) {
if ( !file_exists($dir) ) {
mkdir($dir);
}
}
if ( substr(strtoupper(PHP_OS),0,3) == 'WIN' ) {
@ -107,26 +94,26 @@ if(isset($opts->install))
} else {
//Création des liens symboliques pour l'impression
if (!file_exists($c->profil->path->pages.'/themes/default/images'))
if ( ! file_exists($c->profil->path->pages.'/themes/default/images') )
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/images '.
$c->profil->path->pages.'/themes/default/images');
if (!file_exists($c->profil->path->pages.'/themes/default/scripts'))
if ( ! file_exists($c->profil->path->pages.'/themes/default/scripts') )
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/scripts '.
$c->profil->path->pages.'/themes/default/scripts');
if (!file_exists($c->profil->path->pages.'/fichier/imgcache'))
if ( ! file_exists($c->profil->path->pages.'/fichier/imgcache') )
passthru('ln -vs '.APPLICATION_PATH.'/../data/pages/imgcache'.' '.
$c->profil->path->pages.'/fichier/imgcache');
if (!file_exists($c->profil->path->pages.'/fichier/logo'))
if ( ! file_exists($c->profil->path->pages.'/fichier/logo') )
passthru('ln -vs '.$c->profil->path->data.'/logos '.$c->profil->path->pages.'/fichier/logo');
//Modification des permissions
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
}
echo "End.\n";
echo date('Y-m-d H:i:s')." - End.\n";
}
if ( $opts->incron ) {