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
|
---|
15 | GS3_ROOT=$6
|
---|
16 | COLLECT_DIR=$7
|
---|
17 | LOG_FILE=$8
|
---|
18 | CACHE_DIR=$3
|
---|
19 |
|
---|
20 | if [ -x /usr/bin/lsof ] ; then
|
---|
21 | lsof=/usr/bin/lsof
|
---|
22 | else
|
---|
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
|
---|
28 | fi
|
---|
29 |
|
---|
30 | TOMCAT_ID=`ps ux | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $2 }'`
|
---|
31 |
|
---|
32 | if [ ! -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
|
---|
37 | fi
|
---|
38 |
|
---|
39 | cd $GS3_ROOT
|
---|
40 |
|
---|
41 | source gs3-setup.sh > $LOG_FILE
|
---|
42 |
|
---|
43 | cd gs2build/
|
---|
44 | source setup.bash >> $LOG_FILE
|
---|
45 |
|
---|
46 | perl -S mkcol.pl -gs3mode -collectdir $COLLECT_DIR $1
|
---|
47 |
|
---|
48 | echo $1 $2 $3 $4 $5 $6 $7 $8 >> $LOG_FILE
|
---|
49 |
|
---|
50 | if [ ! -z "$lsof" ] ; then
|
---|
51 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
52 | echo open files: $NUM_OPEN_FILES
|
---|
53 | fi
|
---|
54 |
|
---|
55 | if [ ! -e $CACHE_DIR ] # be sure the cache directory exists
|
---|
56 | then
|
---|
57 | mkdir $CACHE_DIR
|
---|
58 | else
|
---|
59 | /bin/rm -rf $CACHE_DIR/*
|
---|
60 | fi
|
---|
61 |
|
---|
62 | echo "Away to download OAI" >> $LOG_FILE
|
---|
63 |
|
---|
64 | if [ ! -z "$lsof" ] ; then
|
---|
65 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
66 | echo open files: $NUM_OPEN_FILES
|
---|
67 | fi
|
---|
68 |
|
---|
69 | perl -S downloadfrom.pl -download_mode OAI -cache_dir $CACHE_DIR -url $2 -max_records $4 -metadata_prefix $5 $9 2>&1 >> $LOG_FILE
|
---|
70 |
|
---|
71 | if [ ! -z "$lsof" ] ; then
|
---|
72 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
73 | echo open files: $NUM_OPEN_FILES
|
---|
74 | fi
|
---|
75 |
|
---|
76 |
|
---|