1 | #!/bin/bash |
---|
2 | |
---|
3 | |
---|
4 | function waitingFor |
---|
5 | { |
---|
6 | waitedFile=$1 |
---|
7 | |
---|
8 | # verif que la variable MonitoringDir est bien define |
---|
9 | if [ "x${MonitoringDir}" == "x" ] |
---|
10 | then |
---|
11 | echo "variable MonitoringDir not defined. stop." |
---|
12 | exit -1 |
---|
13 | fi |
---|
14 | |
---|
15 | # Le fichier teste doit etre dans le rep de suivi |
---|
16 | isWaitedFileName_In_MonitoringDir=`echo $waitedFile | grep ${MonitoringDir} | wc -l ` |
---|
17 | if [ "x${isWaitedFileName_In_MonitoringDir}" == "x0" ] |
---|
18 | then |
---|
19 | echo "The waited file name :" |
---|
20 | echo "$waitedFile" |
---|
21 | echo "is incorrect. The location of the file must be in the monitoring dir." |
---|
22 | exit -1 |
---|
23 | fi |
---|
24 | |
---|
25 | waitedFileBasename=$(basename ${waitedFile}) |
---|
26 | # echo "On verifie la presence de ${waitedFileBasename}..." |
---|
27 | iter=0 |
---|
28 | found=0 |
---|
29 | while [ ${iter} -lt 60 ] |
---|
30 | do |
---|
31 | if [ -e $waitedFile ] |
---|
32 | then |
---|
33 | found=1 |
---|
34 | break |
---|
35 | fi |
---|
36 | iter=$(( $iter + 1 )) |
---|
37 | echo "waiting for ${waitedFileBasename}...${iter}..." |
---|
38 | sleep 1 |
---|
39 | done |
---|
40 | |
---|
41 | if [ "x${found}" == "x0" ] |
---|
42 | then |
---|
43 | echo "Le fichier ${waitedFileBasename} n'a pas ete trouve. stop." |
---|
44 | exit -1 |
---|
45 | fi |
---|
46 | |
---|
47 | # echo "fichier trouve !" |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | ####################### |
---|
53 | # Main program ######## |
---|
54 | ####################### |
---|
55 | . load_ipslPack_env.sh |
---|
56 | # fichier de progression d'execution |
---|
57 | # Le seul arg du script doit etre un fichier param |
---|
58 | # paramFile=${1} |
---|
59 | # paramFileBasename=$(basename ${1}) |
---|
60 | |
---|
61 | # if [ ! -e $paramFile ] || [ "x${paramFile}" == "x" ] |
---|
62 | # then |
---|
63 | # echo "Le fichier en argument n existe pas" |
---|
64 | # exit 0 |
---|
65 | # fi |
---|
66 | |
---|
67 | if [ ! -e ${1} ] || [ "x${1}" == "x" ] |
---|
68 | then |
---|
69 | echo "Le fichier en argument n existe pas" |
---|
70 | exit 0 |
---|
71 | else |
---|
72 | paramFile=${1} |
---|
73 | paramFileBasename=$(basename ${1}) |
---|
74 | fi |
---|
75 | |
---|
76 | |
---|
77 | extSuiviListes=`echo ${paramFileBasename} | sed 's;\.[[:alnum:]]*$;;' ` |
---|
78 | export MonitoringDir="${TMP_MIGR_DATA}/SuiviListes_${extSuiviListes}" |
---|
79 | # echo "MonitoringDir=$MonitoringDir" |
---|
80 | export generalMonitorFile=${MonitoringDir}/general.txt |
---|
81 | export nbSimuFile=${MonitoringDir}/nbSimu.txt |
---|
82 | |
---|
83 | declare -a tabGeneralSteps=() |
---|
84 | tabGeneralSteps[0]="find_directory_simul.sh-->OK" |
---|
85 | tabGeneralSteps[1]="create_config_card.sh-->OK" |
---|
86 | |
---|
87 | declare -a tabSimuSteps=() |
---|
88 | tabSimuSteps[0]="calcul_size_simul.sh-->OK" |
---|
89 | tabSimuSteps[1]="find_size_pack.sh-->OK" |
---|
90 | tabSimuSteps[2]="write_liste_pack.sh-->OK" |
---|
91 | tabSimuSteps[3]="archive_restart.sh-->OK" |
---|
92 | tabSimuSteps[4]="archive_debug.sh-->OK" |
---|
93 | |
---|
94 | echo "#################################################" |
---|
95 | echo "### ETAT D'AVANCEMENT DES SCRIPTS DE lISTES ###" |
---|
96 | echo "#################################################" |
---|
97 | echo |
---|
98 | |
---|
99 | # Si le rep de suivi n'existe pas, stop. |
---|
100 | if [ ! -d ${MonitoringDir} ] |
---|
101 | then |
---|
102 | echo "${MonitoringDir} n'existe pas. stop." |
---|
103 | exit -1 |
---|
104 | fi |
---|
105 | |
---|
106 | cd ${MonitoringDir} |
---|
107 | if [ "x$?" != "x0" ] |
---|
108 | then |
---|
109 | echo "Pb avec cd ${MonitoringDir}" |
---|
110 | exit -1 |
---|
111 | fi |
---|
112 | |
---|
113 | # Etapes generales |
---|
114 | # ---------------- |
---|
115 | echo "--------------------------------------------------" |
---|
116 | echo "---------------- Etapes generales ----------------" |
---|
117 | echo "--------------------------------------------------" |
---|
118 | waitingFor "${generalMonitorFile}" |
---|
119 | |
---|
120 | |
---|
121 | generalStepsDoneList=`cat ${generalMonitorFile} ` |
---|
122 | for ((i = 0; i < ${#tabGeneralSteps[*]}; i += 1)) |
---|
123 | do |
---|
124 | isEltInDoneList=`echo $generalStepsDoneList | grep "${tabGeneralSteps[$i]}" | wc -l ` |
---|
125 | if [ "x$isEltInDoneList" == "x0" ] |
---|
126 | then |
---|
127 | stringKO=`echo ${tabGeneralSteps[$i]} | sed 's;OK;?? #####;' ` |
---|
128 | echo "$stringKO" |
---|
129 | else |
---|
130 | echo "${tabGeneralSteps[$i]}" |
---|
131 | fi |
---|
132 | |
---|
133 | done |
---|
134 | |
---|
135 | |
---|
136 | # Etapes createListing |
---|
137 | # -------------------- |
---|
138 | echo |
---|
139 | echo "--------------------------------------------------" |
---|
140 | echo "---------------- Etape createListing -------------" |
---|
141 | echo "--------------------------------------------------" |
---|
142 | listSubDir=`ls -l | grep -e '^d' | awk '{print $NF}' ` |
---|
143 | # echo "listSubDir=$listSubDir" |
---|
144 | if [ "x$listSubDir" == "x" ] |
---|
145 | then |
---|
146 | echo "Aucune liste n'est prete." |
---|
147 | fi |
---|
148 | |
---|
149 | # echo "listSubDir=$listSubDir" |
---|
150 | for rep in $listSubDir |
---|
151 | do |
---|
152 | cd $rep |
---|
153 | if [ ! -e createListingOK.txt ] |
---|
154 | then |
---|
155 | echo "${rep}: createListing.sh-->?? #####" |
---|
156 | else |
---|
157 | echo "${rep}: createListing.sh-->OK" |
---|
158 | fi |
---|
159 | |
---|
160 | cd .. |
---|
161 | done |
---|
162 | echo |
---|
163 | |
---|
164 | echo "--------------------------------------------------" |
---|
165 | echo "--------------- Etape par simu ------------------" |
---|
166 | echo "--------------------------------------------------" |
---|
167 | if [ "x$listSubDir" == "x" ] |
---|
168 | then |
---|
169 | echo "Aucune simu n'a ete traitee." |
---|
170 | fi |
---|
171 | |
---|
172 | nbSimuOK=0 |
---|
173 | for rep in $listSubDir |
---|
174 | do |
---|
175 | cd $rep |
---|
176 | listSimu=`ls -1 | grep -v "createListingOK.txt" ` |
---|
177 | if [ ! -e createListingOK.txt ] || [ "x${listSimu}" == "x" ] |
---|
178 | then |
---|
179 | echo "${rep}: Pas de simu traitee" |
---|
180 | fi |
---|
181 | # echo "listSimu=$listSimu" |
---|
182 | for simu in $listSimu |
---|
183 | do |
---|
184 | simuDone=1 |
---|
185 | simuName=`echo $simu | sed 's;_#_;/;g' | sed 's;\.txt;;' ` |
---|
186 | |
---|
187 | # Cas des simu speciales ( < 1 Go ou de type etat0 ) ############# |
---|
188 | isSpecialSimuOK=`cat ${simu} | grep "special simu==>OK" | wc -l ` |
---|
189 | if [ "x${isSpecialSimuOK}" != "x0" ] |
---|
190 | then |
---|
191 | echo "$simuName : special simulation ==> OK" |
---|
192 | nbSimuOK=$(( $nbSimuOK + 1 )) |
---|
193 | continue |
---|
194 | fi |
---|
195 | |
---|
196 | |
---|
197 | # Cas des simus normales |
---|
198 | echo $simuName |
---|
199 | simuStepsDoneList=`cat ${simu} ` |
---|
200 | for ((i = 0; i < ${#tabSimuSteps[*]}; i += 1)) |
---|
201 | do |
---|
202 | isEltInDoneList=`echo $simuStepsDoneList | grep "${tabSimuSteps[$i]}" | wc -l ` |
---|
203 | if [ "x$isEltInDoneList" == "x0" ] |
---|
204 | then |
---|
205 | stringKO=`echo ${tabSimuSteps[$i]} | sed 's;OK;?? #####;' ` |
---|
206 | simuDone=$(( $simuDone && 0 )) |
---|
207 | echo " $stringKO" |
---|
208 | else |
---|
209 | echo " ${tabSimuSteps[$i]}" |
---|
210 | fi |
---|
211 | done |
---|
212 | |
---|
213 | # si toutes les operations sur la simu sont OK, on incremente le nb de simu OK |
---|
214 | if [ "x$simuDone" == "x1" ] |
---|
215 | then |
---|
216 | nbSimuOK=$(( $nbSimuOK + 1 )) |
---|
217 | fi |
---|
218 | done |
---|
219 | cd .. |
---|
220 | done |
---|
221 | |
---|
222 | |
---|
223 | waitingFor "${nbSimuFile}" |
---|
224 | |
---|
225 | nbSimuTot=`cat ${nbSimuFile} ` |
---|
226 | nbSimuFormatOK=`echo $nbSimuTot | grep -e '^[0-9]\{1,4\}$' | wc -l` |
---|
227 | if [ "x$nbSimuFormatOK" == "x0" ] |
---|
228 | then |
---|
229 | echo "Le nombre de simulation contenues dans le fichier $nbSimuFile est incorrect." |
---|
230 | exit -1 |
---|
231 | fi |
---|
232 | |
---|
233 | echo |
---|
234 | echo "=============================================" |
---|
235 | echo "nbre de simu OK : $nbSimuOK / $nbSimuTot" |
---|
236 | echo "=============================================" |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | |
---|
242 | |
---|
243 | |
---|
244 | |
---|
245 | |
---|
246 | |
---|