2013-11-05 11:18:30 +00:00
|
|
|
<?php
|
2015-08-06 20:22:11 +00:00
|
|
|
// --- Define path to application directory
|
2013-11-05 11:18:30 +00:00
|
|
|
defined('APPLICATION_PATH')
|
|
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
|
|
|
|
2015-08-06 20:22:11 +00:00
|
|
|
// --- Define application environment
|
2013-11-05 11:18:30 +00:00
|
|
|
defined('APPLICATION_ENV')
|
|
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
|
2015-08-06 20:22:11 +00:00
|
|
|
// --- Ensure library/ is on include_path
|
2013-11-05 11:18:30 +00:00
|
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
|
|
realpath(APPLICATION_PATH . '/../library'),
|
2015-08-06 20:22:11 +00:00
|
|
|
realpath(APPLICATION_PATH . '/../vendor/zendframework/zendframework1/library'),
|
2013-11-05 11:18:30 +00:00
|
|
|
get_include_path(),
|
|
|
|
)));
|
|
|
|
|
2015-08-06 20:22:11 +00:00
|
|
|
require_once realpath(APPLICATION_PATH . '/../vendor/autoload.php');
|
|
|
|
|
|
|
|
// --- Use classmap autoloader - useful with opcode and realpath cache
|
2014-02-07 16:14:36 +00:00
|
|
|
Zend_Loader_AutoloaderFactory::factory(array(
|
|
|
|
'Zend_Loader_ClassMapAutoloader' => array(
|
2015-07-28 14:39:52 +00:00
|
|
|
__DIR__ . '/../../library/autoload_classmap.php',
|
2014-02-07 16:14:36 +00:00
|
|
|
),
|
|
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
|
|
'prefixes' => array(
|
|
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
2014-05-24 16:57:17 +00:00
|
|
|
'SdMetier' => __DIR__ . '/../../library/SdMetier',
|
2014-02-07 16:14:36 +00:00
|
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
|
|
),
|
|
|
|
'fallback_autoloader' => true
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
2013-11-05 11:18:30 +00:00
|
|
|
try {
|
|
|
|
$opts = new Zend_Console_Getopt(
|
|
|
|
//Options
|
|
|
|
array(
|
|
|
|
'help|?' => "Affiche les informations d'utilisation",
|
2014-11-26 14:05:39 +00:00
|
|
|
'install=s' => "Installe et configure",
|
2013-11-05 11:18:30 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$opts->parse();
|
|
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
|
|
echo $e->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Usage
|
2014-11-26 14:05:39 +00:00
|
|
|
if (isset($opts->help))
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
|
|
|
echo $opts->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-11-26 14:05:39 +00:00
|
|
|
|
|
|
|
if ($opts->install)
|
2013-11-05 11:18:30 +00:00
|
|
|
{
|
2014-05-14 08:09:16 +00:00
|
|
|
echo date('Y-m-d H:i:s')." - Démarrage de la configuration.\n";
|
|
|
|
|
2014-11-26 14:05:39 +00:00
|
|
|
//Copy configuration
|
|
|
|
$configDir = realpath(dirname(__FILE__)).'/profil';
|
|
|
|
$appconfigDir = APPLICATION_PATH.'/configs';
|
|
|
|
$profil = $opts->install;
|
|
|
|
|
2015-07-03 13:28:52 +00:00
|
|
|
$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";
|
2014-11-26 14:05:39 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create application, bootstrap, and run
|
|
|
|
$application = new Zend_Application(
|
|
|
|
APPLICATION_ENV,
|
|
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
|
|
);
|
2014-05-14 08:09:16 +00:00
|
|
|
$c = new Zend_Config($application->getOptions());
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
//Create data directory and all his children
|
2014-11-26 20:11:01 +00:00
|
|
|
$dirToCreate = array(
|
|
|
|
APPLICATION_PATH.'/../data',
|
|
|
|
APPLICATION_PATH.'/../data/cache',
|
|
|
|
APPLICATION_PATH.'/../data/log',
|
|
|
|
APPLICATION_PATH.'/../data/files',
|
|
|
|
APPLICATION_PATH.'/../data/sessions',
|
|
|
|
APPLICATION_PATH.'/../data/wsdl',
|
|
|
|
);
|
|
|
|
foreach ($dirToCreate as $dir) {
|
|
|
|
if ( !file_exists($dir) ) {
|
|
|
|
mkdir($dir);
|
|
|
|
}
|
2014-10-30 14:19:21 +00:00
|
|
|
}
|
2014-05-14 08:09:16 +00:00
|
|
|
|
|
|
|
// Generate cache file
|
|
|
|
// genCache.php
|
2015-06-05 15:29:18 +00:00
|
|
|
passthru('php '.realpath(dirname(__FILE__)).'/genCache.php --generate Evenements');
|
2015-07-03 13:28:52 +00:00
|
|
|
|
2014-05-14 08:09:16 +00:00
|
|
|
// genCodeRatios.php
|
|
|
|
|
2014-11-26 14:05:39 +00:00
|
|
|
if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) {
|
2014-05-14 08:09:16 +00:00
|
|
|
//Copy files
|
2014-11-26 14:05:39 +00:00
|
|
|
passthru('cp -rv '.realpath(dirname(__FILE__)).'/files/* '.$c->profil->path->files.'/');
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-05-14 08:09:16 +00:00
|
|
|
//Modification des permissions
|
|
|
|
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
|
2013-11-05 11:18:30 +00:00
|
|
|
|
2014-11-26 14:05:39 +00:00
|
|
|
//Check WKHTMLTOPDF
|
|
|
|
$wkhtml = exec('echo $(which wkhtmltopdf)');
|
|
|
|
if ( empty(trim($wkhtml)) ) {
|
|
|
|
echo date('Y-m-d H:i:s')." - Warning : WKHTMLTOPDF non installé.\n";
|
|
|
|
}
|
2014-05-14 08:09:16 +00:00
|
|
|
}
|
2013-11-05 11:18:30 +00:00
|
|
|
|
|
|
|
//Check persistent data directories
|
2014-05-14 08:09:16 +00:00
|
|
|
if ( !file_exists($c->profil->path->data.'/log') ) {
|
|
|
|
echo date('Y-m-d H:i:s')." - Info répertoire ".$c->profil->path->data.'/log'. " non présent";
|
2013-11-05 11:18:30 +00:00
|
|
|
echo "\n";
|
|
|
|
}
|
|
|
|
|
2014-05-14 08:09:16 +00:00
|
|
|
echo date('Y-m-d H:i:s')." - Fin de la configuration.\n";
|
2013-11-05 11:18:30 +00:00
|
|
|
}
|