ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/CondWebServer/server
Revision: 1.7
Committed: Wed May 6 16:53:46 2009 UTC (15 years, 11 months ago) by xiezhen
Branch: MAIN
CVS Tags: CONDAPP-1-7-3, CONDAPP-1-7-2, CONDAPP-1-7-1, CONDAPP-1-7-0, CONDAPP-1-6-4b, CONDAPP-1-6-4, HEAD
Branch point for: conddbapp16x
Changes since 1.6: +1 -0 lines
Error occurred while calculating annotation data.
Log Message:
add quite_assert=yes

File Contents

# Content
1 #!/bin/bash
2
3 #This script is for testing condapp server with CMSSW development scram installation indepdent of rpm installations.Use ./server --help to see available options
4
5 #
6 # getopt.sh:
7 # functions like getopts but do long-named options parsing
8 # and support optional arguments
9 #
10 # Version 1.0 1997 by Grigoriy Strokin (grg@philol.msu.ru), Public Domain
11 # Date created: December 21, 1997
12 # Date modified: December 21, 1997
13 #
14 # IMPORTANT FEATURES
15 #
16 # 1) Parses both short and long-named options
17 # 2) Supports optional arguments
18 # 3) Only uses bash builtins, thus no calls to external
19 # utilities such as expr or sed is done. Therefore,
20 # parsing speed is high enough
21 #
22 #
23 # DESCRIPTION
24 #
25 # FUNCTION getopt
26 # Usage: getopt OPTLIST {"$@"|ALTERNATIVE_PARAMETERS}
27 #
28 # like getopts, but parse options with both required and optional arguments,
29 # Options with optional arguments must have "." instead of ":" after them.
30 # Furthemore, a variable name to place option name cannot be specified
31 # and is always placed in OPTOPT variable
32 #
33 # This function is provided for compatibility with getopts()
34 # OPTLIST style, and it actually calls getoptex (see bellow)
35 #
36 # NOTE that a list of parameters is required and must be either "$@",
37 # if processing command line arguments, or some alternative parameters.
38 #
39 # FUNCTION getoptex
40 # Usage: getoptex OPTION_LIST {"$@"|ALTERNATIVE_PARAMETERS}
41 #
42 # like getopts, but parse long-named options.
43 #
44 # Both getopt and getoptex return 0 if an option has been parsed,
45 # and 1 if all options are already parsed or an error occured
46 #
47 # Both getopt and getoptex set or test the following variables:
48 #
49 # OPTERR -- tested for whether error messages must be given for invalid options
50 #
51 # OPTOPT -- set to the name of an option parsed,
52 # or to "?" if no more options or error
53 # OPTARG -- set to the option argument, if any;
54 # unset if ther is no argument;
55 # on error, set to the erroneous option name
56 #
57 # OPTIND -- Initialized to 1.
58 # Then set to the number of the next parameter to be parsed
59 # when getopt or getoptex will be called next time.
60 # When all options are parsed, contains a number of
61 # the first non-option argument.
62 #
63 #
64 # OPTOFS -- If a parameter number $OPTIND containg an option parsed
65 # does not contain any more options, OPTOFS is unset;
66 # otherwise, OPTOFS is set to such a number of "?" signs
67 # which is equal to the number of options parsed
68 #
69 # You might not set variables OPTIND and OPTOFS yourself
70 # unless you want to parse a list of parameters more than once.
71 # Otherwise, you whould unset OPTIND (or set it to 1)
72 # and unset OPTOFS each time you want to parse a new parameters list
73 #
74 # Option list format is DIFFERENT from one for getopts or getopt. getopts-style
75 # option list can be converted to getoptex-style using a function optlistex
76 # (see bellow)
77 #
78 # DESCRIPTION of option list used with getoptex:
79 # Option names are separated by whitespace. Options consiting of
80 # more than one character are treated as long-named (--option)
81 #
82 # Special characters can appear at the and of option names specifying
83 # whether an argument is required (default is ";"):
84 # ";" (default) -- no argument
85 # ":" -- required argument
86 # "," -- optional argument
87 #
88 # For example, an option list "a b c help version f: file: separator."
89 # defines the following options:
90 # -a, -b, -c, --help, --version -- no argument
91 # -f, --file -- argument required
92 # --separator -- optional argument
93 #
94 # FUNCTION optlistex
95 # Usage new_style_optlist=`optlistex OLD_STYLE_OPTLIST`
96 #
97 # Converts getopts-style option list in a format suitable for use with getoptex
98 # Namely, it inserts spaces after each option name.
99 #
100 #
101 # HOW TO USE
102 #
103 # In order o use in your bash scripts the functions described,
104 # include a command ". getopt.sh" to the file containing the script,
105 # which will define functions getopt, getoptex, and optlistex
106 #
107 # EXAMPLES
108 #
109 # See files 'getopt1' and 'getopt2' that contain sample scripts that use
110 # getopt and getoptex functions respectively
111 #
112 #
113 # Please send your comments to grg@philol.msu.ru
114
115 function getoptex()
116 {
117 let $# || return 1
118 local optlist="${1#;}"
119 let OPTIND || OPTIND=1
120 [ $OPTIND -lt $# ] || return 1
121 shift $OPTIND
122 if [ "$1" != "-" -a "$1" != "${1#-}" ]
123 then OPTIND=$[OPTIND+1]; if [ "$1" != "--" ]
124 then
125 local o
126 o="-${1#-$OPTOFS}"
127 for opt in ${optlist#;}
128 do
129 OPTOPT="${opt%[;.:]}"
130 unset OPTARG
131 local opttype="${opt##*[^;:.]}"
132 [ -z "$opttype" ] && opttype=";"
133 if [ ${#OPTOPT} -gt 1 ]
134 then # long-named option
135 case $o in
136 "--$OPTOPT")
137 if [ "$opttype" != ":" ]; then return 0; fi
138 OPTARG="$2"
139 if [ -z "$OPTARG" ];
140 then # error: must have an agrument
141 let OPTERR && echo "$0: error: $OPTOPT must have an argument" >&2
142 OPTARG="$OPTOPT";
143 OPTOPT="?"
144 return 1;
145 fi
146 OPTIND=$[OPTIND+1] # skip option's argument
147 return 0
148 ;;
149 "--$OPTOPT="*)
150 if [ "$opttype" = ";" ];
151 then # error: must not have arguments
152 let OPTERR && echo "$0: error: $OPTOPT must not have arguments" >&2
153 OPTARG="$OPTOPT"
154 OPTOPT="?"
155 return 1
156 fi
157 OPTARG=${o#"--$OPTOPT="}
158 return 0
159 ;;
160 esac
161 else # short-named option
162 case "$o" in
163 "-$OPTOPT")
164 unset OPTOFS
165 [ "$opttype" != ":" ] && return 0
166 OPTARG="$2"
167 if [ -z "$OPTARG" ]
168 then
169 echo "$0: error: -$OPTOPT must have an argument" >&2
170 OPTARG="$OPTOPT"
171 OPTOPT="?"
172 return 1
173 fi
174 OPTIND=$[OPTIND+1] # skip option's argument
175 return 0
176 ;;
177 "-$OPTOPT"*)
178 if [ $opttype = ";" ]
179 then # an option with no argument is in a chain of options
180 OPTOFS="$OPTOFS?" # move to the next option in the chain
181 OPTIND=$[OPTIND-1] # the chain still has other options
182 return 0
183 else
184 unset OPTOFS
185 OPTARG="${o#-$OPTOPT}"
186 return 0
187 fi
188 ;;
189 esac
190 fi
191 done
192 echo "$0: error: invalid option: $o"
193 fi; fi
194 OPTOPT="?"
195 unset OPTARG
196 return 1
197 }
198 function optlistex
199 {
200 local l="$1"
201 local m # mask
202 local r # to store result
203 while [ ${#m} -lt $[${#l}-1] ]; do m="$m?"; done # create a "???..." mask
204 while [ -n "$l" ]
205 do
206 r="${r:+"$r "}${l%$m}" # append the first character of $l to $r
207 l="${l#?}" # cut the first charecter from $l
208 m="${m#?}" # cut one "?" sign from m
209 if [ -n "${l%%[^:.;]*}" ]
210 then # a special character (";", ".", or ":") was found
211 r="$r${l%$m}" # append it to $r
212 l="${l#?}" # cut the special character from l
213 m="${m#?}" # cut one more "?" sign
214 fi
215 done
216 echo $r
217 }
218 function getopt()
219 {
220 local optlist=`optlistex "$1"`
221 shift
222 getoptex "$optlist" "$@"
223 return $?
224 }
225
226 Usage(){
227 echo "Usage: $0 -[options]"
228 echo "options:"
229 echo "--help show this help message and exit"
230 echo "--port port number(default 6789) "
231 echo "--cmsswlocation cmssw installation base dir(required)"
232 echo "--cmsswversion cmssw version(required)"
233 echo "--hostname hostname(default to hostname)"
234 }
235
236 setcmsswenv(){
237 here=`pwd`
238 cd ${CMSSWLOCATION}/${CMSSWVERSION}
239 eval `scramv1 runtime -sh`
240 cd $here
241 }
242 E_OPTERR=65
243
244 PORT=6789
245 CMSSWLOCATION=
246 CMSSWVERSION=
247 MYHOSTNAME=$HOSTNAME
248 while getoptex "help; hostname: port: cmsswlocation: cmsswversion: hostname: " "$@"
249 do
250 case "$OPTOPT" in
251 "help") Usage; exit 0;;
252 "port") PORT=$OPTARG;;
253 "cmsswlocation") CMSSWLOCATION=$OPTARG ;;
254 "cmsswversion") CMSSWVERSION=$OPTARG;;
255 "hostname") MYHOSTNAME=$OPTARG ;;
256 *) break ;;
257 esac
258 done
259 if [ -e ../etc/profile.d/init.sh ]
260 then
261 #echo 'sourcing init.sh'
262 source ../etc/profile.d/init.sh
263 fi
264 echo "============================================"
265 echo starting server with the following parameters
266 echo "PORT $PORT"
267 echo "CMSSWVERSION $CMSSWVERSION"
268 echo "CMSSWLOCATION $CMSSWLOCATION"
269 echo "HOSTNAME $MYHOSTNAME"
270 echo "============================================"
271
272 setcmsswenv
273 export QUIET_ASSERT=yes
274 python ./server.py --hostname "$MYHOSTNAME" --port "$PORT"
275 exit 0