1 | #!/bin/sh
|
---|
2 |
|
---|
3 | echo 'Greenstone Librarian Interface (GLI)'
|
---|
4 | echo 'Copyright (C) 2002 Greenstone Digital Libraries, University Of Waikato'
|
---|
5 | echo 'GLI comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt'
|
---|
6 | echo 'This is free software, and you are welcome to redistribute it'
|
---|
7 | echo
|
---|
8 |
|
---|
9 | ## -------- Run the Greenstone Librarian Interface --------
|
---|
10 |
|
---|
11 | # This script must be run from within the directory in which it lives
|
---|
12 | thisdir=`pwd`
|
---|
13 | if [ ! -f "${thisdir}/gli.sh" ]; then
|
---|
14 | echo "This script must be run from the directory in which it resides."
|
---|
15 | exit 1
|
---|
16 | fi
|
---|
17 |
|
---|
18 |
|
---|
19 | ## ---- Determine GSDLHOME ----
|
---|
20 | gsdlpath=/research/jmt12/gsdl
|
---|
21 |
|
---|
22 | # Some users may set the above line manually
|
---|
23 | if [ "$gsdlpath" == "" ]; then
|
---|
24 | # Check the environment variable first
|
---|
25 | if [ "$GSDLHOME" != "" ]; then
|
---|
26 | gsdlpath=$GSDLHOME
|
---|
27 |
|
---|
28 | # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone
|
---|
29 | else
|
---|
30 | pushd .. > /dev/null
|
---|
31 | gsdlpath=`pwd`
|
---|
32 | popd > /dev/null
|
---|
33 | fi
|
---|
34 | fi
|
---|
35 |
|
---|
36 | # Check that the Greenstone installation looks OK
|
---|
37 | echo "Checking GSDL: $gsdlpath"
|
---|
38 | if [ ! -f "${gsdlpath}/setup.bash" ] ; then
|
---|
39 | echo
|
---|
40 | echo "The Greenstone installation could not be found, or is incomplete."
|
---|
41 | echo "Try reinstalling Greenstone then running this script again."
|
---|
42 | exit 1
|
---|
43 | fi
|
---|
44 |
|
---|
45 | # Setup Greenstone, unless it has already been done
|
---|
46 | if [ "$GSDLHOME" == "" ]; then
|
---|
47 | pushd $gsdlpath > /dev/null
|
---|
48 | source setup.bash
|
---|
49 | popd > /dev/null
|
---|
50 | fi
|
---|
51 |
|
---|
52 |
|
---|
53 | ## ---- Check Perl exists ----
|
---|
54 | perlpath=
|
---|
55 |
|
---|
56 | # Some users may set the above line manually
|
---|
57 | if [ "$perlpath" == "" ]; then
|
---|
58 | # Check if Perl is on the search path
|
---|
59 | perlpath=`which perl 2> /dev/null`
|
---|
60 | fi
|
---|
61 |
|
---|
62 | # Check that a Perl executable has been found
|
---|
63 | echo "Checking Perl: $perlpath"
|
---|
64 | if [ ! -x "$perlpath" ] ; then
|
---|
65 | echo
|
---|
66 | echo "The Greenstone Librarian Interface requires perl in order to operate,"
|
---|
67 | echo "but perl could not be detected on your system. Please ensure that perl"
|
---|
68 | echo "is installed and is on your search path, then rerun this script."
|
---|
69 | exit 1
|
---|
70 | fi
|
---|
71 |
|
---|
72 |
|
---|
73 | ## ---- Check Java exists ----
|
---|
74 | javapath=
|
---|
75 |
|
---|
76 | # Some users may set the above line manually
|
---|
77 | if [ "$javapath" == "" ]; then
|
---|
78 |
|
---|
79 | # If it is set, use the JAVAHOME environment variable
|
---|
80 | if [ "$JAVAHOME" != "" ]; then
|
---|
81 | javapath="$JAVAHOME/bin/java"
|
---|
82 |
|
---|
83 | # Check if Java is on the search path
|
---|
84 | else
|
---|
85 | javapath=`which java 2> /dev/null`
|
---|
86 | fi
|
---|
87 | fi
|
---|
88 |
|
---|
89 | # Check that a Java executable has been found
|
---|
90 | echo "Checking Java: $javapath"
|
---|
91 | if [ ! -x "$javapath" ]; then
|
---|
92 | echo
|
---|
93 | echo "Failed to locate an appropriate version of Java. You must install a"
|
---|
94 | echo "Java Runtime Environment (version 1.4 or greater) before running the"
|
---|
95 | echo "Greenstone Librarian Interface."
|
---|
96 | exit 1
|
---|
97 | fi
|
---|
98 |
|
---|
99 |
|
---|
100 | ## -- Check the version of Java is new enough (1.4.0 or higher) to run the GLI --
|
---|
101 | javaversion=`$javapath -version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'`
|
---|
102 | jvmajor=`echo $javaversion | sed -n 's/^\([0-9]*\).*$/\1/p'`
|
---|
103 | jvminor=`echo $javaversion | sed -n 's/^[0-9]*\.\([0-9]*\).*$/\1/p'`
|
---|
104 |
|
---|
105 | jok=1
|
---|
106 | if [ $jvmajor -lt 1 ] ; then
|
---|
107 | jok=0
|
---|
108 | fi
|
---|
109 | if [ $jvmajor -eq 1 ] && [ $jvminor -lt 4 ] ; then
|
---|
110 | jok=0
|
---|
111 | fi
|
---|
112 | if [ $jok -eq 0 ] ; then
|
---|
113 | echo
|
---|
114 | echo "The version of the Java Runtime Environment you have installed is too"
|
---|
115 | echo "old to run the Greenstone Librarian Interface. Please install a new"
|
---|
116 | echo "version of the JRE (version 1.4 or newer) and rerun this script."
|
---|
117 | exit 1
|
---|
118 | fi
|
---|
119 |
|
---|
120 |
|
---|
121 | ## ---- Check that the GLI has been compiled ----
|
---|
122 | if [ ! -f "classes/org/greenstone/gatherer/Gatherer.class" ] && [ ! -f "GLI.jar" ]; then
|
---|
123 | echo
|
---|
124 | echo "You need to compile the Greenstone Librarian Interface (using makegli.sh)"
|
---|
125 | echo "before running this script."
|
---|
126 | exit 1
|
---|
127 | fi
|
---|
128 |
|
---|
129 | if [ "$1" == "-test" ]; then
|
---|
130 | echo "Testing class: $2"
|
---|
131 | echo "arguments $*"
|
---|
132 | java -classpath classes/:GLI.jar:lib/apache.jar:lib/calpa.jar:lib/jp.jar:lib/polloxml.jar:lib/qfslib.jar:lib/skinlf.jar $2 $3
|
---|
133 | exit 1
|
---|
134 | fi
|
---|
135 |
|
---|
136 | ## ---- Finally, run the GLI ----
|
---|
137 | echo
|
---|
138 | echo "Running the Greenstone Librarian Interface..."
|
---|
139 |
|
---|
140 | # Other arguments you can provide to GLI to work around memory limitations, or debug
|
---|
141 | # -Xms<number>M To set minimum memory (by default 32MB)
|
---|
142 | # -Xmx<number>M To set maximum memory (by default the nearest 2^n to the total remaining physical memory)
|
---|
143 | # -verbose:gc To set garbage collection messages
|
---|
144 | # -Xincgc For incremental garbage collection (significantly slows performance)
|
---|
145 | # -Xprof Function call profiling
|
---|
146 | # -Xloggc:<file> Write garbage collection log
|
---|
147 |
|
---|
148 | java -classpath classes/:GLI.jar:lib/apache.jar:lib/calpa.jar:lib/jp.jar:lib/polloxml.jar:lib/qfslib.jar:lib/skinlf.jar org.greenstone.gatherer.Gatherer -gsdl $GSDLHOME $*
|
---|
149 |
|
---|
150 | echo "Done!"
|
---|