source: gsdl/branches/winmak/gs2-server.sh@ 20973

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

Turn off silent mode for launching the GSI (so that the app does not run in the background but does display output messages).

  • Property svn:executable set to *
File size: 3.4 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
88if [ "$?" == "0" ]; then
89 # In Java code, '...getResourceAsStream("build.properties")'
90 # needs up to be in the right directory when run
91 pushd "$gsdl2path" > /dev/null
92
93
94 #CLASSPATH
95 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
96 CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
97 for JARFILE in lib/java/*.jar; do
98 CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
99 done
100 export CLASSPATH
101 echo " - Adjusted CLASSPATH"
102
103 else
104 echo " - CLASSPATH already correct"
105 fi
106
107 javapath="`search4j -m $java_min_version -e`"
108 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
109 # verbose mode, show all output, but then we can't run the server interface in the background
110 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
111 else
112 # If we launch the Greenstone Server Interface application in the background (with & at end)
113 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
114 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
115 fi
116
117 popd > /dev/null
118fi
119
Note: See TracBrowser for help on using the repository browser.