ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/renameSample.sh
Revision: 1.5
Committed: Sun Jun 19 00:06:01 2011 UTC (13 years, 10 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_024b, Mit_025pre1, Mit_024a, Mit_024
Changes since 1.4: +5 -4 lines
Log Message:
Latest production framework version from 021 when moving to 022.

File Contents

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