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

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

Adjusting the commits made for revision 23620 so that Linux is not affected. The changes which were committed to gs2-server.sh and setup.bash for Mac, so that only gs2-server would set its DYLD_LIBRARY_PATH to the libiconv.lib generated in the apache folder, broke the web-start on Linux. That change should only be done for Mac.

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