2010-10-29 07:30:18 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// Paramètres
|
2011-02-02 13:24:07 +00:00
|
|
|
if ( $argc < 1 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
2010-10-29 07:30:18 +00:00
|
|
|
?>
|
|
|
|
Installation
|
|
|
|
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
|
|
|
|
|
2011-02-21 10:40:38 +00:00
|
|
|
Utilisation : <?php echo $argv[0]; ?> [action]
|
2010-10-29 07:30:18 +00:00
|
|
|
|
2011-02-21 10:40:38 +00:00
|
|
|
action :
|
2011-03-23 15:43:28 +00:00
|
|
|
- configure : Configuration
|
|
|
|
- install : Configuration, Switch entre version
|
2010-10-29 07:30:18 +00:00
|
|
|
|
|
|
|
<?php
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$action = $argv[1];
|
|
|
|
$hostname = exec('echo $(hostname)');
|
2010-10-29 13:33:20 +00:00
|
|
|
$wwwroot = realpath(dirname(__FILE__).'/../../');
|
2010-10-29 07:30:18 +00:00
|
|
|
|
|
|
|
switch ($action)
|
|
|
|
{
|
2011-03-23 15:43:28 +00:00
|
|
|
case 'configure':
|
2011-03-29 13:46:21 +00:00
|
|
|
if (!isRoot()) {
|
|
|
|
echo "Vous devez être ROOT pour utiliser ce script.\n";
|
|
|
|
exit;
|
|
|
|
}
|
2011-02-21 10:40:38 +00:00
|
|
|
writeConfig();
|
|
|
|
changePermission();
|
|
|
|
break;
|
|
|
|
|
2011-03-23 15:43:28 +00:00
|
|
|
case 'install':
|
2011-03-29 13:46:21 +00:00
|
|
|
/*
|
2011-03-23 15:43:28 +00:00
|
|
|
if (!isRoot()) {
|
|
|
|
echo "Vous devez être ROOT pour utiliser ce script.\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
writeConfig();
|
|
|
|
changePermission();
|
|
|
|
changePrimarySymlink();
|
2011-03-29 13:46:21 +00:00
|
|
|
passthru('php ../batch/genwsdl.php --all --host wse.scores-decisions.com:8081');
|
|
|
|
*/
|
2010-10-29 07:30:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Vérfie si l'utilisateur est ROOT
|
|
|
|
*/
|
|
|
|
function isRoot()
|
|
|
|
{
|
|
|
|
$uid = exec('echo $(id -u)');
|
|
|
|
if ((int) $uid == 0){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-23 15:43:28 +00:00
|
|
|
function changePermission()
|
|
|
|
{
|
2011-03-29 13:46:21 +00:00
|
|
|
passthru('chown -vR www-data: '.realpath(dirname(__FILE__).'/../'));
|
|
|
|
passthru('chmod -vR +x '.realpath(dirname(__FILE__).'/../batch/').'/*.php');
|
2010-10-29 07:30:18 +00:00
|
|
|
}
|
|
|
|
|
2011-03-23 15:43:28 +00:00
|
|
|
function changePrimarySymlink()
|
|
|
|
{
|
2011-03-29 13:46:21 +00:00
|
|
|
global $wwwroot;
|
2011-03-23 15:43:28 +00:00
|
|
|
passthru('rm '.$wwwroot.'/webservice');
|
|
|
|
passthru('ln -s '.realpath(dirname(__FILE__).'/../').' '.$wwwroot.'/webservice');
|
|
|
|
}
|
|
|
|
|
2010-10-29 07:30:18 +00:00
|
|
|
function writeConfig()
|
|
|
|
{
|
|
|
|
global $hostname;
|
2011-03-07 17:10:52 +00:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2010-10-29 07:30:18 +00:00
|
|
|
}
|
|
|
|
|