61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
#!/usr/bin/php
|
|
<?php
|
|
// Paramètres
|
|
if ( $argc < 2 || 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]; ?> options
|
|
options :
|
|
--install
|
|
<?php
|
|
exit;
|
|
}
|
|
|
|
$action = $argv[1];
|
|
$mode = strtoupper($argv[2]);
|
|
$hostname = exec('echo $(hostname)');
|
|
|
|
switch ($action)
|
|
{
|
|
case '--install':
|
|
//Création de la configuration
|
|
echo "Ecriture de la configuration\n";
|
|
writeConfig();
|
|
echo "Changement des permissions\n";
|
|
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()
|
|
{
|
|
require_once realpath(dirname(__FILE__)).'/../includes/config.php';
|
|
|
|
if (!file_exists(realpath(dirname(__FILE__).'/../html/data')))
|
|
passthru('ln -vs '.DOC_WEB_LOCAL.' '.realpath(dirname(__FILE__).'/../html/data'));
|
|
|
|
passthru('chown -R www-data: '.realpath(dirname(__FILE__).'/../'));
|
|
passthru('chmod -R +x '.realpath(dirname(__FILE__).'/../batch/').'/*.php');
|
|
}
|
|
|
|
function writeConfig()
|
|
{
|
|
global $hostname;
|
|
passthru('cp -v '.realpath(dirname(__FILE__)).'/'.$hostname.'/config.php '.realpath(dirname(__FILE__)).'/../includes/config.php');
|
|
}
|
|
|