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