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

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

Instead of the Mac menu containing the abbreviation GSI for the Greenstone server interface, it's now set to Greenstone-Server

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