source: trunk/MagicSoft/Mars/datacenter/tools/resetdataset@ 8169

Last change on this file since 8169 was 8064, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.1 KB
Line 
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 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27# This script checks from the DB which new starfiles have been produced
28# and sends it to the person in charge for building datasets
29#
30
31datasetpath=/magic/datasets
32datasetpath=/test/bu.2006.10.05/datasets
33
34function usage()
35{
36 echo "Usage: $0 [options]"
37 echo "options:"
38 echo -n " --ds dataset# "
39 echo " number of the dataset you want to reset "
40 echo -n " --db "
41 echo " name of the db in which you want to reset "
42 echo -n " --user "
43 echo " db user "
44 echo -n " --pw "
45 echo " pw of the db user "
46 echo ""
47 exit
48}
49
50
51while [ "$1" ]
52do
53 case $1 in
54 --ds) shift
55 dataset=$1
56 ;;
57 --db) shift
58 db=$1
59 ;;
60 --pw) shift
61 pw=$1
62 ;;
63 --user) shift
64 user=$1
65 ;;
66 -h) usage
67 ;;
68 *) echo "unknown option $1 "
69 usage
70 exit
71 ;;
72 esac
73 shift
74done
75
76if [ "$dataset" = "" ]
77then
78 echo "Please give the number for the dataset you want to reset."
79 usage
80fi
81
82if [ "$pw" = "" ] || [ "$user" = "" ]
83then
84 echo "Please give user and password for the DB $db."
85 usage
86fi
87
88if [ "$db" = "" ]
89then
90 echo "Please give the DB in which you want to reset."
91 usage
92fi
93
94
95alias mymysql='mysql -u $user --password=$ps --host=hercules $db -s -e'
96
97whereclause1=" WHERE fDataSetNumer=$dataset"
98statusreset=", fStartTime=NULL, fFailedTime=NULL, fFailedCode=NULL, fFailedCodeAdd=NULL, fReturnCode=NULL"
99query1="UPDATE DataSetProcessStatus SET fStarFilesAvail=NULL, fGanymed=NULL, fFillGanymed=NULL"
100query1=$query1$statusreset$whereclause1
101
102query2="DELETE FROM GANYMED "$whereclause1
103
104no=`printf %08d $dataset`
105no2=`echo $no | cut -c 0-5`
106datasetfile=$datasetpath/$no2/dataset$no.txt
107if ! ls $datasetfile 2>&1 >/dev/null
108then
109 echo "There's no datasetfile $datasetfile"
110 exit
111fi
112echo " getting sequence numbers from $datasetfile"
113
114seqon=`grep "SequencesOn" $datasetfile | grep -v '#' | sed -e 's/SequencesOn://' -e 's/^ //g' -e 's/ $//g' -e 's/ /,/g'`
115seqoff=`grep "SequencesOff" $datasetfile | grep -v '#' | sed -e 's/SequencesOff://' -e 's/^ //g' -e 's/ $//g' -e 's/ /,/g'`
116
117echo " Found the following on sequences: $seqon"
118echo " Found the following off sequences: $seqoff"
119
120whereclause2=" WHERE fSequenceFirst IN ($seqon,$seqoff)"
121query3="UPDATE SequenceProcessStatus SET fAllFilesAvail=NULL, fCallisto=NULL, fStar=NULL "
122query3=$query3$setstatusreseet$whereclause2
123
124query4="DELETE FROM Calibration"$whereclause2
125query5="DELETE FROM Star"$whereclause2
126
127
128echo ""
129echo "The following queries would be executed:"
130echo "Q1: "$query1
131echo "Q2: "$query2
132echo "Q3: "$query3
133echo "Q4: "$query4
134echo "Q5: "$query5
135echo ""
136echo " DB: "$db
137echo "user: " $user
138echo ""
139echo "Are you sure you want to continue?"
140echo "please insert y, if you want continue"
141echo " n, if you want quit"
142
143answer=`head -n 1`
144case $answer in
145 y) echo "continue resetting DB"
146 ;;
147 n) exit
148 ;;
149 *) echo "your answer is not clear -> exit"
150 exit
151 ;;
152esac
153
154mymysql "$query1"
155mymysql "$query2"
156mymysql "$query3"
157mymysql "$query4"
158mymysql "$query5"
159
Note: See TracBrowser for help on using the repository browser.