2010-09-22 09:19:17 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
// Paramètres
|
2010-09-27 07:38:07 +00:00
|
|
|
if ( $argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
2010-09-22 09:19:17 +00:00
|
|
|
?>
|
2010-09-22 15:27:56 +00:00
|
|
|
Installation
|
2010-09-22 09:19:17 +00:00
|
|
|
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
|
|
|
|
|
2011-10-06 14:10:14 +00:00
|
|
|
Utilisation : <?php echo $argv[0]; ?> options
|
2010-09-22 09:19:17 +00:00
|
|
|
|
2010-09-22 15:27:56 +00:00
|
|
|
options :
|
2011-10-06 14:10:14 +00:00
|
|
|
--install
|
|
|
|
Execute les actions de configuration suivant le serveur
|
2010-09-22 09:19:17 +00:00
|
|
|
<?php
|
|
|
|
exit;
|
|
|
|
}
|
2010-09-22 15:27:56 +00:00
|
|
|
|
|
|
|
/**
|
2011-10-06 14:10:14 +00:00
|
|
|
* Vérfie si l'utilisateur est ROOT
|
|
|
|
*/
|
2010-09-22 15:27:56 +00:00
|
|
|
function isRoot()
|
|
|
|
{
|
|
|
|
$uid = exec('echo $(id -u)');
|
|
|
|
if ((int) $uid == 0){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function hasConfig()
|
|
|
|
{
|
|
|
|
return file_exists(realpath(dirname(__FILE__)).'/config.inc');
|
|
|
|
}
|
|
|
|
|
|
|
|
function hasSymlink($symlink)
|
|
|
|
{
|
|
|
|
return is_link(PATH_SITE.'/'.$symlink);
|
|
|
|
}
|
|
|
|
|
2010-10-04 09:35:46 +00:00
|
|
|
function changePermission(){
|
2011-02-09 10:58:58 +00:00
|
|
|
passthru('chmod +x '.PATH_SITE.'/batch/*.php');
|
2010-10-04 09:35:46 +00:00
|
|
|
passthru('chmod +x '.PATH_SITE.'/includes/print/linux/*');
|
2010-12-17 14:50:13 +00:00
|
|
|
passthru('chown -R www-data: '.PATH_SITE);
|
2010-10-04 09:35:46 +00:00
|
|
|
}
|
|
|
|
|
2010-09-22 15:27:56 +00:00
|
|
|
function writeSymlinks(){
|
2010-09-24 09:10:30 +00:00
|
|
|
if( !file_exists(PATH_SITE.'/data') ) {
|
2010-09-24 09:58:03 +00:00
|
|
|
passthru('ln -vs '.realpath(dirname(__FILE__).'/../../data').' '.PATH_SITE.'/data');
|
2010-09-24 09:10:30 +00:00
|
|
|
}
|
2011-03-11 10:06:33 +00:00
|
|
|
if( !file_exists(PATH_SITE.'/cache/pages/img') ) {
|
2011-03-01 08:35:17 +00:00
|
|
|
passthru('ln -vs '.PATH_SITE.'/www/img '.PATH_SITE.'/cache/pages/img');
|
|
|
|
}
|
2011-03-11 10:06:33 +00:00
|
|
|
if( !file_exists(PATH_SITE.'/cache/pages/fichier/logos') ) {
|
2011-03-01 08:35:17 +00:00
|
|
|
passthru('ln -vs '.PATH_DATA.'/logos '.PATH_SITE.'/cache/pages/fichier/logos');
|
2010-09-22 15:27:56 +00:00
|
|
|
}
|
2011-03-01 08:35:17 +00:00
|
|
|
if( !file_exists(PATH_SITE.'/cache/pages/fichier/imgcache') ) {
|
|
|
|
passthru('ln -vs '.PATH_SITE.'/cache/pages/imgcache '.PATH_SITE.'/cache/pages/fichier/imgcache');
|
2010-09-22 15:27:56 +00:00
|
|
|
}
|
2011-10-06 14:10:14 +00:00
|
|
|
|
2010-09-22 15:27:56 +00:00
|
|
|
}
|
|
|
|
|
2010-09-24 09:25:45 +00:00
|
|
|
function writeConfig()
|
2010-09-22 15:27:56 +00:00
|
|
|
{
|
|
|
|
global $hostname;
|
2010-10-04 09:35:46 +00:00
|
|
|
passthru('cp -v '.realpath(dirname(__FILE__)).'/'.$hostname.'/config.inc '.realpath(dirname(__FILE__)).'/config.inc');
|
2010-09-22 15:27:56 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 16:03:57 +00:00
|
|
|
function checkDirectories()
|
|
|
|
{
|
|
|
|
$dirList = array(
|
|
|
|
'bilanclient',
|
|
|
|
'courrier',
|
|
|
|
'jo',
|
|
|
|
'log',
|
|
|
|
'logos',
|
|
|
|
'marques',
|
|
|
|
'pdf',
|
|
|
|
'asso',
|
|
|
|
);
|
|
|
|
foreach ($dirList as $dir) {
|
|
|
|
if (!file_exist(PATH_DATA.'/'.$dir)) {
|
|
|
|
mkdir(PATH_DATA.'/'.$dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-06 14:10:14 +00:00
|
|
|
|
|
|
|
$action = $argv[1];
|
|
|
|
$mode = strtoupper($argv[2]);
|
|
|
|
$hostname = exec('echo $(hostname)');
|
|
|
|
|
|
|
|
switch ($action)
|
|
|
|
{
|
|
|
|
case '--install':
|
|
|
|
//Création de la configuration
|
|
|
|
echo "Ecriture de la configuration\n";
|
|
|
|
writeConfig();
|
|
|
|
//Création des liens symboliques
|
|
|
|
require_once 'config.inc';
|
|
|
|
echo "Création des liens symboliques\n";
|
|
|
|
writeSymlinks();
|
|
|
|
//Vérification des répertoires de données
|
|
|
|
|
|
|
|
//Vérification du lien symbolique du projet
|
|
|
|
echo "Changement des permissions\n";
|
|
|
|
changePermission();
|
|
|
|
break;
|
|
|
|
}
|