Nouvel configuration

This commit is contained in:
Michael RICOIS 2015-03-27 12:31:16 +00:00
parent a9433de92d
commit af4cca3338
4 changed files with 70 additions and 27 deletions

View File

@ -1,4 +1,3 @@
#!/usr/bin/php
<?php
//error_reporting(E_ALL & ~E_NOTICE);
@ -16,26 +15,35 @@ set_include_path(implode(PATH_SEPARATOR, array(
get_include_path(),
)));
//Copy configuration
$configDir = realpath(dirname(__FILE__)).'/config';
$hostname = exec('echo $(hostname)');
passthru('cp -fv '. $configDir.'/'.$hostname.'/application.ini '.APPLICATION_PATH.'/configs/application.ini');
//Use classmap autoloader - useful with opcode and realpath cache
require_once 'Zend/Loader/AutoloaderFactory.php';
require_once 'Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array(
'Zend_Loader_ClassMapAutoloader' => array(
__DIR__ . '/../../library/Zend/autoload_classmap.php',
__DIR__ . '/../../library/Application/autoload_classmap.php',
__DIR__ . '/../../application/autoload_classmap.php',
__DIR__ . '/../../library/Scores/autoload_classmap.php',
),
'Zend_Loader_StandardAutoloader' => array(
'prefixes' => array(
'Zend' => __DIR__ . '/../../library/Zend',
'Application' => __DIR__ . '/../../library/Application',
'Scores' => __DIR__ . '/../../library/Scores',
),
'fallback_autoloader' => true
)
));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Zend_Application - Use it if you don't have autoloaders
//require_once 'Zend/Application.php';
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();
@ -45,20 +53,55 @@ try {
}
//Usage
if(isset($opts->help))
if (isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
//Install
if(isset($opts->install))
{
//Création des répertoires
mkdir(APPLICATION_PATH . '/../data');
mkdir(APPLICATION_PATH . '/../data/sessions');
//Modification des permissions
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
passthru('chmod +x '.APPLICATION_PATH.'/../scripts/jobs/*.php');
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
$dirToCreate = array(
APPLICATION_PATH.'/../data',
APPLICATION_PATH.'/../data/sessions',
);
foreach ($dirToCreate as $dir) {
if ( !file_exists($dir) ) {
mkdir($dir);
}
}
if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) {
//Modification des permissions
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
}
echo date('Y-m-d H:i:s')." - Fin de la configuration.\n";
}

View File

@ -21,7 +21,7 @@ autoloaderNamespaces[] = "Application_"
autoloaderNamespaces[] = "Scores_"
; Scores configuration
profil.server.name = development
profil.server.name = sdsrvdev01
profil.webservice.location = sdsrvdev01
profil.mail.method = smtp
profil.mail.smtp_host = smtp.free.fr
@ -29,7 +29,7 @@ profil.mail.email.support = supportdev@scores-decisions.com
profil.mail.email.supportdev = supportdev@scores-decisions.com
profil.mail.email.contact = supportdev@scores-decisions.com
profil.mail.email.production = supportdev@scores-decisions.com
profil.path.data = "d:\www\dataciblage"
profil.path.data = "/home/vhosts/data/ciblage"
profil.db.metier.adapter=mysqli
profil.db.metier.params.host=192.168.78.230
@ -38,7 +38,7 @@ profil.db.metier.params.password=z7jq8AhvrwqQJ4Yb
profil.db.metier.params.dbname=ciblage
profil.db.metier.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
profil.sphinx.host=192.168.78.252
profil.sphinx.host=127.0.0.1
profil.sphinx.port=3312
[staging : production]