ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/renameSample.sh
Revision: 1.3
Committed: Sat Mar 19 01:49:13 2011 UTC (14 years, 1 month ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_020d, TMit_020d, Mit_020c, Mit_021pre1, Mit_020b, Mit_020a, Mit_020
Changes since 1.2: +1 -1 lines
Log Message:
Small updates here and there.

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 SERVER="srm://se01.cmsaf.mit.edu:8443/srm/managerv2?SFN="
6 LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
7 BOOK="filefi/018"
8 LOCAL_LOCATION="/mnt/hadoop/cmsprod"
9 CATALOG="/home/cmsprod/catalog"
10 #SERVER="srm://srm-cms.cern.ch:8443/srm/managerv2?SFN="
11 #LOCATION="/castor/cern.ch/user/p/paus/filefi/014"
12
13 SOURCE="$1"
14 TARGET="$2"
15
16 sourceExists=`srmls ${SERVER}${LOCATION}/${BOOK} | grep $SOURCE`
17 echo " Existing - source: $sourceExists"
18 targetExists=`srmls ${SERVER}${LOCATION}/${BOOK} | grep $TARGET`
19 echo " Existing - target: $targetExists"
20
21 # first the original files
22 if [ ".$sourceExists" != "." ] && [ ".$targetExists" == "." ]
23 then
24 move ${LOCATION}/${BOOK}/$SOURCE ${LOCATION}/${BOOK}/$TARGET
25 fi
26
27 # now the local files
28 if [ -d "${LOCAL_LOCATION}/${BOOK}/$SOURCE" ] && ! [ -d "${LOCAL_LOCATION}/${BOOK}/$TARGET" ]
29 then
30 move ${LOCAL_LOCATION}/${BOOK}/$SOURCE ${LOCAL_LOCATION}/${BOOK}/$TARGET
31 fi
32
33 # next are the catalogs
34 cd $CATALOG/t2mit/$BOOK
35 if [ -d $SOURCE ]
36 then
37 mv $SOURCE $TARGET
38 cd $TARGET
39 ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
40 fi
41
42 cd $CATALOG/local/$BOOK
43 if [ -d $SOURCE ]
44 then
45 mv $SOURCE $TARGET
46 cd $TARGET
47 ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
48 fi
49
50
51 exit 0
52
53 ## MIT_LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
54 ## CERN_LOCATION="/castor/cern.ch/user/p/paus"
55 ## CATALOG=$HOME/catalog
56 ##
57 ## # Health checks
58 ## if [ ".$1" == "." ]
59 ## then
60 ## H=`basename $0`
61 ## echo "";echo " usage: $H <version> [ <pattern> [ <location> ] ]"; echo ""
62 ## exit 1
63 ## fi
64 ##
65 ## # Decode command line parameters
66 ## VERSION="$1"
67 ## PATTERN="empty"
68 ## if [ ".$2" != "." ]
69 ## then
70 ## PATTERN=$2
71 ## fi
72 ## LOCATION=$MIT_LOCATION
73 ## if [ ".$3" != "." ]
74 ## then
75 ## LOCATION=$3
76 ## fi
77 ##
78 ## # Create a list of the datsets we need to catalog
79 ## echo ""
80 ## if [ "`echo $LOCATION | grep castor`" != "" ]
81 ## then
82 ## echo " Identified a castor sample request. Using rfdir on $LOCATION"
83 ## CATALOG=$CATALOG/cern
84 ## LIST=`rfdir $LOCATION/filler/$VERSION | tr -s ' ' | cut -d ' ' -f 9`
85 ## elif [ "`echo $LOCATION | grep cmsaf.mit.edu`" != "" ]
86 ## then
87 ## echo " Identified a tier-2 sample request. Using srmls on $LOCATION"
88 ## CATALOG=$CATALOG/t2mit
89 ## LIST=`srmls ${SERVER}${LOCATION}/filler/$VERSION | grep ' ' | tr -s ' ' | cut -d ' ' -f 3`
90 ## else
91 ## echo " Identified a local sample request. Using ls on $LOCATION"
92 ## CATALOG=$CATALOG/local
93 ## LIST=`ls -1 $LOCATION/filler/$VERSION`
94 ## fi
95 ##
96 ## # Show me the list
97 ## echo ""
98 ## echo "== LIST =="
99 ## echo $LIST
100 ##
101 ## # Loop through the list and catalog
102 ## echo ""
103 ## for dataset in $LIST; do
104 ## dataset=`basename $dataset`
105 ## if [ "$PATTERN" == "empty" ] || [ "`echo $dataset | grep $PATTERN`" != "" ]
106 ## then
107 ## ./catalogFiles.csh $LOCATION $CATALOG filler/$VERSION $dataset
108 ## fi
109 ## done