[18852] | 1 | #!/bin/bash
|
---|
[23620] | 2 |
|
---|
[20896] | 3 | if [ -z "$serverlang" ]; then
|
---|
| 4 | serverlang=en
|
---|
| 5 | fi
|
---|
[18682] | 6 |
|
---|
[20635] | 7 | java_min_version=1.5.0_00
|
---|
[19770] | 8 | PROGNAME="gs2-server"
|
---|
[23603] | 9 | PROGFULLNAME="Greenstone-Server"
|
---|
[20819] | 10 | if [ -z "$PROGABBR" ]; then
|
---|
| 11 | PROGABBR="GSI"
|
---|
| 12 | fi
|
---|
[18682] | 13 |
|
---|
| 14 | function autoset_gsdl_home() {
|
---|
| 15 |
|
---|
| 16 | # remove leading ./ if present
|
---|
[19158] | 17 | prog="${0#./}"
|
---|
[18682] | 18 |
|
---|
[19158] | 19 | isrelative="${prog%%/*}"
|
---|
[18682] | 20 |
|
---|
[19158] | 21 | if [ ! -z "$isrelative" ] ; then
|
---|
[18682] | 22 | # some text is left after stripping
|
---|
| 23 | # => is relative
|
---|
[19158] | 24 | prog="$PWD/$prog"
|
---|
[18682] | 25 | fi
|
---|
| 26 |
|
---|
[19158] | 27 | fulldir="${prog%/*}"
|
---|
[18682] | 28 |
|
---|
| 29 | # remove trailing /. if present
|
---|
[19158] | 30 | eval "$1=\"${fulldir%/.}\""
|
---|
[18682] | 31 | }
|
---|
| 32 |
|
---|
| 33 | function isinpath() {
|
---|
| 34 | for file in `echo $1 | sed 's/:/ /g'`; do
|
---|
| 35 | if [ "$file" == "$2" ]; then
|
---|
| 36 | echo true
|
---|
| 37 | return
|
---|
| 38 | fi
|
---|
| 39 | done
|
---|
| 40 | echo false
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | echo "Greenstone 2 Server"
|
---|
| 45 | echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
|
---|
| 46 | echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
| 47 | echo "This is free software, and you are welcome to redistribute it"
|
---|
| 48 |
|
---|
| 49 | ## -------- Run the Greenstone 2 Server --------
|
---|
| 50 |
|
---|
| 51 | ## ---- Determine GSDLHOME ----
|
---|
| 52 | gsdl2path=
|
---|
| 53 |
|
---|
| 54 | # Some users may set the above line manually
|
---|
| 55 | if [ -z "$gsdl2path" ]; then
|
---|
| 56 | autoset_gsdl_home gsdl2path
|
---|
| 57 | fi
|
---|
| 58 |
|
---|
| 59 | # Setup Greenstone2, unless it has already been done
|
---|
| 60 | if [ -z "$GSDLHOME" ]; then
|
---|
[19158] | 61 | pushd "$gsdl2path" > /dev/null
|
---|
[19739] | 62 | source ./setup.bash
|
---|
[18682] | 63 | popd > /dev/null
|
---|
| 64 | fi
|
---|
| 65 |
|
---|
[23646] | 66 | # On MAC, need to tell apache to find and use its own libiconv(?).dylib
|
---|
| 67 | if test -e apache-httpd ; then
|
---|
| 68 | if test "$GSDLOS" = "darwin" ; then
|
---|
| 69 | echo "+Adding in executable path for apache-httpd"
|
---|
| 70 | PATH=$GSDLHOME/apache-httpd/$GSDLOS/bin:$PATH
|
---|
| 71 | export PATH
|
---|
| 72 | DYLD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$DYLD_LIBRARY_PATH"
|
---|
| 73 | export DYLD_LIBRARY_PATH
|
---|
| 74 | fi
|
---|
| 75 | fi
|
---|
[19040] | 76 |
|
---|
| 77 | # First test that there is actually something that can be run...
|
---|
| 78 | # Exit if the apache-httpd folder doesn't exist for some reason
|
---|
| 79 | # (The errors reported when the apache webserver does not exist
|
---|
| 80 | # in the correct location are not at all helpful).
|
---|
| 81 | if [ ! -d "$GSDLHOME/apache-httpd" ]; then
|
---|
| 82 | echo ""
|
---|
| 83 | echo "UNABLE TO CONTINUE: There is no apache-httpd directory."
|
---|
| 84 | echo "It does not look like the local apache webserver has been installed."
|
---|
| 85 | echo "Exiting..."
|
---|
| 86 | echo ""
|
---|
| 87 | exit 1
|
---|
| 88 | fi
|
---|
| 89 |
|
---|
[19023] | 90 | # If there's no llssite.cfg file, copy from the template
|
---|
| 91 | if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
|
---|
| 92 | if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
|
---|
[19158] | 93 | cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
|
---|
[19023] | 94 | else
|
---|
[19158] | 95 | echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
|
---|
[19023] | 96 | fi
|
---|
[19158] | 97 | fi
|
---|
[18682] | 98 |
|
---|
[20392] | 99 | ## ---- Determine JAVA_HOME ----
|
---|
[19445] | 100 | # Set this to true if you want the Greenstone server interface to run in the background
|
---|
| 101 | # and not print any error messages to the x-term.
|
---|
[19450] | 102 | silent=
|
---|
[19445] | 103 |
|
---|
[18682] | 104 | # JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
| 105 | search4j -m $java_min_version &> /dev/null
|
---|
[19739] | 106 | # for some reason, Mac requires an echo after the above
|
---|
| 107 | echo
|
---|
[18682] | 108 | if [ "$?" == "0" ]; then
|
---|
| 109 | # In Java code, '...getResourceAsStream("build.properties")'
|
---|
| 110 | # needs up to be in the right directory when run
|
---|
[19158] | 111 | pushd "$gsdl2path" > /dev/null
|
---|
[18682] | 112 |
|
---|
| 113 |
|
---|
| 114 | #CLASSPATH
|
---|
| 115 | if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
|
---|
[19158] | 116 | CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
|
---|
| 117 | for JARFILE in lib/java/*.jar; do
|
---|
| 118 | CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
|
---|
| 119 | done
|
---|
| 120 | export CLASSPATH
|
---|
| 121 | echo " - Adjusted CLASSPATH"
|
---|
[20657] | 122 |
|
---|
| 123 | else
|
---|
| 124 | echo " - CLASSPATH already correct"
|
---|
[18682] | 125 | fi
|
---|
| 126 |
|
---|
[19738] | 127 | ## ---- Check Java ----
|
---|
| 128 | # call the script with source, so that we have the variables it sets ($javapath)
|
---|
| 129 | exit_status=0
|
---|
[19770] | 130 | source ./findjava.sh "$serverlang" "$PROGNAME"
|
---|
[19738] | 131 | exit_status=$?
|
---|
| 132 | if [ "$exit_status" -eq 1 ]; then
|
---|
| 133 | exit 1;
|
---|
| 134 | fi
|
---|
[20650] | 135 | export PATH=$javahome/bin:$PATH
|
---|
[19738] | 136 |
|
---|
[20896] | 137 | # some informative messages to direct the users to the logs
|
---|
| 138 | if [ "$serverlang" == "en" -o "x$serverlang" == "x" ]; then
|
---|
| 139 | echo "***************************************************************"
|
---|
| 140 | echo "Starting the Greenstone Server Interface (GSI)..."
|
---|
| 141 | echo
|
---|
| 142 | echo "Server log messages go to:"
|
---|
| 143 | echo " $GSDLHOME/etc/logs-gsi/server.log"
|
---|
| 144 | echo
|
---|
| 145 | echo "Using Apache web server located at:"
|
---|
| 146 | echo " $GSDLHOME/apache-httpd/$GSDLOS/bin/httpd"
|
---|
| 147 | echo "The Apache error log is at:"
|
---|
| 148 | echo " $GSDLHOME/apache-httpd/$GSDLOS/logs/error_log"
|
---|
| 149 | echo "The Apache configuration file template is at:"
|
---|
| 150 | echo " $GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf.in"
|
---|
| 151 | echo "This is used to generate:"
|
---|
| 152 | echo " $GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf"
|
---|
| 153 | echo " each time Enter Library is pressed or otherwise activated."
|
---|
| 154 | echo "***************************************************************"
|
---|
| 155 | echo
|
---|
| 156 | echo
|
---|
| 157 | fi
|
---|
| 158 |
|
---|
[23590] | 159 | # -Xdock:name To set the name of the app in the MacOS Dock bar
|
---|
| 160 | # -Xdock:icon Path to the MacOS Doc icon (not necessary for GS)
|
---|
| 161 | custom_vm_args=""
|
---|
| 162 | if [ "$GSDLOS" = "darwin" ]; then
|
---|
[23603] | 163 | custom_vm_args="-Xdock:name=$PROGFULLNAME"
|
---|
[23590] | 164 | fi
|
---|
| 165 |
|
---|
| 166 |
|
---|
[19445] | 167 | if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
|
---|
| 168 | # verbose mode, show all output, but then we can't run the server interface in the background
|
---|
[20650] | 169 |
|
---|
[23590] | 170 | "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
|
---|
[19445] | 171 | else
|
---|
| 172 | # If we launch the Greenstone Server Interface application in the background (with & at end)
|
---|
| 173 | # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
|
---|
[23590] | 174 | "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
|
---|
[19445] | 175 | fi
|
---|
[18682] | 176 |
|
---|
| 177 | popd > /dev/null
|
---|
| 178 | fi
|
---|
| 179 |
|
---|