[4914] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
[6262] | 3 | echo
|
---|
[6211] | 4 | echo 'Greenstone Librarian Interface (GLI)'
|
---|
[6280] | 5 | echo 'Copyright (C) 2003 The New Zealand Digital Library Project, University Of Waikato'
|
---|
[6211] | 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'
|
---|
[6223] | 8 | echo
|
---|
[4952] | 9 |
|
---|
[5003] | 10 | ## -------- Run the Greenstone Librarian Interface --------
|
---|
[4952] | 11 |
|
---|
[5003] | 12 | # This script must be run from within the directory in which it lives
|
---|
[4952] | 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
|
---|
[4914] | 17 | fi
|
---|
| 18 |
|
---|
[4952] | 19 |
|
---|
[5003] | 20 | ## ---- Determine GSDLHOME ----
|
---|
[6279] | 21 | gsdlpath=
|
---|
[4952] | 22 |
|
---|
| 23 | # Some users may set the above line manually
|
---|
[5003] | 24 | if [ "$gsdlpath" == "" ]; then
|
---|
[4952] | 25 | # Check the environment variable first
|
---|
| 26 | if [ "$GSDLHOME" != "" ]; then
|
---|
[5003] | 27 | gsdlpath=$GSDLHOME
|
---|
[4952] | 28 |
|
---|
| 29 | # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone
|
---|
| 30 | else
|
---|
| 31 | pushd .. > /dev/null
|
---|
[5003] | 32 | gsdlpath=`pwd`
|
---|
[4952] | 33 | popd > /dev/null
|
---|
| 34 | fi
|
---|
| 35 | fi
|
---|
| 36 |
|
---|
| 37 | # Check that the Greenstone installation looks OK
|
---|
[5003] | 38 | echo "Checking GSDL: $gsdlpath"
|
---|
[5091] | 39 | if [ ! -f "${gsdlpath}/setup.bash" ] ; then
|
---|
[5003] | 40 | echo
|
---|
| 41 | echo "The Greenstone installation could not be found, or is incomplete."
|
---|
| 42 | echo "Try reinstalling Greenstone then running this script again."
|
---|
[4952] | 43 | exit 1
|
---|
| 44 | fi
|
---|
| 45 |
|
---|
[5003] | 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
|
---|
[4952] | 52 |
|
---|
| 53 |
|
---|
[5003] | 54 | ## ---- Check Perl exists ----
|
---|
[4952] | 55 | perlpath=
|
---|
| 56 |
|
---|
| 57 | # Some users may set the above line manually
|
---|
| 58 | if [ "$perlpath" == "" ]; then
|
---|
[5003] | 59 | # Check if Perl is on the search path
|
---|
[4952] | 60 | perlpath=`which perl 2> /dev/null`
|
---|
| 61 | fi
|
---|
| 62 |
|
---|
[5003] | 63 | # Check that a Perl executable has been found
|
---|
| 64 | echo "Checking Perl: $perlpath"
|
---|
[4952] | 65 | if [ ! -x "$perlpath" ] ; then
|
---|
[5003] | 66 | echo
|
---|
[5459] | 67 | echo "The Greenstone Librarian Interface requires perl in order to operate,"
|
---|
[5003] | 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."
|
---|
[4952] | 70 | exit 1
|
---|
| 71 | fi
|
---|
| 72 |
|
---|
| 73 |
|
---|
[5003] | 74 | ## ---- Check Java exists ----
|
---|
[4952] | 75 | javapath=
|
---|
| 76 |
|
---|
| 77 | # Some users may set the above line manually
|
---|
| 78 | if [ "$javapath" == "" ]; then
|
---|
[5003] | 79 |
|
---|
[6467] | 80 | # If it is set, use the JAVA_HOME environment variable
|
---|
| 81 | if [ "$JAVA_HOME" != "" ]; then
|
---|
| 82 | javapath="$JAVA_HOME/bin/java"
|
---|
[4952] | 83 |
|
---|
[5003] | 84 | # Check if Java is on the search path
|
---|
[4952] | 85 | else
|
---|
| 86 | javapath=`which java 2> /dev/null`
|
---|
| 87 | fi
|
---|
| 88 | fi
|
---|
| 89 |
|
---|
[5003] | 90 | # Check that a Java executable has been found
|
---|
| 91 | echo "Checking Java: $javapath"
|
---|
[4952] | 92 | if [ ! -x "$javapath" ]; then
|
---|
[5003] | 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."
|
---|
[4952] | 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
|
---|
[5003] | 114 | echo
|
---|
[4952] | 115 | echo "The version of the Java Runtime Environment you have installed is too"
|
---|
[5003] | 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."
|
---|
[4952] | 118 | exit 1
|
---|
| 119 | fi
|
---|
| 120 |
|
---|
| 121 |
|
---|
[5003] | 122 | ## ---- Check that the GLI has been compiled ----
|
---|
[5027] | 123 | if [ ! -f "classes/org/greenstone/gatherer/Gatherer.class" ] && [ ! -f "GLI.jar" ]; then
|
---|
[5003] | 124 | echo
|
---|
| 125 | echo "You need to compile the Greenstone Librarian Interface (using makegli.sh)"
|
---|
[4952] | 126 | echo "before running this script."
|
---|
| 127 | exit 1
|
---|
| 128 | fi
|
---|
| 129 |
|
---|
[6211] | 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
|
---|
[4952] | 136 |
|
---|
[5003] | 137 | ## ---- Finally, run the GLI ----
|
---|
| 138 | echo
|
---|
[4952] | 139 | echo "Running the Greenstone Librarian Interface..."
|
---|
| 140 |
|
---|
[6211] | 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)
|
---|
[4914] | 144 | # -verbose:gc To set garbage collection messages
|
---|
[6211] | 145 | # -Xincgc For incremental garbage collection (significantly slows performance)
|
---|
[4914] | 146 | # -Xprof Function call profiling
|
---|
| 147 | # -Xloggc:<file> Write garbage collection log
|
---|
| 148 |
|
---|
[6211] | 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 $*
|
---|
[4914] | 150 |
|
---|
| 151 | echo "Done!"
|
---|