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
Line 
1#!/bin/bash
2
3if [ -z "$serverlang" ]; then
4 serverlang=en
5fi
6
7java_min_version=1.5.0_00
8PROGNAME="gs2-server"
9PROGFULLNAME="Greenstone-Server"
10if [ -z "$PROGABBR" ]; then
11 PROGABBR="GSI"
12fi
13
14function autoset_gsdl_home() {
15
16 # remove leading ./ if present
17 prog="${0#./}"
18
19 isrelative="${prog%%/*}"
20
21 if [ ! -z "$isrelative" ] ; then
22 # some text is left after stripping
23 # => is relative
24 prog="$PWD/$prog"
25 fi
26
27 fulldir="${prog%/*}"
28
29 # remove trailing /. if present
30 eval "$1=\"${fulldir%/.}\""
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
61 pushd "$gsdl2path" > /dev/null
62 source ./setup.bash
63 popd > /dev/null
64fi
65
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
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
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
93 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
94 else
95 echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
96 fi
97fi
98
99## ---- Determine JAVA_HOME ----
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.
102silent=
103
104# JRE_HOME or JAVA_HOME must be set correctly to run this program
105search4j -m $java_min_version &> /dev/null
106# for some reason, Mac requires an echo after the above
107echo
108if [ "$?" == "0" ]; then
109 # In Java code, '...getResourceAsStream("build.properties")'
110 # needs up to be in the right directory when run
111 pushd "$gsdl2path" > /dev/null
112
113
114 #CLASSPATH
115 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
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"
122
123 else
124 echo " - CLASSPATH already correct"
125 fi
126
127 ## ---- Check Java ----
128 # call the script with source, so that we have the variables it sets ($javapath)
129 exit_status=0
130 source ./findjava.sh "$serverlang" "$PROGNAME"
131 exit_status=$?
132 if [ "$exit_status" -eq 1 ]; then
133 exit 1;
134 fi
135 export PATH=$javahome/bin:$PATH
136
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
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
163 custom_vm_args="-Xdock:name=$PROGFULLNAME"
164 fi
165
166
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
169
170 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
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.
174 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
175 fi
176
177 popd > /dev/null
178fi
179
Note: See TracBrowser for help on using the repository browser.