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

Last change on this file since 24874 was 24874, checked in by ak19, 12 years ago

Third set of commits to do with the migration of cgi-bin into common-src, so that upon make install, common-src\cgi-bin will be installed in cgi-bin\GSDLOS(GSDLARCH). The first commit was of changes to files in cgi-bin itself. The second commit was moving cgi-bin. This one involves changes to all the files referring to cgi-bin where this needs to be changed to cgi-bin\OS_and_ARCH.

  • Property svn:executable set to *
File size: 5.3 KB
RevLine 
[18852]1#!/bin/bash
[23620]2
[20896]3if [ -z "$serverlang" ]; then
4 serverlang=en
5fi
[18682]6
[20635]7java_min_version=1.5.0_00
[19770]8PROGNAME="gs2-server"
[23603]9PROGFULLNAME="Greenstone-Server"
[20819]10if [ -z "$PROGABBR" ]; then
11 PROGABBR="GSI"
12fi
[18682]13
14function autoset_gsdl_home() {
15
16 # remove leading ./ if present
[19158]17 prog="${0#./}"
[18682]18
[19158]19 isrelative="${prog%%/*}"
[18682]20
[19158]21 if [ ! -z "$isrelative" ] ; then
[18682]22 # some text is left after stripping
23 # => is relative
[19158]24 prog="$PWD/$prog"
[18682]25 fi
26
[19158]27 fulldir="${prog%/*}"
[18682]28
29 # remove trailing /. if present
[19158]30 eval "$1=\"${fulldir%/.}\""
[18682]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
[19158]61 pushd "$gsdl2path" > /dev/null
[19739]62 source ./setup.bash
[18682]63 popd > /dev/null
64fi
65
[19040]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
[19023]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
[19158]82 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
[19023]83 else
[19158]84 echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
[19023]85 fi
[19158]86fi
[18682]87
[20392]88## ---- Determine JAVA_HOME ----
[19445]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.
[19450]91silent=
[19445]92
[18682]93# JRE_HOME or JAVA_HOME must be set correctly to run this program
94search4j -m $java_min_version &> /dev/null
[19739]95# for some reason, Mac requires an echo after the above
96echo
[18682]97if [ "$?" == "0" ]; then
98 # In Java code, '...getResourceAsStream("build.properties")'
99 # needs up to be in the right directory when run
[19158]100 pushd "$gsdl2path" > /dev/null
[18682]101
102
103 #CLASSPATH
104 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
[19158]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"
[20657]111
112 else
113 echo " - CLASSPATH already correct"
[18682]114 fi
115
[19738]116 ## ---- Check Java ----
117 # call the script with source, so that we have the variables it sets ($javapath)
118 exit_status=0
[19770]119 source ./findjava.sh "$serverlang" "$PROGNAME"
[19738]120 exit_status=$?
121 if [ "$exit_status" -eq 1 ]; then
122 exit 1;
123 fi
[20650]124 export PATH=$javahome/bin:$PATH
[19738]125
[20896]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
[23590]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
[23603]152 custom_vm_args="-Xdock:name=$PROGFULLNAME"
[23590]153 fi
154
[23988]155 # whenever the server is started up, make sure gsdlhome is correct (in case the gs install was moved).
156 # If both stderr and stdout need to be redirected into the void (with &>/dev/null), see
[23983]157 # http://linuxwave.blogspot.com/2008/03/redirecting-stdout-and-stderr.html
[23988]158 ./gsicontrol.sh reset-gsdlhome >/dev/null
[23590]159
[19445]160 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
161 # verbose mode, show all output, but then we can't run the server interface in the background
[20650]162
[24874]163 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$GSDLOS$GSDLARCH" "$serverlang" $*
[19445]164 else
165 # If we launch the Greenstone Server Interface application in the background (with & at end)
166 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
[24874]167 "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$GSDLOS$GSDLARCH" "$serverlang" $* > /dev/null &
[19445]168 fi
[18682]169
170 popd > /dev/null
171fi
172
Note: See TracBrowser for help on using the repository browser.