extranet/scripts/build/configure.php

121 lines
3.8 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(),
)));
2012-11-16 15:23:59 +00:00
//Copie de la configuration
$configDir = realpath(dirname(__FILE__)).'/config';
$appconfigDir = APPLICATION_PATH.'/configs';
$hostname = exec('echo $(hostname)');
if ( !file_exists( $appconfigDir.'/application.ini') ) {
copy($configDir.'/'.$hostname.'/application.ini', $appconfigDir.'/application.ini');
}
2012-11-16 15:23:59 +00:00
2011-05-10 09:02:47 +00:00
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche les informations d'utilisation",
2011-05-24 06:25:58 +00:00
'install' => "Installe et configure",
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 "Démarrage de la configuration.\n";
$c = new Zend_Config($application->getOptions());
2011-05-10 09:02:47 +00:00
2012-12-07 13:42:51 +00:00
//Create data directory and all his children
if ( !file_exists(APPLICATION_PATH.'/../data') ) exit(1);
if ( !file_exists(APPLICATION_PATH.'/../data/cache') )
mkdir(APPLICATION_PATH.'/../data/cache');
if ( !file_exists(APPLICATION_PATH.'/../data/cache/giant') )
mkdir(APPLICATION_PATH.'/../data/cache/giant');
if ( !file_exists(APPLICATION_PATH.'/../data/files') )
mkdir(APPLICATION_PATH.'/../data/files');
if ( !file_exists(APPLICATION_PATH.'/../data/infogreffe') )
mkdir(APPLICATION_PATH.'/../data/infogreffe');
if ( !file_exists(APPLICATION_PATH.'/../data/log') )
mkdir(APPLICATION_PATH.'/../data/log');
if ( !file_exists(APPLICATION_PATH.'/../data/rss') )
mkdir(APPLICATION_PATH.'/../data/rss');
if ( !file_exists(APPLICATION_PATH.'/../data/sessions') )
mkdir(APPLICATION_PATH.'/../data/sessions');
if ( !file_exists(APPLICATION_PATH.'/../data/wsdl') )
mkdir(APPLICATION_PATH.'/../data/wsdl');
if ( substr(strtoupper(PHP_OS),0,3) == 'WIN' ) {
echo "Windows OS : Créer les liens symboliques pour l'impression. Voir script d'install.";
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 "Fin de la configuration.\n";
2011-05-10 09:02:47 +00:00
}