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

Last change on this file since 19268 was 19158, checked in by oranfry, 15 years ago

space-proofed this script

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