webservice/scripts/build/configure.php

100 lines
3.0 KiB
PHP
Raw Normal View History

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')
2015-09-17 19:57:13 +00:00
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
2013-11-05 11:18:30 +00:00
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-09-18 09:53:21 +00:00
// --- Composer autoload
2015-09-17 19:57:13 +00:00
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
2014-02-07 16:14:36 +00:00
2013-11-05 11:18:30 +00:00
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche les informations d'utilisation",
'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
if (isset($opts->help))
2013-11-05 11:18:30 +00:00
{
echo $opts->getUsageMessage();
exit;
}
if ($opts->install)
2013-11-05 11:18:30 +00:00
{
echo date('Y-m-d H:i:s')." - Démarrage de la configuration.\n";
2016-01-25 15:41:01 +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";
exit(1);
}
2015-09-17 19:57:13 +00:00
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$c = new Zend_Config($application->getOptions());
2013-11-05 11:18:30 +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
// genCodeRatios.php
if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) {
2016-01-25 15:41:01 +00:00
// --- Copy files
passthru('cp -rv '.realpath(dirname(__FILE__)).'/files/* '.$c->profil->path->shared.'/files/');
2013-11-05 11:18:30 +00:00
2016-01-25 15:41:01 +00:00
// --- Modification des permissions
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
2013-11-05 11:18:30 +00:00
2016-01-25 15:41:01 +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";
}
}
2013-11-05 11:18:30 +00:00
2016-01-25 15:41:01 +00:00
// --- Create data directory and all his children
$path = $c->profil->path->shared;
$dirToCreate = array(
$path.'/cache',
$path.'/files',
2016-01-26 08:36:44 +00:00
$path.'/log',
2016-01-25 15:41:01 +00:00
$path.'/sessions',
$path.'/wsdl',
);
foreach ($dirToCreate as $dir) {
if ( file_exists($dir) ) {
passthru("rm -rfv ".$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 -vs ".$releasePath." ".$projectPath."/current");
2013-11-05 11:18:30 +00:00
echo date('Y-m-d H:i:s')." - Fin de la configuration.\n";
2013-11-05 11:18:30 +00:00
}