2011-10-24 09:07:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
PATH_BIN=/usr/local/sphinx/bin
|
|
|
|
PATH_LOG=/dbs/sphinxlog
|
|
|
|
|
|
|
|
DATE=`date '+%Y-%m-%d %H-%M-%S'`
|
|
|
|
|
|
|
|
echo "DEBUT de l'indexation ==== $(date +%H:%M:%S)" >> $PATH_LOG/indexerEtab-$(date +%F).log
|
|
|
|
|
|
|
|
# nombre de lignes dans la table etab
|
|
|
|
output=$(mysql -h192.168.3.30 -usphinx -pindexer jo < sql/countEtab.sql)
|
|
|
|
for line in "$output"; do
|
|
|
|
etab="$line"
|
|
|
|
done
|
|
|
|
# Suppression fin de ligne
|
|
|
|
etab=$(echo $etab|sed -e "s/^[etab ]*//g"||sed -e "s/[ ]*$//g")
|
|
|
|
# Cast de la variable au cas ou
|
|
|
|
#etab=$(echo $etab| gawk '{print + 0}')
|
|
|
|
|
|
|
|
# nombre de lignes dans la table etab_tmp
|
|
|
|
output=$(mysql -h192.168.3.30 -usphinx -pindexer jo < sql/countEtab_tmp.sql)
|
|
|
|
for line in "$output"; do
|
|
|
|
etab_tmp="$line"
|
|
|
|
done
|
|
|
|
# Suppression fin de ligne
|
|
|
|
etab_tmp=$(echo $etab_tmp|sed -e "s/^[etab_tmp ]*//g"||sed -e "s/[ ]*$//g")
|
|
|
|
# Cast de la variable au cas ou
|
|
|
|
#etab_tmp=$(echo $etab_tmp| gawk '{print + 0}')
|
|
|
|
|
|
|
|
# Comparaison du nombre de lignes entre etab (ancien) et etab_tmp (nouveau)
|
|
|
|
if test $etab_tmp -gt $etab; then
|
|
|
|
echo "Il y a $etab_tmp lignes dans la nouvelle table etablissement ($etab lignes dans l'ancienne)" >> $PATH_LOG/indexerEtab-$(date +%F).log
|
|
|
|
# $PATH_BIN/indexer --rotate --all >> $PATH_LOG/indexer-$(date +%F).log
|
|
|
|
$PATH_BIN/indexer --rotate ent ent_mns ent_phx >> $PATH_LOG/indexerEtab-$(date +%F).log
|
|
|
|
echo "Sphinx - terminé : $(date +%H:%M:%S)" >> $PATH_LOG/indexerEtab-$(date +%F).log
|
2011-11-25 17:21:43 +01:00
|
|
|
mysql -f -usphinx -h192.168.3.30 -pindexer jo < sql/finIndexationEtab.sql >> $PATH_LOG/indexerEtab-$(date +%F).log
|
2011-10-24 09:07:16 +02:00
|
|
|
else
|
|
|
|
# Il y a plus de lignes dans l'ancienne table etablissements ==> On ne fait rien
|
|
|
|
echo "Il n'y a pas assez de lignes dans la nouvelle table etablissement ($etab_tmp / $etab) !" >> $PATH_LOG/indexerEtab-$(date +%F).log
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "FIN ===== $(date +%H:%M:%S)" >> $PATH_LOG/indexerEtab-$(date +%F).log
|