ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/renameSample.sh
Revision: 1.7
Committed: Wed Sep 28 21:02:50 2011 UTC (13 years, 7 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_025c_branch1, Mit_025c_branch0, Mit_025c, Mit_025b, Mit_025a, Mit_025
Branch point for: Mit_025c_branch
Changes since 1.6: +16 -6 lines
Log Message:
Use of central sample database.

File Contents

# Content
1 #!/bin/bash
2 #---------------------------------------------------------------------------------------------------
3 # Rename an existing sample (so far all potentially exisiting catalog info will have to be redone)
4 #---------------------------------------------------------------------------------------------------
5 domain=`echo $HOSTNAME | cut -d'.' -f2-100`
6 CATALOG="~cmsprod/catalog"
7 BOOK="filefi/${MIT_VERS}"
8 if [ "$domain" == "mit.edu" ]
9 then
10 # For MIT
11 SERVER="srm://se01.cmsaf.mit.edu:8443/srm/managerv2?SFN="
12 LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
13 LOCAL_LOCATION="/mnt/hadoop/cmsprod"
14 else
15 # For CERN
16 SERVER="srm://srm-cms.cern.ch:8443/srm/managerv2?SFN="
17 LOCATION="/castor/cern.ch/user/p/paus"
18 LOCAL_LOCATION="/data/hadoop/cmsprod"
19 fi
20
21 klist -s
22 if [ $? != 0 ]; then
23 kinit -f
24 fi
25
26 SOURCE="$1"
27 TARGET="$2"
28
29 echo ""
30 echo "Trying to rename sample: $SOURCE to $TARGET"
31 echo " in: $SERVER/$LOCATION/$BOOK"
32 echo ""
33 echo ""
34
35 sourceExists=`srmls -recursion_depth=0 ${SERVER}${LOCATION}/${BOOK}/$SOURCE 2> /dev/null`
36 echo " Existing - source: $sourceExists"
37 targetExists=`srmls -recursion_depth=0 ${SERVER}${LOCATION}/${BOOK}/$TARGET 2> /dev/null`
38 echo " Existing - target: $targetExists"
39
40 # first the original files
41 if [ ".$sourceExists" != "." ] && [ ".$targetExists" == "." ]
42 then
43 move ${LOCATION}/${BOOK}/$SOURCE ${LOCATION}/${BOOK}/$TARGET
44 ~paus/bin/repstr $SOURCE $TARGET $MIT_RPOD_DIR/$BOOK/Productions.*
45 fi
46
47 # now the local files
48 if [ -d "${LOCAL_LOCATION}/${BOOK}/$SOURCE" ] && ! [ -d "${LOCAL_LOCATION}/${BOOK}/$TARGET" ]
49 then
50 move ${LOCAL_LOCATION}/${BOOK}/$SOURCE ${LOCAL_LOCATION}/${BOOK}/$TARGET
51 fi
52
53 # next are the catalogs
54 cd $CATALOG/t2mit/$BOOK
55 if [ -d $SOURCE ]
56 then
57 mv $SOURCE $TARGET
58 cd $TARGET
59 ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
60 fi
61
62 cd $CATALOG/local/$BOOK
63 if [ -d $SOURCE ]
64 then
65 mv $SOURCE $TARGET
66 cd $TARGET
67 ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
68 fi
69
70
71 exit 0
72
73 ## MIT_LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
74 ## CERN_LOCATION="/castor/cern.ch/user/p/paus"
75 ## CATALOG=$HOME/catalog
76 ##
77 ## # Health checks
78 ## if [ ".$1" == "." ]
79 ## then
80 ## H=`basename $0`
81 ## echo "";echo " usage: $H <version> [ <pattern> [ <location> ] ]"; echo ""
82 ## exit 1
83 ## fi
84 ##
85 ## # Decode command line parameters
86 ## VERSION="$1"
87 ## PATTERN="empty"
88 ## if [ ".$2" != "." ]
89 ## then
90 ## PATTERN=$2
91 ## fi
92 ## LOCATION=$MIT_LOCATION
93 ## if [ ".$3" != "." ]
94 ## then
95 ## LOCATION=$3
96 ## fi
97 ##
98 ## # Create a list of the datsets we need to catalog
99 ## echo ""
100 ## if [ "`echo $LOCATION | grep castor`" != "" ]
101 ## then
102 ## echo " Identified a castor sample request. Using rfdir on $LOCATION"
103 ## CATALOG=$CATALOG/cern
104 ## LIST=`rfdir $LOCATION/filler/$VERSION | tr -s ' ' | cut -d ' ' -f 9`
105 ## elif [ "`echo $LOCATION | grep cmsaf.mit.edu`" != "" ]
106 ## then
107 ## echo " Identified a tier-2 sample request. Using srmls on $LOCATION"
108 ## CATALOG=$CATALOG/t2mit
109 ## LIST=`srmls ${SERVER}${LOCATION}/filler/$VERSION | grep ' ' | tr -s ' ' | cut -d ' ' -f 3`
110 ## else
111 ## echo " Identified a local sample request. Using ls on $LOCATION"
112 ## CATALOG=$CATALOG/local
113 ## LIST=`ls -1 $LOCATION/filler/$VERSION`
114 ## fi
115 ##
116 ## # Show me the list
117 ## echo ""
118 ## echo "== LIST =="
119 ## echo $LIST
120 ##
121 ## # Loop through the list and catalog
122 ## echo ""
123 ## for dataset in $LIST; do
124 ## dataset=`basename $dataset`
125 ## if [ "$PATTERN" == "empty" ] || [ "`echo $dataset | grep $PATTERN`" != "" ]
126 ## then
127 ## ./catalogFiles.csh $LOCATION $CATALOG filler/$VERSION $dataset
128 ## fi
129 ## done