Changeset 8215 for trunk/MagicSoft/Mars/datacenter/scripts
- Timestamp:
- 11/16/06 17:54:57 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/copyscript
r8125 r8215 38 38 # - filling the information from the *.rbk and *.run files into the DB 39 39 # using the macros filldotrbk.C and filldotrun.C 40 # - copying all logfiles to the correct directory:40 # - moving all logfiles to the correct directory: 41 41 # /subsystemdata/subsystem/YYYY/MM/DD/file.* 42 42 # - building the sequences for the standard analysis in the database … … 100 100 #find all dates in transfer-directory 101 101 dates=`find $transdir/*/ -type d | grep -o --regexp=20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]` >> $scriptlog 2>&1 102 if [ "$dates" = "" ]102 if ! [ "$dates" = "" ] 103 103 then 104 echo "nothing to do -> exit" >> $scriptlog 2>&1 105 finish >> $scriptlog 2>&1 104 echo "dates found: "$dates >> $scriptlog 2>&1 105 #loop over dates 106 for date in ${dates[@]} 107 do 108 printprocesslog "INFO processing files for $date" 109 #find all files for this date 110 files=`find $transdir/*/$date/ -name "*.*"` >> $scriptlog 2>&1 111 if [ "$files" = "" ] 112 then 113 echo "no files found for $date" >> $scriptlog 2>&1 114 continue 115 else 116 echo "files found for $date" >> $scriptlog 2>&1 117 fi 118 119 date2=`echo $date | sed -e 's/_/\//g'` 120 copylogpath=$logpath/$program/$date2 121 echo "copylogpath: "$copylogpath >> $scriptlog 2>&1 122 makedir $copylogpath >> $scriptlog 2>&1 123 124 #loop over all files in the directories for this date 125 for file in $files 126 do 127 echo "file: "$file >> $scriptlog 2>&1 128 filename=`basename $file` 129 130 #check for each file whether it has to be processed 131 if grep -i "$filename: OK" $transdir/.check >> $scriptlog 2>&1 132 then 133 newfile=`echo $file | sed -e 's/home\/lapalma\/transfer/magic\/subsystemdata/' -e 's/ccdata/cc/' -e 's/cacodata/caco/' -e 's/drivelogs/drive/' -e 's/_/\//1' -e 's/_/\//1' ` 134 echo "file (new path): "$newfile >> $scriptlog 2>&1 135 newpath=`dirname $newfile` 136 #make sure, that the needed directories are available 137 makedir $newpath >> $scriptlog 2>&1 138 139 #run macros if the file is a *.rbk or a *.run file to 140 #fill the information into the db 141 if echo $filename | grep \\\.rbk$ >> $scriptlog 2>&1 142 then 143 echo "found rbk-file $filename" >> $scriptlog 2>&1 144 145 checkfillrbk=`root -q -b $macrospath/filldotrbk.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrbk-$filename-log.txt | intgrep` 146 147 case $checkfillrbk in 148 1) echo " checkfillrbk=$checkfillrbk -> everything ok " >> $scriptlog 2>&1 149 echo " -> go on with moving file" >> $scriptlog 2>&1 150 ;; 151 *) echo " checkfillrbk=$checkfillrbk - Error -> go on with next file" >> $scriptlog 2>&1 152 printprocesslog "ERROR filldotrbk.C failed for $file" 153 continue 154 ;; 155 esac 156 fi 157 158 if echo $file | grep 'CC_.*.run' >> $scriptlog 2>&1 && ! echo $file | grep .run.html >> $scriptlog 2>&1 159 then 160 echo "found run-file $filename" >> $scriptlog 2>&1 161 162 checkfillrun=`root -q -b $macrospath/filldotrun.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrun-$filename-log.txt | intgrep` 163 164 case $checkfillrun in 165 1) echo " checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1 166 echo " -> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1 167 168 checkinsertdate=`root -q -b $macrospath/insertdate.C+\("\"$date\""\) | tee $copylogpath/insertdate-$date-log.txt | intgrep` 169 170 case $checkinsertdate in 171 1) echo "date inserted" >> $scriptlog 2>&1 ;; 172 *) echo " checkinsertdate=$checkinsertdate -> ERROR - insert date didn't work" >> $scriptlog 2>&1 173 printprocesslog "ERROR insertdate.C failed for $date" 174 continue 175 ;; 176 esac 177 echo " -> go on with moving file" >> $scriptlog 2>&1 178 ;; 179 *) echo " checkfillrun=$checkfillrun Error -> go on with next file" >> $scriptlog 2>&1 180 printprocesslog "ERROR filldotrun.C failed for $file" 181 continue 182 ;; 183 esac 184 fi 185 186 if mv -v $file $newpath >> $scriptlog 2>&1 187 then 188 #add file to donelist 189 filename3=`echo $file | cut -c $char-999` 190 echo "$filename3 processed" >> $transdir/.processed 191 echo $filename" moved and added to .processed" >> $scriptlog 2>&1 192 else 193 echo $file" couldn't be moved!!!!!" >> $scriptlog 2>&1 194 printprocesslog "WARN moving of file $file didn't work" 195 fi 196 197 else 198 #if the checksum for the file is not ok or the file was 199 #already processed (entry in donelist) -> go on with next file 200 echo $file": checksum not ok " >> $scriptlog 2>&1 201 printprocesslog "WARN checksum for file $file is not ok" 202 fi 203 done 204 done 106 205 fi 107 206 108 echo "dates found: "$dates >> $scriptlog 2>&1109 #loop over dates110 for date in ${dates[@]}111 do112 printprocesslog "INFO processing files for $date"113 #find all files for this date114 files=`find $transdir/*/$date/ -name "*.*"` >> $scriptlog 2>&1115 if [ "$files" = "" ]116 then117 echo "no files found for $date" >> $scriptlog 2>&1118 continue119 else120 echo "files found for $date" >> $scriptlog 2>&1121 fi122 123 date2=`echo $date | sed -e 's/_/\//g'`124 copylogpath=$logpath/$program/$date2125 echo "copylogpath: "$copylogpath >> $scriptlog 2>&1126 makedir $copylogpath >> $scriptlog 2>&1127 128 #loop over all files in the directories for this date129 for file in $files130 do131 echo "file: "$file >> $scriptlog 2>&1132 filename=`basename $file`133 134 #check for each file whether it has to be processed135 if grep -i "$filename: OK" $transdir/.check >> $scriptlog 2>&1136 then137 newfile=`echo $file | sed -e 's/home\/lapalma\/transfer/magic\/subsystemdata/' -e 's/ccdata/cc/' -e 's/cacodata/caco/' -e 's/drivelogs/drive/' -e 's/_/\//1' -e 's/_/\//1' `138 echo "file (new path): "$newfile >> $scriptlog 2>&1139 newpath=`dirname $newfile`140 #make sure, that the needed directories are available141 makedir $newpath >> $scriptlog 2>&1142 143 #run macros if the file is a *.rbk or a *.run file to144 #fill the information into the db145 if echo $filename | grep \\\.rbk$ >> $scriptlog 2>&1146 then147 echo "found rbk-file $filename" >> $scriptlog 2>&1148 149 checkfillrbk=`root -q -b $macrospath/filldotrbk.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrbk-$filename-log.txt | intgrep`150 151 case $checkfillrbk in152 1) echo " checkfillrbk=$checkfillrbk -> everything ok " >> $scriptlog 2>&1153 echo " -> go on with copying file" >> $scriptlog 2>&1154 ;;155 *) echo " checkfillrbk=$checkfillrbk - Error -> go on with next file" >> $scriptlog 2>&1156 printprocesslog "ERROR filldotrbk.C failed for $file"157 continue158 ;;159 esac160 fi161 162 if echo $file | grep 'CC_.*.run' >> $scriptlog 2>&1 && ! echo $file | grep .run.html >> $scriptlog 2>&1163 then164 echo "found run-file $filename" >> $scriptlog 2>&1165 166 checkfillrun=`root -q -b $macrospath/filldotrun.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrun-$filename-log.txt | intgrep`167 168 case $checkfillrun in169 1) echo " checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1170 echo " -> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1171 172 checkinsertdate=`root -q -b $macrospath/insertdate.C+\("\"$date\""\) | tee $copylogpath/insertdate-$date-log.txt | intgrep`173 174 case $checkinsertdate in175 1) echo "date inserted" >> $scriptlog 2>&1 ;;176 *) echo " checkinsertdate=$checkinsertdate -> ERROR - insert date didn't work" >> $scriptlog 2>&1177 printprocesslog "ERROR insertdate.C failed for $date"178 continue179 ;;180 esac181 echo " -> go on with copying file" >> $scriptlog 2>&1182 ;;183 *) echo " checkfillrun=$checkfillrun Error -> go on with next file" >> $scriptlog 2>&1184 printprocesslog "ERROR filldotrun.C failed for $file"185 continue186 ;;187 esac188 fi189 190 if mv -v $file $newpath >> $scriptlog 2>&1191 then192 #add file to donelist193 filename3=`echo $file | cut -c $char-999`194 echo "$filename3 processed" >> $transdir/.processed195 echo $filename" moved and added to .processed" >> $scriptlog 2>&1196 else197 echo $file" couldn't be moved!!!!!" >> $scriptlog 2>&1198 printprocesslog "WARN moving of file $file didn't work"199 fi200 201 else202 #if the checksum for the file is not ok or the file was203 #already processed (entry in donelist) -> go on with next file204 echo $file": checksum not ok " >> $scriptlog 2>&1205 printprocesslog "WARN checksum for file $file is not ok"206 fi207 done208 done209 207 210 208 echo "remove empty directories: " >> $scriptlog 2>&1 … … 214 212 215 213 216 217 #second part of the script: 214 # second part of the script 215 #searching optical data files, inserting the information into the db and 216 #moving the files 217 file="" 218 opticalfiles=`find $transdir/optical -name '*.instr'` 219 for opticalfile in $opticalfiles 220 do 221 printprocesslog "INFO process "$opticalfile 222 # echo $opticalfile 223 file=`basename $opticalfile` 224 year=`echo $file | cut -c 0-4` 225 opticallogpath=$logpath/filloptical/$year 226 makedir $opticallogpath >> $scriptlog 2>&1 227 opticallogfile=$opticallogpath/filloptical-$file.log 228 # echo "logfile: "$opticallogfile 229 230 checkfilloptical=`root -q -b $macrospath/filloptical.C+\("\"$opticalfile\""\,kFALSE\) | tee $opticallogfile | intgrep` 231 # checkfilloptical=`root -q -b $macrospath/filloptical.C+\("\"$opticalfile\""\) | tee $opticallogfile | intgrep` 232 233 case $checkfilloptical in 234 1) echo " checkfilloptical=$checkfilloptical -> everything ok -> go on with moving file" >> $scriptlog 2>&1 235 newdir=$subsystempath/optical/$year 236 newfile=$newdir/$file 237 makedir $newdir >> $scriptlog 2>&1 238 239 if mv -v $opticalfile $newfile >> $scriptlog 2>&1 240 then 241 echo "moved "$opticalfile" successfully" >> $scriptlog 2>&1 242 printprocesslog "INFO moved "$opticalfile" successfully" 243 else 244 echo $opticalfile" couldn't be moved!!!!!" >> $scriptlog 2>&1 245 printprocesslog "WARN moving of file $opticalfile didn't work" 246 fi 247 248 ;; 249 *) echo " checkfilloptical=$checkfilloptical - Error -> go on with next file" >> $scriptlog 2>&1 250 printprocesslog "ERROR filloptical.C failed for $opticalfile" 251 continue 252 ;; 253 esac 254 done 255 256 257 # third part of the script: 218 258 #update the catalog file magic_favorites.edb 219 259 printprocesslog "INFO processing new catalog files" … … 258 298 259 299 oldcatalogpath=$setuppath/oldcatalogs 260 makedir $oldcatalogpath 300 makedir $oldcatalogpath >> $scriptlog 2>&1 261 301 #rsync current catalogfile to directory with old catalogfiles including the date of the new catalogfile into the filename 262 302 if ! rsync -av $catalog $oldcatalogpath/$magfav.$date >> $scriptlog 2>&1
Note:
See TracChangeset
for help on using the changeset viewer.