2011-05-10 09:02:47 +00:00
|
|
|
<?php
|
|
|
|
//error_reporting(E_ALL & ~E_NOTICE);
|
|
|
|
|
|
|
|
// Define path to application directory
|
|
|
|
defined('APPLICATION_PATH')
|
2012-11-16 09:34:42 +00:00
|
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
2011-05-10 09:02:47 +00:00
|
|
|
|
|
|
|
// Define application environment
|
|
|
|
defined('APPLICATION_ENV')
|
|
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
|
|
|
|
// Ensure library/ is on include_path
|
|
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
|
|
get_include_path(),
|
|
|
|
)));
|
|
|
|
|
2014-12-19 14:13:42 +00:00
|
|
|
//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(
|
2015-07-16 15:42:55 +00:00
|
|
|
'Zend_Loader_ClassMapAutoloader' => array(
|
|
|
|
__DIR__ . '/../../library/autoload_classmap.php',
|
|
|
|
),
|
2014-12-19 14:13:42 +00:00
|
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
|
|
'prefixes' => array(
|
|
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
|
|
|
'SdMetier' => __DIR__ . '/../../library/SdMetier',
|
|
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
|
|
),
|
|
|
|
'fallback_autoloader' => true
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
2011-05-10 09:02:47 +00:00
|
|
|
try {
|
|
|
|
$opts = new Zend_Console_Getopt(
|
|
|
|
//Options
|
|
|
|
array(
|
|
|
|
'help|?' => "Affiche les informations d'utilisation",
|
2014-12-18 15:58:10 +00:00
|
|
|
'install=s' => "Installe et configure",
|
2014-08-19 07:46:54 +00:00
|
|
|
'incron' => "Create incron file",
|
|
|
|
'cron' => "Create cron file",
|
2011-05-10 09:02:47 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$opts->parse();
|
|
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
|
|
echo $e->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Usage
|
|
|
|
if(isset($opts->help))
|
|
|
|
{
|
|
|
|
echo $opts->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-05-05 13:08:24 +00:00
|
|
|
if(isset($opts->install))
|
2011-05-10 09:02:47 +00:00
|
|
|
{
|
2014-12-18 15:58:10 +00:00
|
|
|
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;
|
|
|
|
|
2015-06-01 12:30:29 +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-05-12 09:06:39 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2014-05-05 13:08:24 +00:00
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
// Create application, bootstrap, and run
|
|
|
|
$application = new Zend_Application(
|
|
|
|
APPLICATION_ENV,
|
|
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
|
|
);
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
2014-05-05 13:08:24 +00:00
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
//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);
|
|
|
|
}
|
2014-05-12 09:06:39 +00:00
|
|
|
}
|
2014-05-05 13:08:24 +00:00
|
|
|
|
|
|
|
if ( substr(strtoupper(PHP_OS),0,3) == 'WIN' ) {
|
|
|
|
|
2014-05-12 09:06:39 +00:00
|
|
|
echo "Windows OS : Créer les liens symboliques pour l'impression. Voir script.";
|
2014-05-05 13:08:24 +00:00
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//Création des liens symboliques pour l'impression
|
2014-12-18 15:58:10 +00:00
|
|
|
if ( ! file_exists($c->profil->path->pages.'/themes/default/images') )
|
2014-05-05 13:08:24 +00:00
|
|
|
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/images '.
|
|
|
|
$c->profil->path->pages.'/themes/default/images');
|
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
if ( ! file_exists($c->profil->path->pages.'/themes/default/scripts') )
|
2014-05-05 13:08:24 +00:00
|
|
|
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/scripts '.
|
|
|
|
$c->profil->path->pages.'/themes/default/scripts');
|
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
if ( ! file_exists($c->profil->path->pages.'/fichier/imgcache') )
|
2014-05-05 13:08:24 +00:00
|
|
|
passthru('ln -vs '.APPLICATION_PATH.'/../data/pages/imgcache'.' '.
|
|
|
|
$c->profil->path->pages.'/fichier/imgcache');
|
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
if ( ! file_exists($c->profil->path->pages.'/fichier/logo') )
|
2014-05-05 13:08:24 +00:00
|
|
|
passthru('ln -vs '.$c->profil->path->data.'/logos '.$c->profil->path->pages.'/fichier/logo');
|
|
|
|
|
|
|
|
//Modification des permissions
|
|
|
|
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
|
|
|
|
}
|
|
|
|
|
2014-12-18 15:58:10 +00:00
|
|
|
echo date('Y-m-d H:i:s')." - End.\n";
|
2014-08-19 07:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $opts->incron ) {
|
|
|
|
|
|
|
|
echo "Création configuration incron.\n";
|
|
|
|
|
2014-08-19 09:46:02 +00:00
|
|
|
if ( !file_exist('/etc/incron.d') ) {
|
|
|
|
echo "incron is not install !\n";
|
|
|
|
exit;
|
2014-08-19 07:46:54 +00:00
|
|
|
}
|
|
|
|
|
2014-08-19 09:46:02 +00:00
|
|
|
//Send bilanclient
|
|
|
|
file_put_contents('/etc/incron.d/bilanclient', $c->profil->path->data . "/bilanclient IN_CLOSE_WRITE php /home/vhosts/extranet/scripts/jobs/sendBilanClient.php --file $#");
|
|
|
|
|
2014-08-19 07:46:54 +00:00
|
|
|
echo "Don't forget to restart incron. sudo service incron restart.\n";
|
2014-05-05 13:08:24 +00:00
|
|
|
echo "Fin de la configuration.\n";
|
2011-05-10 09:02:47 +00:00
|
|
|
}
|
2014-08-19 07:46:54 +00:00
|
|
|
|
|
|
|
if ( $opts->cron ) {
|
|
|
|
|
|
|
|
echo "Création configuration cron.\n";
|
|
|
|
|
2014-08-19 09:46:02 +00:00
|
|
|
if ( !file_exist('/etc/cron.d') ) {
|
|
|
|
echo "cron is not install !\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//AltiScore
|
|
|
|
file_put_contents('/etc/cron.d/altiscore', "# AltiScore");
|
|
|
|
file_put_contents('/etc/cron.d/altiscore', "00 04 * * 1-5 www-data php /home/vhosts/extranet/scripts/jobs/getAltiScore.php --cron >> /home/vhosts/data/log/altiscore.log", FILE_APPEND);
|
|
|
|
|
2014-08-19 07:46:54 +00:00
|
|
|
echo "Don't forget to restart cron. sudo service cron restart.";
|
|
|
|
echo "End.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|