extranet/scripts/build/configure.php

166 lines
5.3 KiB
PHP
Raw Normal View History

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",
'install=s' => "Installe et configure",
'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;
}
if(isset($opts->install))
2011-05-10 09:02:47 +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";
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/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' ) {
echo "Windows OS : Créer les liens symboliques pour l'impression. Voir script.";
echo "\n";
} else {
//Création des liens symboliques pour l'impression
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') )
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') )
passthru('ln -vs '.APPLICATION_PATH.'/../data/pages/imgcache'.' '.
$c->profil->path->pages.'/fichier/imgcache');
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 date('Y-m-d H:i:s')." - End.\n";
}
if ( $opts->incron ) {
echo "Création configuration incron.\n";
if ( !file_exist('/etc/incron.d') ) {
echo "incron is not install !\n";
exit;
}
//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 $#");
echo "Don't forget to restart incron. sudo service incron restart.\n";
echo "Fin de la configuration.\n";
2011-05-10 09:02:47 +00:00
}
if ( $opts->cron ) {
echo "Création configuration cron.\n";
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);
echo "Don't forget to restart cron. sudo service cron restart.";
echo "End.\n";
}