[21996] | 1 | #!/bin/bash
|
---|
[18086] | 2 | # if this file is executed, /bin/sh is used, as we don't start with #!
|
---|
| 3 | # this should work under ash, bash, zsh, ksh, sh style shells.
|
---|
| 4 | # $1 should be the collection name
|
---|
| 5 | # $2 should be the oai URL
|
---|
| 6 | # $3 should the cache directory
|
---|
| 7 | # $4 should be the max records
|
---|
| 8 | # $5 should be the OAI metadata prefix
|
---|
| 9 | # $6 should be GS3 root
|
---|
| 10 | # $7 should be the collection directory
|
---|
| 11 | # $8 should the log file
|
---|
[21996] | 12 | # $9 should be the host name : port number
|
---|
[18086] | 13 |
|
---|
| 14 | #$GS3_ROOT=$6
|
---|
| 15 | #$COLLECT_DIR=$7
|
---|
| 16 | #$LOG_FILE=$8
|
---|
[21996] | 17 | CACHE_DIR=$3
|
---|
[18086] | 18 |
|
---|
| 19 | # check we are still in the right directories
|
---|
| 20 |
|
---|
[21996] | 21 | if [ -x /usr/bin/lsof ] ; then
|
---|
| 22 | lsof=/usr/bin/lsof
|
---|
| 23 | else
|
---|
| 24 | if [ -x /usr/sbin/lsof ] ; then
|
---|
| 25 | lsof=/usr/sbin/lsof
|
---|
| 26 | else
|
---|
| 27 | echo "Warning: Unable to find 'lsof', skipping test for number of files open"
|
---|
| 28 | fi
|
---|
| 29 | fi
|
---|
| 30 |
|
---|
[18086] | 31 | TOMCAT_ID=`ps ux | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $2 }'`
|
---|
| 32 | echo Tomcat_ID: $TOMCAT_ID
|
---|
| 33 |
|
---|
[21996] | 34 | if [ ! -z "$lsof" ] ; then
|
---|
| 35 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
| 36 | echo open files: $NUM_OPEN_FILES
|
---|
| 37 | fi
|
---|
[18086] | 38 |
|
---|
| 39 | cd $6
|
---|
| 40 | source gs3-setup.sh >> $8
|
---|
| 41 |
|
---|
| 42 | cd gs2build/
|
---|
| 43 | source setup.bash >> $8
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | # event log goes to greenstone3/gs2build/etc/events.txt
|
---|
| 47 |
|
---|
| 48 | ## build -indextype lucene -site localsite -collectdir $COLLECT_DIR -download file://$3 -log_events $1
|
---|
| 49 |
|
---|
| 50 | echo "Away to build" >> $8
|
---|
| 51 |
|
---|
[21996] | 52 | build -indextype lucene -site localsite -collectdir $7 -log_events -download file://$CACHE_DIR $1 2>&1
|
---|
[18086] | 53 | #2>&1 >> $LOG_FILE
|
---|
| 54 |
|
---|
| 55 | # -log_events
|
---|
| 56 | # >> $LOG_FILE
|
---|
[21996] | 57 | if [ ! -z "$lsof" ] ; then
|
---|
| 58 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
| 59 | echo open files: $NUM_OPEN_FILES
|
---|
| 60 | fi
|
---|
[18086] | 61 |
|
---|
| 62 | echo "Build finished ...." >> $8
|
---|
| 63 |
|
---|
| 64 | if [ -d $6/gs2build/collect/$1 ]
|
---|
| 65 | then
|
---|
| 66 | echo "moving from gs2 dir" >> $8
|
---|
| 67 | echo built in gs2 dir ... moving
|
---|
| 68 | mv $6/gs2build/collect/$1 $7/$1
|
---|
| 69 | fi
|
---|
| 70 |
|
---|
| 71 | echo "Away to convert from Greenstone 2 to Greenstone 3" >> $8
|
---|
| 72 | echo "Away to convert from Greenstone 2 to Greenstone 3"
|
---|
| 73 |
|
---|
| 74 | # >> $LOG_FILE
|
---|
| 75 |
|
---|
[21996] | 76 | if [ ! -z "$lsof" ] ; then
|
---|
| 77 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
| 78 | echo open files: $NUM_OPEN_FILES
|
---|
| 79 | # >> $LOG_FILE
|
---|
| 80 | fi
|
---|
[18086] | 81 |
|
---|
| 82 | echo "Away to reconfigure Greenstone 3 server" >> $8
|
---|
| 83 | echo "Away to reconfigure Greenstone 3 server"
|
---|
| 84 |
|
---|
| 85 | # >> $LOG_FILE
|
---|
| 86 |
|
---|
| 87 | #wget -O /tmp/mat5.html "http://localhost:8090/greenstone3/library?a=s&sa=c"
|
---|
[21996] | 88 | wget -O /tmp/mat3.html "http://$9/greenstone3/library?a=s&sa=c"
|
---|
[18086] | 89 |
|
---|
| 90 | echo "Done" >> $8
|
---|
| 91 | echo "Done"
|
---|
| 92 |
|
---|
[21996] | 93 | if [ ! -z "$lsof" ] ; then
|
---|
| 94 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
| 95 | echo open files: $NUM_OPEN_FILES
|
---|
| 96 |
|
---|
| 97 | $lsof -p $TOMCAT_ID
|
---|
[18086] | 98 | # >> $LOG_FILE
|
---|
[21996] | 99 | fi
|
---|
[18086] | 100 |
|
---|
| 101 |
|
---|
| 102 | #exit 0
|
---|