2012-01-13 17:08:10 +01:00
|
|
|
#!/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();
|
|
|
|
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 changePrimarySymlink()
|
|
|
|
{
|
|
|
|
global $wwwroot;
|
|
|
|
passthru('rm '.$wwwroot.'/webservice');
|
|
|
|
passthru('ln -s '.realpath(dirname(__FILE__).'/../').' '.$wwwroot.'/webservice');
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeConfig()
|
|
|
|
{
|
|
|
|
global $hostname;
|
|
|
|
|
|
|
|
$arrayConfig = array(
|
|
|
|
'mysql.php',
|
2012-01-30 12:01:43 +01:00
|
|
|
'stockage.php',
|
2012-01-13 17:08:10 +01:00
|
|
|
);
|
|
|
|
foreach($arrayConfig as $config) {
|
|
|
|
passthru('cp -v '.
|
|
|
|
realpath(dirname(__FILE__)).'/'.$hostname.'/'.$config.' ' .
|
|
|
|
realpath(dirname(__FILE__)).'/'.$config);
|
|
|
|
}
|
2012-01-16 15:29:31 +01:00
|
|
|
passthru('cp -v '.
|
|
|
|
realpath(dirname(__FILE__)).'/'.$hostname.'/configuration.ini'.' '.
|
2012-01-16 15:30:09 +01:00
|
|
|
realpath(dirname(__FILE__)).'/../application/configs/configuration.ini');
|
2012-01-16 15:29:31 +01:00
|
|
|
|
2012-01-13 17:08:10 +01:00
|
|
|
}
|
|
|
|
|