source: main/branches/64_bit_Greenstone/greenstone2/gs2-server.sh@ 23594

Last change on this file since 23594 was 23594, checked in by sjm84, 13 years ago

Another set of trunk changes to commit to this branch

  • Property svn:executable set to *
File size: 4.9 KB
Line 
1#!/bin/bash
2if [ -z "$serverlang" ]; then
3 serverlang=en
4fi
5
6java_min_version=1.5.0_00
7PROGNAME="gs2-server"
8if [ -z "$PROGABBR" ]; then
9 PROGABBR="GSI"
10fi
11
12function autoset_gsdl_home() {
13
14 # remove leading ./ if present
15 prog="${0#./}"
16
17 isrelative="${prog%%/*}"
18
19 if [ ! -z "$isrelative" ] ; then
20 # some text is left after stripping
21 # => is relative
22 prog="$PWD/$prog"
23 fi
24
25 fulldir="${prog%/*}"
26
27 # remove trailing /. if present
28 eval "$1=\"${fulldir%/.}\""
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
59 pushd "$gsdl2path" > /dev/null
60 source ./setup.bash
61 popd > /dev/null
62fi
63
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
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
81 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
82 else
83 echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
84 fi
85fi
86
87## ---- Determine JAVA_HOME ----
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.
90silent=
91
92# JRE_HOME or JAVA_HOME must be set correctly to run this program
93search4j -m $java_min_version &> /dev/null
94# for some reason, Mac requires an echo after the above
95echo
96if [ "$?" == "0" ]; then
97 # In Java code, '...getResourceAsStream("build.properties")'
98 # needs up to be in the right directory when run
99 pushd "$gsdl2path" > /dev/null
100
101
102 #CLASSPATH
103 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
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"
110
111 else
112 echo " - CLASSPATH already correct"
113 fi
114
115 ## ---- Check Java ----
116 # call the script with source, so that we have the variables it sets ($javapath)
117 exit_status=0
118 source ./findjava.sh "$serverlang" "$PROGNAME"
119 exit_status=$?
120 if [ "$exit_status" -eq 1 ]; then
121 exit 1;
122 fi
123 export PATH=$javahome/bin:$PATH
124
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
147 # -Xdock:name To set the name of the app in the MacOS Dock bar
148 # -Xdock:icon Path to the MacOS Doc icon (not necessary for GS)
149 custom_vm_args=""
150 if [ "$GSDLOS" = "darwin" ]; then
151 custom_vm_args="-Xdock:name=$PROGABBR"
152 fi
153
154
155 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
156 # verbose mode, show all output, but then we can't run the server interface in the background
157
158 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
159 else
160 # If we launch the Greenstone Server Interface application in the background (with & at end)
161 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
162 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
163 fi
164
165 popd > /dev/null
166fi
167
Note: See TracBrowser for help on using the repository browser.