#!/bin/bash # if this file is executed, /bin/sh is used, as we don't start with #! # this should work under ash, bash, zsh, ksh, sh style shells. # $1 should be the collection name # $2 should be the oai URL # $3 should the cache directory # $4 should be the max records # $5 should be the OAI metadata prefix # $6 should be GS3 root # $7 should be the collection directory # $8 should the log file # $9 should be the creator # $10 should be the proxy settings COL_NAME=$1 OAI_URL=$2 CACHE_DIR=$3 MAX_RECORDS=$4 OAI_PREF=$5 GS3_ROOT=$6 COLLECT_DIR=$7 LOG_FILE=$8 CREATOR=$9 #SHIFT #PROXY=$9 if [ -x /usr/bin/lsof ] ; then lsof=/usr/bin/lsof else if [ -x /usr/sbin/lsof ] ; then lsof=/usr/sbin/lsof else echo "Warning: Unable to find 'lsof', skipping test for number of files open" fi fi TOMCAT_ID=`ps ux | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $OAI_URL }'` if [ ! -z "$lsof" ] ; then echo Tomcat_ID: $TOMCAT_ID #cd /usr/sbin NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES fi cd $GS3_ROOT source gs3-setup.sh > $LOG_FILE cd gs2build/ source setup.bash >> $LOG_FILE perl -S mkcol.pl -gs3mode -buildtype lucene -collectdir $COLLECT_DIR $COL_NAME echo $COL_NAME $OAI_URL $CACHE_DIR $MAX_RECORDS $OAI_PREF $GS3_ROOT $COLLECT_DIR $LOG_FILE >> $LOG_FILE if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES fi if [ ! -e $CACHE_DIR ] # be sure the cache directory exists then mkdir $CACHE_DIR else /bin/rm -rf $CACHE_DIR/* fi echo "Away to download OAI" >> $LOG_FILE if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES fi perl -S downloadfrom.pl -download_mode OAI -cache_dir $CACHE_DIR -url $OAI_URL -max_records $MAX_RECORDS -metadata_prefix $OAI_PREF $CREATOR 2>&1 >> $LOG_FILE if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES fi