| 1 | #!/bin/sh | 
|---|
| 2 | # | 
|---|
| 3 | # ======================================================================== | 
|---|
| 4 | # | 
|---|
| 5 | # * | 
|---|
| 6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction | 
|---|
| 7 | # * Software. It is distributed to you in the hope that it can be a useful | 
|---|
| 8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes. | 
|---|
| 9 | # * It is distributed WITHOUT ANY WARRANTY. | 
|---|
| 10 | # * | 
|---|
| 11 | # * Permission to use, copy, modify and distribute this software and its | 
|---|
| 12 | # * documentation for any purpose is hereby granted without fee, | 
|---|
| 13 | # * provided that the above copyright notice appear in all copies and | 
|---|
| 14 | # * that both that copyright notice and this permission notice appear | 
|---|
| 15 | # * in supporting documentation. It is provided "as is" without express | 
|---|
| 16 | # * or implied warranty. | 
|---|
| 17 | # * | 
|---|
| 18 | # | 
|---|
| 19 | # | 
|---|
| 20 | #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de> | 
|---|
| 21 | # | 
|---|
| 22 | #   Copyright: MAGIC Software Development, 2000-2007 | 
|---|
| 23 | # | 
|---|
| 24 | # | 
|---|
| 25 | # ======================================================================== | 
|---|
| 26 | # | 
|---|
| 27 | # This script launches the inserting of sequences into the db. | 
|---|
| 28 | # It is not used in the automatic processing of data, but only for | 
|---|
| 29 | # inserting of manual written sequences. | 
|---|
| 30 | # | 
|---|
| 31 | # Find manual written sequence files and insert information into the | 
|---|
| 32 | # database using the macro insertsequence.C | 
|---|
| 33 | # | 
|---|
| 34 |  | 
|---|
| 35 | source `dirname $0`/sourcefile | 
|---|
| 36 | printprocesslog "INFO starting $0" | 
|---|
| 37 | program=insertsequences | 
|---|
| 38 |  | 
|---|
| 39 | set -C | 
|---|
| 40 |  | 
|---|
| 41 | scriptlog=$runlogpath/$program-$datetime.log | 
|---|
| 42 | date >> $scriptlog 2>&1 | 
|---|
| 43 |  | 
|---|
| 44 | # check if script is already running | 
|---|
| 45 | lockfile=$lockpath/lock-$program.txt | 
|---|
| 46 | checklock  >> $scriptlog 2>&1 | 
|---|
| 47 |  | 
|---|
| 48 | # finding manual written sequence files (marked by the comment '#manually changed') | 
|---|
| 49 | # for test reasons there has to be cut from 1-47 (not as for operator from 1-42) because of | 
|---|
| 50 | # sequpath=/magic/test/sequences (not /magic/sequences) | 
|---|
| 51 | sequencefiles=(`grep -R '#manually changed' $sequpath/ | cut -c 1-42`) | 
|---|
| 52 | echo "sequencefiles: "${sequencefiles[@]}  >> $scriptlog 2>&1 | 
|---|
| 53 | echo "" >> $scriptlog 2>&1 | 
|---|
| 54 |  | 
|---|
| 55 | cd $mars | 
|---|
| 56 |  | 
|---|
| 57 | # process sequencefiles: insert information into the database | 
|---|
| 58 | for sequencefile in ${sequencefiles[@]} | 
|---|
| 59 | do | 
|---|
| 60 | printprocesslog "INFO inserting sequence from file $sequencefile" | 
|---|
| 61 | echo "file: "$sequencefile >> $scriptlog 2>&1 | 
|---|
| 62 | no=`echo $sequencefile | cut -c 31-38` | 
|---|
| 63 | no2=`echo $no | cut -c 1-4` | 
|---|
| 64 | insertsequencepath=$logpath/$program/$no2 | 
|---|
| 65 | makedir $insertsequencepath >> $scriptlog 2>&1 | 
|---|
| 66 | insertsequencelog=$insertsequencepath/$program-$no.log | 
|---|
| 67 |  | 
|---|
| 68 | check0=`root -q -b $macrospath/insertsequence.C+\("\"$sequencefile\""\,kFALSE\) | tee $insertsequencelog | intgrep` | 
|---|
| 69 | case $check0 in | 
|---|
| 70 | 1)   echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1 | 
|---|
| 71 | printprocesslog "INFO sequence $no2 successfully inserted" | 
|---|
| 72 | ;; | 
|---|
| 73 | 0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 | 
|---|
| 74 | printprocesslog "WARN connection to DB failed" | 
|---|
| 75 | check="no" | 
|---|
| 76 | ;; | 
|---|
| 77 | *)   echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 | 
|---|
| 78 | printprocesslog "ERROR $program.C failed for sequence $no2" | 
|---|
| 79 | ;; | 
|---|
| 80 | esac | 
|---|
| 81 | done | 
|---|
| 82 |  | 
|---|
| 83 | finish >> $scriptlog 2>&1 | 
|---|
| 84 |  | 
|---|