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

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

Fixing oversight: The recent changes need to be moved after the section sourcing setup.bash.

  • Property svn:executable set to *
File size: 5.4 KB
RevLine 
[18852]1#!/bin/bash
[23620]2
[20896]3if [ -z "$serverlang" ]; then
4 serverlang=en
5fi
[18682]6
[20635]7java_min_version=1.5.0_00
[19770]8PROGNAME="gs2-server"
[23603]9PROGFULLNAME="Greenstone-Server"
[20819]10if [ -z "$PROGABBR" ]; then
11 PROGABBR="GSI"
12fi
[18682]13
14function 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
33function 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
44echo "Greenstone 2 Server"
45echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
46echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
47echo "This is free software, and you are welcome to redistribute it"
48
49## -------- Run the Greenstone 2 Server --------
50
51## ---- Determine GSDLHOME ----
52gsdl2path=
53
54# Some users may set the above line manually
55if [ -z "$gsdl2path" ]; then
56 autoset_gsdl_home gsdl2path
57fi
58
59# Setup Greenstone2, unless it has already been done
60if [ -z "$GSDLHOME" ]; then
[19158]61 pushd "$gsdl2path" > /dev/null
[19739]62 source ./setup.bash
[18682]63 popd > /dev/null
64fi
65
[23646]66# On MAC, need to tell apache to find and use its own libiconv(?).dylib
67if 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
75fi
[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).
81if [ ! -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
88fi
89
[19023]90# If there's no llssite.cfg file, copy from the template
91if [ ! -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]97fi
[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]102silent=
[19445]103
[18682]104# JRE_HOME or JAVA_HOME must be set correctly to run this program
105search4j -m $java_min_version &> /dev/null
[19739]106# for some reason, Mac requires an echo after the above
107echo
[18682]108if [ "$?" == "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
178fi
179
Note: See TracBrowser for help on using the repository browser.