enrichissement/config/configure.php

82 lines
1.6 KiB
PHP
Raw Normal View History

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;
2013-01-28 18:31:29 +01:00
//Copie de la configuration
2013-01-29 14:09:15 +01:00
$configDir = realpath(dirname(__FILE__)).'';
2013-01-28 18:31:29 +01:00
$appconfigDir = '../application/configs';
$hostname = exec('echo $(hostname)');
passthru('cp -fv '.
$configDir.'/'.$hostname.'/application.ini' . ' ' .
$appconfigDir.'/application.ini');
2012-01-13 17:08:10 +01:00
$arrayConfig = array(
2013-01-28 18:31:29 +01:00
'mysql.php',
'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
2012-01-13 17:08:10 +01:00
}