84 lines
2.1 KiB
PHP
84 lines
2.1 KiB
PHP
#!/usr/bin/php
|
|
<?php
|
|
// Paramètres
|
|
if ( count($argc)<1 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
|
?>
|
|
Utilisation : <?php echo $argv[0]; ?> [actions]
|
|
|
|
Installation :
|
|
- install list
|
|
- install version
|
|
Configuration :
|
|
- config initscript
|
|
- config logrotate
|
|
- config list
|
|
- config server *.conf
|
|
<?php
|
|
exit;
|
|
}
|
|
$hostname = exec('echo $HOSTNAME');
|
|
|
|
$SPHINX_VERSION = array(
|
|
'0.9.9' => array('archive'=>'sphinx-0.9.9.tar.gz', 'dir'=>'sphinx-0.9.9'),
|
|
'1.10' => array('archive'=>'sphinx-1.10-beta.tar.gz', 'dir'=>'sphinx-1.10-beta'),
|
|
'2.0.2' => array('archive'=>'sphinx-2.0.2-beta.tar.gz', 'dir'=>'sphinx-2.0.2-beta'),
|
|
'2.0.3' => array('archive'=>'sphinx-2.0.3-release.tar.gz', 'dir'=>'sphinx-2.0.3-release'),
|
|
'2.0.4' => array('archive'=>'sphinx-2.0.4-release.tar.gz', 'dir'=>'sphinx-2.0.4-release'),
|
|
);
|
|
|
|
if ($argv[1]=='install')
|
|
{
|
|
//Version
|
|
if (!array_key_exists($argv[2], $SPHINX_VERSION)){
|
|
exit;
|
|
}
|
|
$version = $argv[2];
|
|
|
|
//Compilation
|
|
$cmd = array();
|
|
$cmd[] = "tar xzvf ".$SPHINX_VERSION[$version]['archive'];
|
|
$cmd[] = "cp libstemmer_c.tgz ".$SPHINX_VERSION[$version]['dir']."/";
|
|
$cmd[] = "cd ".$SPHINX_VERSION[$version]['dir']."/";
|
|
$cmd[] = "tar xzvf libstemmer_c.tgz";
|
|
$cmd[] = "./configure --with-libstemmer --prefix=/usr/local/sphinx";
|
|
$cmd[] = "make";
|
|
$cmd[] = "make install";
|
|
foreach($cmd as $c){
|
|
passthru($c);
|
|
}
|
|
}
|
|
|
|
if ($argv[1]=='config')
|
|
{
|
|
//Initscript
|
|
if ($argv[2]=='initscript') {
|
|
exec("cp -v initscript/sphinxsearch /etc/init.d/");
|
|
exit;
|
|
}
|
|
//Logrotate
|
|
if ($argv[2]=='logrotate') {
|
|
echo exec("which logrotate");
|
|
exec("cp -v logrotate/searchd /etc/logrotate.d/");
|
|
exit;
|
|
}
|
|
|
|
//Liste des configuration
|
|
if ($argv[2]=='list') {
|
|
echo passthru("tree config/".$hostname."/");
|
|
exit;
|
|
}
|
|
|
|
//Configuration
|
|
if (!file_exist("config/".$hostname."/".$argv[2])){
|
|
echo "Erreur\n"; exit;
|
|
}
|
|
$server = $argv[2];
|
|
|
|
$concat = '';
|
|
for($i=3;$i<count($argc);$i++){
|
|
$concat.= "config/".$hostname."/".$server."/".$argv[$i];
|
|
}
|
|
exec("cat config/".$hostname."/".$server."/sphinx.conf ".$concact." > /usr/local/sphinx/etc/sphinx.conf");
|
|
}
|
|
|