New configure method, use profil to duplicate more easily on servers
This commit is contained in:
parent
fe8613fa27
commit
f19db0de9f
@ -15,19 +15,6 @@ set_include_path(implode(PATH_SEPARATOR, array(
|
|||||||
get_include_path(),
|
get_include_path(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
//Copy configuration
|
|
||||||
$configDir = realpath(dirname(__FILE__)).'/config';
|
|
||||||
$appconfigDir = APPLICATION_PATH.'/configs';
|
|
||||||
$hostname = exec('echo $(hostname)');
|
|
||||||
|
|
||||||
if ( !file_exists( $appconfigDir.'/application.ini') ) {
|
|
||||||
$result = copy($configDir.'/'.$hostname.'/application.ini', $appconfigDir.'/application.ini');
|
|
||||||
if ($result !== true) {
|
|
||||||
echo date('Y-m-d H:i:s')." - Erreur lors de la configuration\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Use classmap autoloader - useful with opcode and realpath cache
|
//Use classmap autoloader - useful with opcode and realpath cache
|
||||||
require_once 'Zend/Loader/AutoloaderFactory.php';
|
require_once 'Zend/Loader/AutoloaderFactory.php';
|
||||||
require_once 'Zend/Loader/ClassMapAutoloader.php';
|
require_once 'Zend/Loader/ClassMapAutoloader.php';
|
||||||
@ -54,18 +41,12 @@ Zend_Loader_AutoloaderFactory::factory(array(
|
|||||||
// Zend_Application - Use it if you don't have autoloaders
|
// Zend_Application - Use it if you don't have autoloaders
|
||||||
//require_once 'Zend/Application.php';
|
//require_once 'Zend/Application.php';
|
||||||
|
|
||||||
// Create application, bootstrap, and run
|
|
||||||
$application = new Zend_Application(
|
|
||||||
APPLICATION_ENV,
|
|
||||||
APPLICATION_PATH . '/configs/application.ini'
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$opts = new Zend_Console_Getopt(
|
$opts = new Zend_Console_Getopt(
|
||||||
//Options
|
//Options
|
||||||
array(
|
array(
|
||||||
'help|?' => "Affiche les informations d'utilisation",
|
'help|?' => "Affiche les informations d'utilisation",
|
||||||
'install' => "Installe et configure",
|
'install=s' => "Installe et configure",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$opts->parse();
|
$opts->parse();
|
||||||
@ -75,16 +56,38 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Usage
|
//Usage
|
||||||
if(isset($opts->help))
|
if (isset($opts->help))
|
||||||
{
|
{
|
||||||
echo $opts->getUsageMessage();
|
echo $opts->getUsageMessage();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($opts->install))
|
|
||||||
|
if ($opts->install)
|
||||||
{
|
{
|
||||||
echo date('Y-m-d H:i:s')." - Démarrage de la configuration.\n";
|
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());
|
$c = new Zend_Config($application->getOptions());
|
||||||
|
|
||||||
//Create data directory and all his children
|
//Create data directory and all his children
|
||||||
@ -98,6 +101,11 @@ if(isset($opts->install))
|
|||||||
mkdir(APPLICATION_PATH.'/../data/cache');
|
mkdir(APPLICATION_PATH.'/../data/cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !file_exists(APPLICATION_PATH.'/../data/cache') )
|
||||||
|
{
|
||||||
|
mkdir(APPLICATION_PATH.'/../data/log');
|
||||||
|
}
|
||||||
|
|
||||||
if ( !file_exists(APPLICATION_PATH.'/../data/files') )
|
if ( !file_exists(APPLICATION_PATH.'/../data/files') )
|
||||||
{
|
{
|
||||||
mkdir(APPLICATION_PATH.'/../data/files');
|
mkdir(APPLICATION_PATH.'/../data/files');
|
||||||
@ -117,17 +125,18 @@ if(isset($opts->install))
|
|||||||
// genCache.php
|
// genCache.php
|
||||||
// genCodeRatios.php
|
// genCodeRatios.php
|
||||||
|
|
||||||
|
if ( substr(strtoupper(PHP_OS),0,3) != 'WIN' ) {
|
||||||
if ( substr(strtoupper(PHP_OS),0,3) == 'WIN' ) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
//Copy files
|
//Copy files
|
||||||
passthru('cp -rv '.realpath(dirname(__FILE__)).'/config/_files/* '.$c->profil->path->files.'/');
|
passthru('cp -rv '.realpath(dirname(__FILE__)).'/files/* '.$c->profil->path->files.'/');
|
||||||
|
|
||||||
//Modification des permissions
|
//Modification des permissions
|
||||||
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
|
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
|
||||||
|
|
||||||
|
//Check WKHTMLTOPDF
|
||||||
|
$wkhtml = exec('echo $(which wkhtmltopdf)');
|
||||||
|
if ( empty(trim($wkhtml)) ) {
|
||||||
|
echo date('Y-m-d H:i:s')." - Warning : WKHTMLTOPDF non installé.\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check persistent data directories
|
//Check persistent data directories
|
||||||
|
Loading…
Reference in New Issue
Block a user