From 04f472bc869f52515ce4d2621de19ba1708d60d3 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 18 Apr 2014 13:27:44 +0000 Subject: [PATCH] issue #0001933 : Prepare file name and update --- indexer/{indexerAct.sh => indexer-act.sh} | 0 indexer/indexer-dir.sh | 48 ++++++++++++++++++ indexer/indexer-etab.sh | 49 +++++++++++++++++++ indexer/indexerDiri.sh | 39 --------------- indexer/indexerEtab.sh | 43 ---------------- indexer/sql/count-dir.sql | 1 + indexer/sql/count-dirtmp.sql | 1 + indexer/sql/{countEtab.sql => count-ent.sql} | 0 .../{countEtab_tmp.sql => count-enttmp.sql} | 0 indexer/sql/countDiri.sql | 1 - indexer/sql/countDiri_tmp.sql | 1 - .../{finIndexationDiri.sql => rotate-dir.sql} | 0 .../{finIndexationEtab.sql => rotate-ent.sql} | 0 13 files changed, 99 insertions(+), 84 deletions(-) rename indexer/{indexerAct.sh => indexer-act.sh} (100%) create mode 100755 indexer/indexer-dir.sh create mode 100755 indexer/indexer-etab.sh delete mode 100755 indexer/indexerDiri.sh delete mode 100755 indexer/indexerEtab.sh create mode 100644 indexer/sql/count-dir.sql create mode 100644 indexer/sql/count-dirtmp.sql rename indexer/sql/{countEtab.sql => count-ent.sql} (100%) rename indexer/sql/{countEtab_tmp.sql => count-enttmp.sql} (100%) delete mode 100644 indexer/sql/countDiri.sql delete mode 100644 indexer/sql/countDiri_tmp.sql rename indexer/sql/{finIndexationDiri.sql => rotate-dir.sql} (100%) rename indexer/sql/{finIndexationEtab.sql => rotate-ent.sql} (100%) diff --git a/indexer/indexerAct.sh b/indexer/indexer-act.sh similarity index 100% rename from indexer/indexerAct.sh rename to indexer/indexer-act.sh diff --git a/indexer/indexer-dir.sh b/indexer/indexer-dir.sh new file mode 100755 index 0000000..8a6055a --- /dev/null +++ b/indexer/indexer-dir.sh @@ -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 diff --git a/indexer/indexer-etab.sh b/indexer/indexer-etab.sh new file mode 100755 index 0000000..0bf0d98 --- /dev/null +++ b/indexer/indexer-etab.sh @@ -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 diff --git a/indexer/indexerDiri.sh b/indexer/indexerDiri.sh deleted file mode 100755 index 247bf80..0000000 --- a/indexer/indexerDiri.sh +++ /dev/null @@ -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 diff --git a/indexer/indexerEtab.sh b/indexer/indexerEtab.sh deleted file mode 100755 index cdeb932..0000000 --- a/indexer/indexerEtab.sh +++ /dev/null @@ -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 diff --git a/indexer/sql/count-dir.sql b/indexer/sql/count-dir.sql new file mode 100644 index 0000000..63da2a0 --- /dev/null +++ b/indexer/sql/count-dir.sql @@ -0,0 +1 @@ +SELECT count(*) AS nb from dirigeants; \ No newline at end of file diff --git a/indexer/sql/count-dirtmp.sql b/indexer/sql/count-dirtmp.sql new file mode 100644 index 0000000..a1ae09b --- /dev/null +++ b/indexer/sql/count-dirtmp.sql @@ -0,0 +1 @@ +SELECT count(*) AS nb from dirigeants_tmp; diff --git a/indexer/sql/countEtab.sql b/indexer/sql/count-ent.sql similarity index 100% rename from indexer/sql/countEtab.sql rename to indexer/sql/count-ent.sql diff --git a/indexer/sql/countEtab_tmp.sql b/indexer/sql/count-enttmp.sql similarity index 100% rename from indexer/sql/countEtab_tmp.sql rename to indexer/sql/count-enttmp.sql diff --git a/indexer/sql/countDiri.sql b/indexer/sql/countDiri.sql deleted file mode 100644 index 7605dc6..0000000 --- a/indexer/sql/countDiri.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT count(*) AS etab from dirigeants; \ No newline at end of file diff --git a/indexer/sql/countDiri_tmp.sql b/indexer/sql/countDiri_tmp.sql deleted file mode 100644 index 0a27146..0000000 --- a/indexer/sql/countDiri_tmp.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT count(*) AS etab_tmp from dirigeants_tmp; diff --git a/indexer/sql/finIndexationDiri.sql b/indexer/sql/rotate-dir.sql similarity index 100% rename from indexer/sql/finIndexationDiri.sql rename to indexer/sql/rotate-dir.sql diff --git a/indexer/sql/finIndexationEtab.sql b/indexer/sql/rotate-ent.sql similarity index 100% rename from indexer/sql/finIndexationEtab.sql rename to indexer/sql/rotate-ent.sql