108 lines
2.0 KiB
PHP
108 lines
2.0 KiB
PHP
#!/usr/bin/php
|
|
<?php
|
|
|
|
// Paramètres
|
|
if ( $argc < 1 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
|
?>
|
|
Installation
|
|
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
|
|
|
|
Utilisation : <?php echo $argv[0]; ?> [action]
|
|
|
|
action :
|
|
--install : Configuration
|
|
|
|
<?php
|
|
exit;
|
|
}
|
|
|
|
$action = $argv[1];
|
|
$hostname = exec('echo $(hostname)');
|
|
$wwwroot = realpath(dirname(__FILE__).'/../../');
|
|
|
|
switch ($action)
|
|
{
|
|
case '--install':
|
|
writeConfig();
|
|
check();
|
|
copyFiles();
|
|
changePermission();
|
|
break;
|
|
}
|
|
|
|
/**
|
|
* Vérfie si l'utilisateur est ROOT
|
|
*/
|
|
function isRoot()
|
|
{
|
|
$uid = exec('echo $(id -u)');
|
|
if ((int) $uid == 0){
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function changePermission()
|
|
{
|
|
passthru('chown -R www-data: '.realpath(dirname(__FILE__).'/../'));
|
|
passthru('chmod -R +x '.realpath(dirname(__FILE__).'/../batch/').'/*.php');
|
|
}
|
|
|
|
function copyFiles()
|
|
{
|
|
passthru('cp -Rv '.realpath(dirname(__FILE__)).'/_files/kbis/styles '.
|
|
realpath(dirname(__FILE__)).'/../public/data/kbis/');
|
|
|
|
}
|
|
|
|
function check()
|
|
{
|
|
//Vérifier le lien symbolique de data dans public
|
|
if ( !is_link(realpath(dirname(__FILE__)).'/../public/data') ) {
|
|
echo "Erreur lien symbolique 'data'\n"; exit;
|
|
}
|
|
|
|
//Répertoire dans data
|
|
$directories = array(
|
|
'bodacc',
|
|
'csv',
|
|
'fichiers',
|
|
'kbis',
|
|
'log',
|
|
'marques',
|
|
'pdf',
|
|
'tables',
|
|
'wkhtml');
|
|
|
|
foreach ( $directories as $dir ) {
|
|
if ( !file_exists(realpath(dirname(__FILE__)).'/../public/data/'.$dir) ) {
|
|
echo "Erreur dossier ".$dir."\n";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function writeConfig()
|
|
{
|
|
global $hostname;
|
|
|
|
$arrayConfig = array(
|
|
'mysql.php',
|
|
'smtp.php',
|
|
'sphinx.php',
|
|
'stockage.php',
|
|
);
|
|
foreach($arrayConfig as $config) {
|
|
passthru('cp -v '.
|
|
realpath(dirname(__FILE__)).'/'.$hostname.'/'.$config.' ' .
|
|
realpath(dirname(__FILE__)).'/'.$config);
|
|
}
|
|
|
|
require_once realpath(dirname(__FILE__)).'/config.php';
|
|
|
|
if ( !file_exists(realpath(dirname(__FILE__)).'/../public/data/') )
|
|
passthru('ln -s '.DOC_WEB_LOCAL.' '.realpath(dirname(__FILE__)).'/../public/data');
|
|
}
|
|
|