1 | #!/bin/bash
|
---|
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 GS3 root
|
---|
8 | # $5 should be the collection directory
|
---|
9 | # $6 should the log file
|
---|
10 | # $7 should be the host name : port number
|
---|
11 |
|
---|
12 | COL_NAME=$1
|
---|
13 | OAI_URL=$2
|
---|
14 | CACHE_DIR=$3
|
---|
15 | GS3_ROOT=$4
|
---|
16 | COL_DIR=$5
|
---|
17 | LOG_FILE=$6
|
---|
18 | HOST_PORT=$7
|
---|
19 |
|
---|
20 | # check we are still in the right directories
|
---|
21 |
|
---|
22 | if [ -x /usr/bin/lsof ] ; then
|
---|
23 | lsof=/usr/bin/lsof
|
---|
24 | else
|
---|
25 | if [ -x /usr/sbin/lsof ] ; then
|
---|
26 | lsof=/usr/sbin/lsof
|
---|
27 | else
|
---|
28 | echo "Warning: Unable to find 'lsof', skipping test for number of files open"
|
---|
29 | fi
|
---|
30 | fi
|
---|
31 |
|
---|
32 | TOMCAT_ID=`ps ux | grep tomcat | grep java | grep -v grep | awk -F" " '{ print $OAI_URL }'`
|
---|
33 | echo Tomcat_ID: $TOMCAT_ID
|
---|
34 |
|
---|
35 | if [ ! -z "$lsof" ] ; then
|
---|
36 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
37 | echo open files: $NUM_OPEN_FILES
|
---|
38 | fi
|
---|
39 |
|
---|
40 | cd $GS3_ROOT
|
---|
41 | source gs3-setup.sh >> $LOG_FILE
|
---|
42 |
|
---|
43 | cd gs2build/
|
---|
44 | source setup.bash >> $LOG_FILE
|
---|
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" >> $LOG_FILE
|
---|
51 | #echo "BABAB CACHE_DIR = Q $CACHE_DIR Q - COL_DIR = Q $COL_DIR Q - COL_NAME = Q $COL_NAME Q"
|
---|
52 | #echo "AAAAA /bin/cp -r" $CACHE_DIR/* "$COL_DIR/$COL_NAME/import/."
|
---|
53 | /bin/cp -r $CACHE_DIR/* $COL_DIR/$COL_NAME/import/.
|
---|
54 |
|
---|
55 | echo "perl -S incremental-rebuild.pl -site localsite -collectdir $COL_DIR $COL_NAME"
|
---|
56 |
|
---|
57 | perl -S incremental-rebuild.pl -site localsite -collectdir $COL_DIR $COL_NAME
|
---|
58 |
|
---|
59 | #build -indextype lucene -site localsite -collectdir $COL_DIR -log_events -download file://$CACHE_DIR $COL_NAME 2>&1
|
---|
60 | #2>&1 >> $LOG_FILE
|
---|
61 |
|
---|
62 | # -log_events
|
---|
63 | # >> $LOG_FILE
|
---|
64 | if [ ! -z "$lsof" ] ; then
|
---|
65 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
66 | echo Finished Build: open files: $NUM_OPEN_FILES
|
---|
67 | fi
|
---|
68 |
|
---|
69 | echo "Build finished ...." >> $LOG_FILE
|
---|
70 |
|
---|
71 | if [ -d $GS3_ROOT/gs2build/collect/$COL_NAME ]
|
---|
72 | then
|
---|
73 | echo "moving from gs2 dir" >> $LOG_FILE
|
---|
74 | echo built in gs2 dir ... moving
|
---|
75 | mv $GS3_ROOT/gs2build/collect/$COL_NAME $COL_DIR/$COL_NAME
|
---|
76 | fi
|
---|
77 |
|
---|
78 |
|
---|
79 | if [ ! -z "$lsof" ] ; then
|
---|
80 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
81 | echo open files: $NUM_OPEN_FILES
|
---|
82 | # >> $LOG_FILE
|
---|
83 | fi
|
---|
84 |
|
---|
85 | echo "Away to reconfigure Greenstone 3 server" >> $LOG_FILE
|
---|
86 | echo "Away to reconfigure Greenstone 3 server"
|
---|
87 |
|
---|
88 | # >> $LOG_FILE
|
---|
89 |
|
---|
90 | #wget -O /tmp/mat5.html "http://localhost:8090/greenstone3/library?a=s&sa=c"
|
---|
91 | wget -O /tmp/mat3.html "http://$HOST_PORT/greenstone3/library?a=s&sa=c"
|
---|
92 |
|
---|
93 | echo "Done" >> $LOG_FILE
|
---|
94 | echo "Done"
|
---|
95 |
|
---|
96 | if [ ! -z "$lsof" ] ; then
|
---|
97 | NUM_OPEN_FILES=`$lsof -p $TOMCAT_ID | wc -l `
|
---|
98 | echo open files: $NUM_OPEN_FILES
|
---|
99 |
|
---|
100 | $lsof -p $TOMCAT_ID
|
---|
101 | # >> $LOG_FILE
|
---|
102 | fi
|
---|
103 |
|
---|
104 |
|
---|
105 | #exit 0
|
---|