ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/renameSample.sh
Revision: 1.6
Committed: Mon Sep 19 21:45:41 2011 UTC (13 years, 7 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_025pre2
Changes since 1.5: +12 -3 lines
Log Message:
Reinstate the bin and python areas.

File Contents

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