[18852] | 1 | #!/bin/bash
|
---|
[18682] | 2 | serverlang=en
|
---|
| 3 |
|
---|
| 4 | java_min_version=1.4.0_00
|
---|
| 5 |
|
---|
| 6 | function autoset_gsdl_home() {
|
---|
| 7 |
|
---|
| 8 | # remove leading ./ if present
|
---|
[19158] | 9 | prog="${0#./}"
|
---|
[18682] | 10 |
|
---|
[19158] | 11 | isrelative="${prog%%/*}"
|
---|
[18682] | 12 |
|
---|
[19158] | 13 | if [ ! -z "$isrelative" ] ; then
|
---|
[18682] | 14 | # some text is left after stripping
|
---|
| 15 | # => is relative
|
---|
[19158] | 16 | prog="$PWD/$prog"
|
---|
[18682] | 17 | fi
|
---|
| 18 |
|
---|
[19158] | 19 | fulldir="${prog%/*}"
|
---|
[18682] | 20 |
|
---|
| 21 | # remove trailing /. if present
|
---|
[19158] | 22 | eval "$1=\"${fulldir%/.}\""
|
---|
[18682] | 23 | }
|
---|
| 24 |
|
---|
| 25 | function isinpath() {
|
---|
| 26 | for file in `echo $1 | sed 's/:/ /g'`; do
|
---|
| 27 | if [ "$file" == "$2" ]; then
|
---|
| 28 | echo true
|
---|
| 29 | return
|
---|
| 30 | fi
|
---|
| 31 | done
|
---|
| 32 | echo false
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | echo "Greenstone 2 Server"
|
---|
| 37 | echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
|
---|
| 38 | echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
| 39 | echo "This is free software, and you are welcome to redistribute it"
|
---|
| 40 |
|
---|
| 41 | ## -------- Run the Greenstone 2 Server --------
|
---|
| 42 |
|
---|
| 43 | ## ---- Determine GSDLHOME ----
|
---|
| 44 | gsdl2path=
|
---|
| 45 |
|
---|
| 46 | # Some users may set the above line manually
|
---|
| 47 | if [ -z "$gsdl2path" ]; then
|
---|
| 48 | autoset_gsdl_home gsdl2path
|
---|
| 49 | fi
|
---|
| 50 |
|
---|
| 51 | # Setup Greenstone2, unless it has already been done
|
---|
| 52 | if [ -z "$GSDLHOME" ]; then
|
---|
[19158] | 53 | pushd "$gsdl2path" > /dev/null
|
---|
[18682] | 54 | source setup.bash
|
---|
| 55 | popd > /dev/null
|
---|
| 56 | fi
|
---|
| 57 |
|
---|
[19040] | 58 |
|
---|
| 59 | # First test that there is actually something that can be run...
|
---|
| 60 | # Exit if the apache-httpd folder doesn't exist for some reason
|
---|
| 61 | # (The errors reported when the apache webserver does not exist
|
---|
| 62 | # in the correct location are not at all helpful).
|
---|
| 63 | if [ ! -d "$GSDLHOME/apache-httpd" ]; then
|
---|
| 64 | echo ""
|
---|
| 65 | echo "UNABLE TO CONTINUE: There is no apache-httpd directory."
|
---|
| 66 | echo "It does not look like the local apache webserver has been installed."
|
---|
| 67 | echo "Exiting..."
|
---|
| 68 | echo ""
|
---|
| 69 | exit 1
|
---|
| 70 | fi
|
---|
| 71 |
|
---|
[19023] | 72 | # If there's no llssite.cfg file, copy from the template
|
---|
| 73 | if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
|
---|
| 74 | if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
|
---|
[19158] | 75 | cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
|
---|
[19023] | 76 | else
|
---|
[19158] | 77 | echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
|
---|
[19023] | 78 | fi
|
---|
[19158] | 79 | fi
|
---|
[18682] | 80 |
|
---|
[19445] | 81 | ## ---- Determine GSDLHOME ----
|
---|
| 82 | # Set this to true if you want the Greenstone server interface to run in the background
|
---|
| 83 | # and not print any error messages to the x-term.
|
---|
[19450] | 84 | silent=
|
---|
[19445] | 85 |
|
---|
[18682] | 86 | # JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
| 87 | search4j -m $java_min_version &> /dev/null
|
---|
| 88 | if [ "$?" == "0" ]; then
|
---|
| 89 | # In Java code, '...getResourceAsStream("build.properties")'
|
---|
| 90 | # needs up to be in the right directory when run
|
---|
[19158] | 91 | pushd "$gsdl2path" > /dev/null
|
---|
[18682] | 92 |
|
---|
| 93 |
|
---|
| 94 | #CLASSPATH
|
---|
| 95 | if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
|
---|
[19158] | 96 | CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
|
---|
| 97 | for JARFILE in lib/java/*.jar; do
|
---|
| 98 | CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
|
---|
| 99 | done
|
---|
| 100 | export CLASSPATH
|
---|
| 101 | echo " - Adjusted CLASSPATH"
|
---|
[18682] | 102 |
|
---|
| 103 | else
|
---|
[19158] | 104 | echo " - CLASSPATH already correct"
|
---|
[18682] | 105 | fi
|
---|
| 106 |
|
---|
[19158] | 107 | javapath="`search4j -m $java_min_version -e`"
|
---|
[19445] | 108 | if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
|
---|
| 109 | # verbose mode, show all output, but then we can't run the server interface in the background
|
---|
| 110 | "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
|
---|
| 111 | else
|
---|
| 112 | # If we launch the Greenstone Server Interface application in the background (with & at end)
|
---|
| 113 | # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
|
---|
| 114 | "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
|
---|
| 115 | fi
|
---|
[18682] | 116 |
|
---|
| 117 | popd > /dev/null
|
---|
| 118 | fi
|
---|
| 119 |
|
---|