Ignore:
Timestamp:
11/16/06 17:54:57 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/scripts/copyscript

    r8125 r8215  
    3838# - filling the information from the *.rbk and *.run files into the DB
    3939# using the macros filldotrbk.C and filldotrun.C
    40 # - copying all logfiles to the correct directory:
     40# - moving all logfiles to the correct directory:
    4141# /subsystemdata/subsystem/YYYY/MM/DD/file.*
    4242# - building the sequences for the standard analysis in the database
     
    100100#find all dates in transfer-directory
    101101dates=`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" = "" ]
     102if ! [ "$dates" = "" ]
    103103then
    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
    106205fi
    107206
    108 echo "dates found: "$dates  >> $scriptlog 2>&1
    109 #loop over dates
    110 for date in ${dates[@]}
    111 do
    112    printprocesslog "INFO processing files for $date"
    113    #find all files for this date
    114    files=`find $transdir/*/$date/ -name "*.*"`  >> $scriptlog 2>&1
    115    if [ "$files" = "" ]
    116    then
    117       echo "no files found for $date"  >> $scriptlog 2>&1
    118       continue
    119    else
    120       echo "files found for $date"  >> $scriptlog 2>&1
    121    fi
    122    
    123    date2=`echo $date | sed -e 's/_/\//g'`
    124    copylogpath=$logpath/$program/$date2
    125    echo "copylogpath: "$copylogpath >> $scriptlog 2>&1
    126    makedir $copylogpath >> $scriptlog 2>&1
    127    
    128    #loop over all files in the directories for this date
    129    for file in $files
    130    do
    131       echo "file: "$file  >> $scriptlog 2>&1
    132       filename=`basename $file`
    133                        
    134       #check for each file whether it has to be processed
    135       if grep -i "$filename: OK" $transdir/.check  >> $scriptlog 2>&1
    136       then
    137          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>&1
    139          newpath=`dirname $newfile`
    140          #make sure, that the needed directories are available
    141          makedir $newpath >> $scriptlog 2>&1
    142          
    143          #run macros if the file is a *.rbk or a *.run file to
    144          #fill the information into the db
    145          if echo $filename | grep \\\.rbk$  >> $scriptlog 2>&1
    146          then
    147             echo "found rbk-file $filename"  >> $scriptlog 2>&1
    148            
    149             checkfillrbk=`root -q -b $macrospath/filldotrbk.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrbk-$filename-log.txt | intgrep`
    150            
    151             case $checkfillrbk in
    152                1) echo " checkfillrbk=$checkfillrbk -> everything ok " >> $scriptlog 2>&1
    153                   echo "  -> go on with copying file" >> $scriptlog 2>&1
    154                   ;;
    155                *) echo " checkfillrbk=$checkfillrbk - Error -> go on with next file" >> $scriptlog 2>&1
    156                   printprocesslog "ERROR filldotrbk.C failed for $file"
    157                   continue
    158                   ;;
    159             esac
    160          fi
    161          
    162          if echo $file | grep 'CC_.*.run' >> $scriptlog 2>&1  && ! echo $file | grep .run.html >> $scriptlog 2>&1
    163          then
    164             echo "found run-file $filename" >> $scriptlog 2>&1
    165            
    166             checkfillrun=`root -q -b $macrospath/filldotrun.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrun-$filename-log.txt | intgrep`
    167            
    168             case $checkfillrun in
    169                1) echo " checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1
    170                   echo "  -> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1
    171 
    172                   checkinsertdate=`root -q -b $macrospath/insertdate.C+\("\"$date\""\) | tee $copylogpath/insertdate-$date-log.txt | intgrep`
    173                  
    174                   case $checkinsertdate in
    175                      1) echo "date inserted" >> $scriptlog 2>&1 ;;
    176                      *) echo " checkinsertdate=$checkinsertdate -> ERROR - insert date didn't work" >> $scriptlog 2>&1
    177                         printprocesslog "ERROR insertdate.C failed for $date"
    178                         continue
    179                         ;;
    180                   esac
    181                   echo " -> go on with copying file" >> $scriptlog 2>&1
    182                   ;;
    183                *) echo " checkfillrun=$checkfillrun Error -> go on with next file" >> $scriptlog 2>&1
    184                   printprocesslog "ERROR filldotrun.C failed for $file"
    185                   continue
    186                   ;;
    187             esac
    188          fi
    189 
    190          if mv -v $file $newpath >> $scriptlog 2>&1
    191          then
    192             #add file to donelist
    193             filename3=`echo $file | cut -c $char-999`
    194             echo "$filename3 processed" >> $transdir/.processed
    195             echo $filename" moved and added to .processed" >> $scriptlog 2>&1
    196          else
    197             echo $file" couldn't be moved!!!!!" >> $scriptlog 2>&1
    198             printprocesslog "WARN moving of file $file didn't work"
    199          fi
    200 
    201       else
    202          #if the checksum for the file is not ok or the file was
    203          #already processed (entry in donelist) -> go on with next file
    204          echo $file": checksum not ok " >> $scriptlog 2>&1
    205          printprocesslog "WARN checksum for file $file is not ok"
    206       fi
    207    done
    208 done
    209207
    210208echo "remove empty directories: "  >> $scriptlog 2>&1
     
    214212
    215213
    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
     217file=""
     218opticalfiles=`find $transdir/optical -name '*.instr'`
     219for opticalfile in $opticalfiles
     220do
     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
     254done
     255
     256
     257# third part of the script:
    218258#update the catalog file magic_favorites.edb
    219259printprocesslog "INFO processing new catalog files"
     
    258298
    259299      oldcatalogpath=$setuppath/oldcatalogs
    260       makedir $oldcatalogpath
     300      makedir $oldcatalogpath >> $scriptlog 2>&1
    261301      #rsync current catalogfile to directory with old catalogfiles including the date of the new catalogfile into the filename
    262302      if ! rsync -av $catalog $oldcatalogpath/$magfav.$date >> $scriptlog 2>&1
Note: See TracChangeset for help on using the changeset viewer.