-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbashrc_cern.sh
381 lines (308 loc) · 7.84 KB
/
bashrc_cern.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#!/bin/sh
export HOST=$(hostname | cut -d. -f1)
export USER=${USER:-$(whoami)}
if [ "$PS1" ]; then
# Set auto_resume if you want TWENEX style behaviour for command names.
auto_resume=
# Set notify if you want to be asynchronously notified about background
# job completion.
notify=
# Make it so that failed `exec' commands do not flush this shell.
no_exit_on_failed_exec=
#export HOST=$(hostname | cut -d. -f1)
#export USER=${USER:-$(whoami)}
export EDITOR=vim
#export MAIL=/usr/spool/mail/$USER
#if [ ! "$LOGIN_SHELL" ]; then
PS1="\u_$HOST> "
#fi
HISTSIZE=256
MAILCHECK=60
xtitle() {
if [ $# -gt 1 ]; then
echo -e "\033]1;$1\a\c"
echo -e "\033]2;$2\a\c"
else
echo -e "\033]0;$1\a\c"
fi
}
cd_xtitle() {
xtitle "$USER@$HOST" "$HOST $PWD"
}
[ "$TERM" = "xterm" ] && PROMPT_COMMAND=cd_xtitle
[ -n "$DISPLAY" ] && export GKS3Dconid=$DISPLAY
pwd() {
if [ "${nolinks+set}" = "set" ] ; then
builtin pwd
else
echo "$PWD"
fi
}
fi
#--------------------------------------------------
# General Aliases
#--------------------------------------------------
alias bs="bjobs"
alias bsr="bjobs -u $USER | grep RUN | wc"
alias en="emacs -nw"
alias ec="emacsclient"
alias ls="ls -h --color"
alias lsd="ls -d */"
alias l="ls"
alias ll="ls -lh"
alias p="pwd"
alias cl="rm *~; rm *.orig"
alias rl="root -l"
alias screen='TERM=screen screen' # remove the Wuff!
alias sr='screen -r'
#--------------------------------------------------
# General ENV
#--------------------------------------------------
export CVS_RSH=ssh
export CVSEDITOR=vim
export PATH=$HOME/local/bin:$PATH
export LESS='-R'
export LESSOPEN='|~/.sys/lessfilter.sh %s'
export ILCSOFT=/afs/cern.ch/work/x/xshi/public/ILCSOFT
unset SSH_ASKPASS
#--------------------------------------------------
# Functions
#--------------------------------------------------
batch_kill() {
pgrep $1 | awk '{print "kill -9 "$1}' | sh
}
ki() {
if [ -z "$1" ]; then
echo "fnal (f) ?"
fi;
if [ "$1" = "f" ]; then
kinit -f [email protected]
fi;
}
lk_hist() {
for i in `seq 1 9`; do
ln -sf ~/.bash_history ~/.history.lxplus00$i.cern.ch;
done
for i in `seq 10 99`; do
ln -sf ~/.bash_history ~/.history.lxplus0$i.cern.ch;
done
for i in `seq 100 999`; do
ln -sf ~/.bash_history ~/.history.lxplus$i.cern.ch;
done
}
mnt() {
if [ -z "$1" ]; then
echo "[e] eosmount /afs/cern.ch/user/x/xshi/eos"
echo "[ef] eosforceumount /afs/cern.ch/user/x/xshi/eos"
echo "[eu] eosumount /afs/cern.ch/user/x/xshi/eos"
read menu
else
menu=$1
fi
case $menu in
e) eosmount /afs/cern.ch/user/x/xshi/eos
;;
ef) eosforceumount /afs/cern.ch/user/x/xshi/eos
eosmount /afs/cern.ch/user/x/xshi/eos
;;
eu) eosumount /afs/cern.ch/user/x/xshi/eos
;;
esac
}
setafb() {
echo -ne "Setting afb ...\r"
export afb=$HOME/work/cms/afb
export src=$afb/src
export dat=$afb/dat
export doc=$afb/doc
export fig=$doc/fig
export log=$afb/log
export rafb=$afb
if [ -z "$1" ]; then
echo "[run2011v0] CMSSW_4_2_8_patch7, run2011v0"
echo "[run2011v1] CMSSW_4_2_8_patch7, run2011v1"
echo "[run2012v0] CMSSW_5_3_9_patch3, run2012v0"
read code_tag
else
code_tag=$1
fi
case $code_tag in
run2011v0) cmssw="CMSSW_4_2_8_patch7"
;;
run2011v1) cmssw="CMSSW_4_2_8_patch7"
;;
run2012v0) cmssw="CMSSW_5_3_9_patch3"
;;
esac
export rel=$afb/rel/$cmssw/src
cd $rel ; eval `scram runtime -sh`
export build=$rel/BphAna/BToKstarMuMu_$code_tag
export run=$build/python
case $2 in
g) setgrid
;;
esac
#. $src/sh/bash_completion.sh
echo "Setting afb ... done."
}
setdas() {
echo -ne "Setting das ...\r"
export das=$HOME/work/cms/das/2012
export src=$das/CMSSW_5_2_5/src
echo "Setting das ... done."
}
setgrid() {
echo -ne "Setting GRID ...\r"
source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh
source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh
#voms-proxy-init --voms cms
echo "Setting GRID ... done."
}
sethbb() {
echo -ne "Setting hbb ...\r"
export hbb=$HOME/work/cms/hbb
export rel=$hbb/rel/CMSSW_5_3_9/src
cd $rel ; eval `scram runtime -sh`
export build=$rel/HbbAna/BprimeTobH
export test=$build/test
echo "Setting hbb ... done."
}
setmcb() {
if [ -z "$1" ]; then
echo "[0] CMSSW_5_3_7"
echo "[1] CMSSW_4_4_4"
echo "[2] CMSSW_4_2_8_patch7"
echo "[3] CMSSW_4_1_8_patch9"
read menu
else
menu=$1
fi
case $menu in
0) cmssw="CMSSW_5_3_7"
;;
1) cmssw="CMSSW_4_4_4"
;;
2) cmssw="CMSSW_4_2_8_patch7"
;;
3) cmssw="CMSSW_4_1_8_patch9"
;;
esac
echo -ne "Setting mcb ...\r"
export mcb=$HOME/work/cms/mcb
export rel=$mcb/rel/$cmssw/src
cd $rel ; eval `scram runtime -sh`
echo "Setting mcb ... done."
}
setpxl() {
export pxl=$HOME/work/cms/pxl
if [ -z "$1" ]; then
echo "[tbm] TestBeam EUTel Software"
echo "[cal] cmspxltb Calibration Software"
read menu
else
menu=$1
fi
case $menu in
tbm)
settbm $2
;;
cal)
export src=$HOME/work/cms/pxl/tbm/cmspxltb
cd $src
. env.sh
;;
esac
}
setroot() {
echo -ne "Setting ROOT ...\r"
if [ -z "$1" ]; then
root=5.32.01
. /afs/cern.ch/sw/lcg/external/gcc/4.3.2/x86_64-slc5/setup.sh
. /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/bin/thisroot.sh
fi;
echo "Setting ROOT ... $root done."
}
settbm() {
echo -ne "Setting tbm ...\r"
export WORKSPACE=`pwd`
if [ -z "$1" ]; then
export TB_ANALYSIS=/afs/cern.ch/user/x/xshi/work/cms/pxl/tbm/TestBeam/Analysis
export ILCSOFT=${TB_ANALYSIS}/ilcsoft
cd $ILCSOFT/v01-12/Eutelescope/HEAD/
source build_env.sh
else
source /afs/cern.ch/work/y/ymtzeng/public/PixelBeamTestAnalysis/env_current.sh
fi;
export pxl=$HOME/work/cms/pxl
export tbm=$pxl/tbm
#export simplesub=$pxl/tbm/simplesub
export simplesub=${EUTELESCOPE}/simplesub
export dqm=$simplesub/dqm #_dev use the hg instead
export dat=$simplesub/CMSPixel
cd $dqm && source setup.sh
export LD_LIBRARY_PATH=/opt/cactus/lib:$LD_LIBRARY_PATH
export PATH=/opt/cactus/bin:$PATH
export PYTHONPATH=$HOME/work/cms/pxl/tbm/uhal/PyChips_1_4_3/src:$PYTHONPATH
cd ${WORKSPACE}
echo "Setting tbm ... done."
}
setdqm() {
echo -ne "Setting dqm ...\r"
. /afs/cern.ch/cms/Tracker/Pixel/HRbeamtest/dqm/v3/setup.sh
export dqm=/afs/cern.ch/cms/Tracker/Pixel/HRbeamtest/dqm
echo "Setting dqm ... done."
}
sl() {
if [ -z "$1" ]; then
echo "[f5] cmslpc-sl5.fnal.gov"
echo "[n] ntucms1.cern.ch"
echo "[np] pixel_dev@ntucms1"
echo "[t] pcpixeltb"
echo "[db] mysql --host=dbod-cmspxltb.cern.ch --port=5503 --user=admin -p"
read menu
else
menu=$1
fi
case $menu in
f5) ssh -Y [email protected]
;;
n) ssh -Y [email protected]
;;
np) ssh -Y [email protected]
;;
p) ssh [email protected]
;;
t) ssh -Y [email protected]
;;
db) mysql --host=dbod-cmspxltb.cern.ch --port=5503 --user=admin -p
;;
esac
}
uptbm(){
echo "Updating tbm ..."
cd ${EUTELESCOPE}/../branches/cmspixel
svn update
cd ${EUTELESCOPE}/../
cp branches/cmspixel/src/*cc HEAD/src/
cp branches/cmspixel/include/*h HEAD/include/
cd ${EUTELESCOPE}/build
cmake ..
make clean
make install -j 4
cd ${EUTELESCOPE}
pwd
}
pkgdqm(){
if [ -z "$1" ]; then
echo "Please give the tag number. (eg: 1.2)"
else
echo "Packging dqm $1 ... "
cd $dqm
hg tag -f "$1"
hg arc -r "$1" ~/www/pxl/dqm/src/dqm-$1.tar.gz
echo "Saved as: https://cern.ch/xshi/pxl/dqm/src/dqm-$1.tar.gz"
fi;
}
if [ `hostname -s` = ntucms1 ] || [ `hostname -s` = ntucms2 ] ; then
setroot
fi