source: main/trunk/greenstone2/gs2-server.sh@ 23620

Last change on this file since 23620 was 23620, checked in by ak19, 13 years ago

Implemented Dr Bainbridge and Sam's solution to the libiconv/wvware/gnome/apache problem: apache's lib folder (containing its own libiconv) is no longer set in the DYLD_LIBRARY_PATH exported from GS2's setup.bash, but is now set specifically for the web-server in gs2-server.sh

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