source: gs3-extensions/mat/trunk/bin/script/mat-colbuild-download.bash@ 22002

Last change on this file since 22002 was 22002, checked in by sjm84, 14 years ago

Updated to find lsof in either /usr/bin or /usr/sbin and various other small changes

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/bin/bash
2
3# if this file is executed, /bin/sh is used, as we don't start with #!
4# this should work under ash, bash, zsh, ksh, sh style shells.
5# $1 should be the collection name
6# $2 should be the oai URL
7# $3 should the cache directory
8# $4 should be the max records
9# $5 should be the OAI metadata prefix
10# $6 should be GS3 root
11# $7 should be the collection directory
12# $8 should the log file
13# $9 should be the creator
14# $10 should be the proxy settings
15GS3_ROOT=$6
16COLLECT_DIR=$7
17LOG_FILE=$8
18CACHE_DIR=$3
19
20if [ -x /usr/bin/lsof ] ; then
21 lsof=/usr/bin/lsof
22else
23 if [ -x /usr/sbin/lsof ] ; then
24 lsof=/usr/sbin/lsof
25 else
26 echo "Warning: Unable to find 'lsof', skipping test for number of files open"
27 fi
28fi
29
30TOMCAT_ID=`ps ux | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $2 }'`
31
32if [ ! -z "$lsof" ] ; then
33 echo Tomcat_ID: $TOMCAT_ID
34 #cd /usr/sbin
35 NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
36 echo open files: $NUM_OPEN_FILES
37fi
38
39cd $GS3_ROOT
40
41source gs3-setup.sh > $LOG_FILE
42
43cd gs2build/
44source setup.bash >> $LOG_FILE
45
46perl -S mkcol.pl -gs3mode -collectdir $COLLECT_DIR $1
47
48echo $1 $2 $3 $4 $5 $6 $7 $8 >> $LOG_FILE
49
50if [ ! -z "$lsof" ] ; then
51 NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
52 echo open files: $NUM_OPEN_FILES
53fi
54
55if [ ! -e $CACHE_DIR ] # be sure the cache directory exists
56then
57 mkdir $CACHE_DIR
58else
59 /bin/rm -rf $CACHE_DIR/*
60fi
61
62echo "Away to download OAI" >> $LOG_FILE
63
64if [ ! -z "$lsof" ] ; then
65 NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
66 echo open files: $NUM_OPEN_FILES
67fi
68
69perl -S downloadfrom.pl -download_mode OAI -cache_dir $CACHE_DIR -url $2 -max_records $4 -metadata_prefix $5 $9 2>&1 >> $LOG_FILE
70
71if [ ! -z "$lsof" ] ; then
72 NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
73 echo open files: $NUM_OPEN_FILES
74fi
75
76
Note: See TracBrowser for help on using the repository browser.