source: branches/removing_cpp11_features/datacenter/tools/resetpriorities@ 19102

Last change on this file since 19102 was 9088, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.6 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 08/2008 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2008
23#
24#
25# ========================================================================
26#
27# This script resets the priorities for the tables RunProcessStatus
28# SequenceProcessStatus and DataSetProcessStatus
29#
30
31alias mymysql='mysql -u $user --password=$pw --host=vela $db -e'
32
33
34function usage()
35{
36 echo "Usage: $0 [options]"
37 echo "options:"
38 echo -n " --db "
39 echo " name of the db for which you want to reset the priorities"
40 echo " if no db is given, MyMagic is resetted"
41 echo -n " --user "
42 echo " db user "
43 echo -n " --pw "
44 echo " pw of the db user "
45 echo ""
46 echo -n " -d "
47 echo " reset only priorities of datasets"
48 echo -n " -r "
49 echo " reset only priorities of runs"
50 echo -n " -s "
51 echo " reset only priorities of sequences"
52 echo ""
53 echo " If none of the last three option is chosen, all of them are resetted."
54 echo ""
55 exit
56}
57
58
59all="yes"
60while [ "$1" ]
61do
62 case $1 in
63 --db) shift
64 db=$1
65 ;;
66 --pw) shift
67 pw=$1
68 ;;
69 --user) shift
70 user=$1
71 ;;
72 -h) usage
73 ;;
74 -d) ds="yes"
75 all="no"
76 ;;
77 -r) rn="yes"
78 all="no"
79 ;;
80 -s) sq="yes"
81 all="no"
82 ;;
83 *) echo "unknown option $1 "
84 usage
85 exit
86 ;;
87 esac
88 shift
89done
90
91
92if [ "$pw" = "" ] || [ "$user" = "" ]
93then
94 echo "Please give user and password for the DB $db."
95 usage
96fi
97
98if [ "$db" = "" ]
99then
100 echo "You didn't give a database. The priorities for MyMagic will be resetted in 5 seconds..."
101 db="MyMagic"
102 sleep 5
103fi
104
105if [ "$all" = "yes" ]
106then
107 ds="yes"
108 rn="yes"
109 sq="yes"
110fi
111
112
113if [ "$rn" = "yes" ]
114then
115 query1="update RunProcessStatus set fPriority=fRunNumber"
116 if ! mymysql "$query1"
117 then
118 echo "ERROR: could not reset priorities for RunProcessStatus"
119 else
120 echo "The priorities for RunProcessStatus have been resetted successfully."
121 fi
122fi
123
124if [ "$sq" = "yes" ]
125then
126 query2="update SequenceProcessStatus set fPriority=fSequenceFirst"
127 if ! mymysql "$query2"
128 then
129 echo "ERROR: could not reset priorities for SequenceProcessStatus"
130 else
131 echo "The priorities for SequenceProcessStatus have been resetted successfully."
132 fi
133fi
134
135if [ "$ds" = "yes" ]
136then
137 query3="update DataSetProcessStatus set fPriority=fDataSetNumber"
138 if ! mymysql "$query3"
139 then
140 echo "ERROR: could not reset priorities for DataSetProcessStatus"
141 else
142 echo "The priorities for DataSetProcessStatus have been resetted successfully."
143 fi
144fi
145
Note: See TracBrowser for help on using the repository browser.