source: gsdl/trunk/gs2-server.sh@ 19122

Last change on this file since 19122 was 19040, checked in by ak19, 15 years ago

Whenever I'm testing the binary distribution installation of apache-httpd, I move the regular version out of the way. However once the tests are finished, I forget to move the regular installation of GS2's apache-httpd back and this catches me out everytime, because trying to start the webserver does not tell me that the webserver files are entirely missing or relocated. Therefore, when gs2-server.sh is launched, it now checks that the GSDLHOME/apache-httpd folder actually exists before trying to issue commands to this.

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/bash
2serverlang=en
3
4java_min_version=1.4.0_00
5
6function autoset_gsdl_home() {
7
8 # remove leading ./ if present
9 prog=${0#./}
10
11 isrelative=${prog%%/*}
12
13 if [ ! -z $isrelative ] ; then
14 # some text is left after stripping
15 # => is relative
16 pwd=$PWD
17 prog="$pwd/$prog"
18 fi
19
20 fulldir=${prog%/*}
21
22 # remove trailing /. if present
23 eval $1=${fulldir%/.}
24}
25
26function isinpath() {
27 for file in `echo $1 | sed 's/:/ /g'`; do
28 if [ "$file" == "$2" ]; then
29 echo true
30 return
31 fi
32 done
33 echo false
34}
35
36
37echo "Greenstone 2 Server"
38echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
39echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
40echo "This is free software, and you are welcome to redistribute it"
41
42## -------- Run the Greenstone 2 Server --------
43
44## ---- Determine GSDLHOME ----
45gsdl2path=
46
47# Some users may set the above line manually
48if [ -z "$gsdl2path" ]; then
49 autoset_gsdl_home gsdl2path
50fi
51
52# Setup Greenstone2, unless it has already been done
53if [ -z "$GSDLHOME" ]; then
54 pushd $gsdl2path > /dev/null
55 source setup.bash
56 popd > /dev/null
57fi
58
59
60# First test that there is actually something that can be run...
61# Exit if the apache-httpd folder doesn't exist for some reason
62# (The errors reported when the apache webserver does not exist
63# in the correct location are not at all helpful).
64if [ ! -d "$GSDLHOME/apache-httpd" ]; then
65 echo ""
66 echo "UNABLE TO CONTINUE: There is no apache-httpd directory."
67 echo "It does not look like the local apache webserver has been installed."
68 echo "Exiting..."
69 echo ""
70 exit 1
71fi
72
73# If there's no llssite.cfg file, copy from the template
74if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
75 if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
76 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
77 else
78 echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
79 fi
80fi
81
82# JRE_HOME or JAVA_HOME must be set correctly to run this program
83search4j -m $java_min_version &> /dev/null
84if [ "$?" == "0" ]; then
85 # In Java code, '...getResourceAsStream("build.properties")'
86 # needs up to be in the right directory when run
87 pushd $gsdl2path > /dev/null
88
89
90 #CLASSPATH
91 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
92 CLASSPATH=$GSDLHOME/lib/java:$CLASSPATH
93 for JARFILE in $GSDLHOME/lib/java/*.jar; do
94 CLASSPATH=$CLASSPATH:$JARFILE
95 done
96 export CLASSPATH
97
98 echo " - Adjusted CLASSPATH"
99 else
100 echo " - CLASSPATH already correct"
101 fi
102
103 javapath=`search4j -m $java_min_version -e`
104 $javapath org.greenstone.server.Server2 $GSDLHOME $serverlang $*
105
106 popd > /dev/null
107fi
108
Note: See TracBrowser for help on using the repository browser.