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

Last change on this file since 31853 was 30120, checked in by ak19, 6 years ago

Bringing GS2 up to speed with the previous commit for GS3: Mac icons for when launching the gs2-server startup script from the command line. This also ensures the appropriate icon for the second item in the dock panel when launching the .app file.

  • Property svn:executable set to *
File size: 5.5 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# 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 if [ -f "gs2-server.app/Contents/Resources/AutomatorApplet.icns" ]; then
154 custom_vm_args="$custom_vm_args -Xdock:icon=gs2-server.app/Contents/Resources/AutomatorApplet.icns"
155 fi
156 fi
157
158 # whenever the server is started up, make sure gsdlhome is correct (in case the gs install was moved).
159 # If both stderr and stdout need to be redirected into the void (with &>/dev/null), see
160 # http://linuxwave.blogspot.com/2008/03/redirecting-stdout-and-stderr.html
161 ./gsicontrol.sh reset-gsdlhome >/dev/null
162
163 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
164 # verbose mode, show all output, but then we can't run the server interface in the background
165
166 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$GSDLOS$GSDLARCH" "$serverlang" $*
167 else
168 # If we launch the Greenstone Server Interface application in the background (with & at end)
169 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
170 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$GSDLOS$GSDLARCH" "$serverlang" $* > /dev/null &
171 fi
172
173 popd > /dev/null
174fi
175
Note: See TracBrowser for help on using the repository browser.