#!/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 GS3 root # $5 should be the collection directory # $6 should the log file # $7 should be the host name : port number COL_NAME=$1 OAI_URL=$2 CACHE_DIR=$3 GS3_ROOT=$4 COL_DIR=$5 LOG_FILE=$6 HOST_PORT=$7 # check we are still in the right directories 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 }'` echo Tomcat_ID: $TOMCAT_ID if [ ! -z "$lsof" ] ; then 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 # event log goes to greenstone3/gs2build/etc/events.txt ## build -indextype lucene -site localsite -collectdir $COLLECT_DIR -download file://$3 -log_events $1 echo "Away to build" >> $LOG_FILE /bin/cp -r $CACHE_DIR/* $COL_DIR/$COL_NAME/import/. echo "perl -S incremental-rebuild.pl -site localsite -collectdir $COL_DIR $COL_NAME" perl -S incremental-rebuild.pl -site localsite -collectdir $COL_DIR $COL_NAME #build -indextype lucene -site localsite -collectdir $COL_DIR -log_events -download file://$CACHE_DIR $COL_NAME 2>&1 #2>&1 >> $LOG_FILE # -log_events # >> $LOG_FILE if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo Finished Build: open files: $NUM_OPEN_FILES fi echo "Build finished ...." >> $LOG_FILE if [ -d $GS3_ROOT/gs2build/collect/$COL_NAME ] then echo "moving from gs2 dir" >> $LOG_FILE echo built in gs2 dir ... moving mv $GS3_ROOT/gs2build/collect/$COL_NAME $COL_DIR/$COL_NAME fi if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES # >> $LOG_FILE fi echo "Away to reconfigure Greenstone 3 server" >> $LOG_FILE echo "Away to reconfigure Greenstone 3 server" # >> $LOG_FILE #wget -O /tmp/mat5.html "http://localhost:8090/greenstone3/library?a=s&sa=c" wget -O /tmp/mat3.html "http://$HOST_PORT/greenstone3/library?a=s&sa=c" echo "Done" >> $LOG_FILE echo "Done" if [ ! -z "$lsof" ] ; then NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l ` echo open files: $NUM_OPEN_FILES $lsof -p $TOMCAT_ID # >> $LOG_FILE fi #exit 0