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

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

Minor change to get the server to run on Mac again. And sourcing setup.bash with the required dot in front.

  • Property svn:executable set to *
File size: 3.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 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## ---- Determine GSDLHOME ----
82# Set this to true if you want the Greenstone server interface to run in the background
83# and not print any error messages to the x-term.
84silent=
85
86# JRE_HOME or JAVA_HOME must be set correctly to run this program
87search4j -m $java_min_version &> /dev/null
88# for some reason, Mac requires an echo after the above
89echo
90if [ "$?" == "0" ]; then
91 # In Java code, '...getResourceAsStream("build.properties")'
92 # needs up to be in the right directory when run
93 pushd "$gsdl2path" > /dev/null
94
95
96 #CLASSPATH
97 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
98 CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
99 for JARFILE in lib/java/*.jar; do
100 CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
101 done
102 export CLASSPATH
103 echo " - Adjusted CLASSPATH"
104
105 else
106 echo " - CLASSPATH already correct"
107 fi
108
109 ## ---- Check Java ----
110 # call the script with source, so that we have the variables it sets ($javapath)
111 exit_status=0
112 source ./findjava.sh $serverlang
113 exit_status=$?
114 if [ "$exit_status" -eq 1 ]; then
115 exit 1;
116 fi
117
118 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
119 # verbose mode, show all output, but then we can't run the server interface in the background
120 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
121 else
122 # If we launch the Greenstone Server Interface application in the background (with & at end)
123 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
124 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
125 fi
126
127 popd > /dev/null
128fi
129
Note: See TracBrowser for help on using the repository browser.