source: gsdl/trunk/gs2-server.sh@ 20896

Last change on this file since 20896 was 20896, checked in by ak19, 14 years ago

When the GSI is about to run, messages are displayed to tell the user where the Greenstone server log and the apache error log files are.

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