issue #0001933 : Prepare file name and update
This commit is contained in:
parent
589da22cda
commit
04f472bc86
48
indexer/indexer-dir.sh
Executable file
48
indexer/indexer-dir.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION DIR" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Nombre de lignes dans la table actuelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-dir.sql)
|
||||
for line in "$output"; do
|
||||
nbC="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbC=$(echo $nbC|sed -e "s/^[nbC ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Nombre de lignes dans la table nouvelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-dirtmp.sql)
|
||||
for line in "$output"; do
|
||||
nbT="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Comparaison du nombre de lignes entre nbC (ancien) et nbT (nouveau)
|
||||
if [ -z "$nbC" ]; then
|
||||
echo "etab = null"
|
||||
elif [ -z "$nbT" ]; then
|
||||
echo "etab_tmp = null"
|
||||
elif [ $nbT -gt $nbC ]; then
|
||||
|
||||
echo "Il y a $nbT lignes dans la nouvelle table dirigeants ($nbC lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
# Sphinx rotate
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate dir dir_phx >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Rotation des tables MySQL
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-dir.sql >> $PATH_LOG/indexer.log
|
||||
|
||||
else
|
||||
# Il y a plus de lignes dans l'ancienne table dirigeants ==> On ne fait rien
|
||||
echo "Il n'y a pas assez de lignes dans la nouvelle table dirigeants ($nbT / $nbC) !" >> $PATH_LOG/indexer.log
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION DIR" >> $PATH_LOG/indexer.log
|
49
indexer/indexer-etab.sh
Executable file
49
indexer/indexer-etab.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Nombre de lignes dans la table actuelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-ent.sql)
|
||||
for line in "$output"; do
|
||||
nbC="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbC=$(echo $nbC|sed -e "s/^[nbC ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Nombre de lignes dans la table nouvelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-enttmp.sql)
|
||||
for line in "$output"; do
|
||||
nbT="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Comparaison du nombre de lignes entre etab (ancien) et etab_tmp (nouveau)
|
||||
if [ -z "$nbC" ]; then
|
||||
echo "nbC = null"
|
||||
elif [ -z "$nbT" ]; then
|
||||
echo "nbT = null"
|
||||
elif [ $nbT -gt $nbC ]; then
|
||||
|
||||
echo "Il y a $nbT lignes dans la nouvelle table etablissement ($nbC lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Sphinx rotate
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate ent ent_phx >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Rotation des tables MySQL
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-ent.sql >> $PATH_LOG/indexer.log
|
||||
|
||||
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 ($nbT / $nbC) !" >> $PATH_LOG/indexer.log
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION ENT" >> $PATH_LOG/indexer.log
|
@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === DEBUT de l'indexation" >> $PATH_LOG/indexer.log
|
||||
|
||||
# nombre de lignes dans la table etab
|
||||
output=$(mysql -h192.168.3.30 -usphinx -pindexer jo < $PATH_SQL/countDiri.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")
|
||||
|
||||
# nombre de lignes dans la table diri_tmp
|
||||
output=$(mysql -h192.168.3.30 -usphinx -pindexer jo < $PATH_SQL/countDiri_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")
|
||||
|
||||
# Comparaison du nombre de lignes entre etab (ancien) et etab_tmp (nouveau)
|
||||
if [ -z "$etab" ]; then
|
||||
echo "etab = null"
|
||||
elif [ -z "$etab_tmp" ]; then
|
||||
echo "etab_tmp = null"
|
||||
elif [ $etab_tmp -gt $etab ]; then
|
||||
echo "Il y a $etab_tmp lignes dans la nouvelle table dirigeants ($etab lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate dir dir_phx >> $PATH_LOG/indexer.log
|
||||
echo "Sphinx - termine : $(date +%H:%M:%S)" >> $PATH_LOG/indexer.log
|
||||
mysql -f -usphinx -h192.168.3.30 -pindexer jo < $PATH_SQL/finIndexationDiri.sql >> $PATH_LOG/indexer.log
|
||||
else
|
||||
# Il y a plus de lignes dans l'ancienne table dirigeants ==> On ne fait rien
|
||||
echo "Il n'y a pas assez de lignes dans la nouvelle table dirigeants ($etab_tmp / $etab) !" >> $PATH_LOG/indexer.log
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN" >> $PATH_LOG/indexer.log
|
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === DEBUT de l'indexation" >> $PATH_LOG/indexer.log
|
||||
|
||||
# nombre de lignes dans la table etab
|
||||
output=$(mysql -h192.168.3.30 -usphinx -pindexer jo < $PATH_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 < $PATH_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 [ -z "$etab" ]; then
|
||||
echo "etab = null"
|
||||
elif [ -z "$etab_tmp" ]; then
|
||||
echo "etab_tmp = null"
|
||||
elif [ $etab_tmp -gt $etab ]; then
|
||||
echo "Il y a $etab_tmp lignes dans la nouvelle table etablissement ($etab lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate ent ent_phx >> $PATH_LOG/indexer.log
|
||||
echo "Sphinx - terminé : $(date +%H:%M:%S)" >> $PATH_LOG/indexer.log
|
||||
mysql -f -usphinx -h192.168.3.30 -pindexer jo < $PATH_SQL/finIndexationEtab.sql >> $PATH_LOG/indexer.log
|
||||
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/indexer.log
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN" >> $PATH_LOG/indexer.log
|
1
indexer/sql/count-dir.sql
Normal file
1
indexer/sql/count-dir.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT count(*) AS nb from dirigeants;
|
1
indexer/sql/count-dirtmp.sql
Normal file
1
indexer/sql/count-dirtmp.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT count(*) AS nb from dirigeants_tmp;
|
@ -1 +0,0 @@
|
||||
SELECT count(*) AS etab from dirigeants;
|
@ -1 +0,0 @@
|
||||
SELECT count(*) AS etab_tmp from dirigeants_tmp;
|
Loading…
Reference in New Issue
Block a user