Script de configuration
This commit is contained in:
parent
e0bf62b8fa
commit
223eae4784
77
config/configure.php
Normal file
77
config/configure.php
Normal file
@ -0,0 +1,77 @@
|
||||
#!/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',
|
||||
'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';
|
||||
|
||||
passthru('ln -s '.DOC_WEB_LOCAL.' '.realpath(dirname(__FILE__)).'/../public/data');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user