root/main/trunk/greenstone2/gs2-server.sh @ 23620

Revision 23620, 5.4 KB (checked in by ak19, 9 years ago)

Implemented Dr Bainbridge and Sam's solution to the libiconv/wvware/gnome/apache problem: apache's lib folder (containing its own libiconv) is no longer set in the DYLD_LIBRARY_PATH exported from GS2's setup.bash, but is now set specifically for the web-server in gs2-server.sh

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3if test -e apache-httpd ; then
4  echo "+Adding in executable path for apache-httpd"
5  PATH=$GSDLHOME/apache-httpd/$GSDLOS/bin:$PATH
6  export PATH
7
8  if test "$GSDLOS" = "linux" ; then
9      LD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$LD_LIBRARY_PATH"
10      export LD_LIBRARY_PATH
11
12  elif test "$GSDLOS" = "darwin" ; then
13      DYLD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$DYLD_LIBRARY_PATH"
14      export DYLD_LIBRARY_PATH
15  fi
16fi
17
18
19if [ -z "$serverlang" ]; then
20    serverlang=en
21fi
22
23java_min_version=1.5.0_00
24PROGNAME="gs2-server"
25PROGFULLNAME="Greenstone-Server"
26if [ -z "$PROGABBR" ]; then
27   PROGABBR="GSI"
28fi
29
30function autoset_gsdl_home() {
31
32  # remove leading ./ if present
33  prog="${0#./}"
34
35  isrelative="${prog%%/*}"
36
37  if [ ! -z "$isrelative" ] ; then
38    # some text is left after stripping
39    # => is relative
40    prog="$PWD/$prog"
41  fi
42
43  fulldir="${prog%/*}"
44
45  # remove trailing /. if present
46  eval "$1=\"${fulldir%/.}\""
47}
48
49function isinpath() {
50  for file in `echo $1 | sed 's/:/ /g'`; do
51    if [ "$file" == "$2" ]; then
52      echo true
53      return
54    fi
55  done
56  echo false
57}
58
59
60echo "Greenstone 2 Server"
61echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
62echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
63echo "This is free software, and you are welcome to redistribute it"
64
65##  -------- Run the Greenstone 2 Server --------
66
67##  ---- Determine GSDLHOME ----
68gsdl2path=
69
70# Some users may set the above line manually
71if [ -z "$gsdl2path" ]; then
72   autoset_gsdl_home gsdl2path
73fi
74
75# Setup Greenstone2, unless it has already been done
76if [ -z "$GSDLHOME" ]; then
77  pushd "$gsdl2path" > /dev/null
78  source ./setup.bash
79  popd > /dev/null
80fi
81
82
83# First test that there is actually something that can be run...
84# Exit if the apache-httpd folder doesn't exist for some reason
85# (The errors reported when the apache webserver does not exist
86# in the correct location are not at all helpful).
87if [ ! -d "$GSDLHOME/apache-httpd" ]; then
88    echo ""
89    echo "UNABLE TO CONTINUE: There is no apache-httpd directory."
90    echo "It does not look like the local apache webserver has been installed."
91    echo "Exiting..."
92    echo ""
93    exit 1
94fi
95
96# If there's no llssite.cfg file, copy from the template
97if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
98    if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
99    cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
100    else
101    echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
102    fi
103fi
104
105##  ---- Determine JAVA_HOME ----
106# Set this to true if you want the Greenstone server interface to run in the background
107# and not print any error messages to the x-term.
108silent=
109
110# JRE_HOME or JAVA_HOME must be set correctly to run this program
111search4j -m $java_min_version &> /dev/null
112# for some reason, Mac requires an echo after the above
113echo
114if [ "$?" == "0" ]; then
115    # In Java code, '...getResourceAsStream("build.properties")'
116    # needs up to be in the right directory when run
117    pushd "$gsdl2path" > /dev/null
118
119
120    #CLASSPATH
121    if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
122        CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
123        for JARFILE in lib/java/*.jar; do
124            CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
125        done
126        export CLASSPATH
127        echo "  - Adjusted CLASSPATH"
128
129    else
130        echo "  - CLASSPATH already correct"
131    fi
132
133    ## ---- Check Java ----
134    # call the script with source, so that we have the variables it sets ($javapath)
135    exit_status=0
136    source ./findjava.sh "$serverlang" "$PROGNAME"
137    exit_status=$?
138    if [ "$exit_status" -eq 1 ]; then
139        exit 1;
140    fi
141    export PATH=$javahome/bin:$PATH
142
143    # some informative messages to direct the users to the logs
144    if [ "$serverlang" == "en" -o "x$serverlang" == "x" ]; then
145    echo "***************************************************************"
146    echo "Starting the Greenstone Server Interface (GSI)..."
147    echo
148    echo "Server log messages go to:"
149    echo "   $GSDLHOME/etc/logs-gsi/server.log"
150    echo
151    echo "Using Apache web server located at:"
152    echo "   $GSDLHOME/apache-httpd/$GSDLOS/bin/httpd"
153    echo "The Apache error log is at:"
154    echo "   $GSDLHOME/apache-httpd/$GSDLOS/logs/error_log"
155    echo "The Apache configuration file template is at:"
156    echo "   $GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf.in"
157    echo "This is used to generate:"
158    echo "   $GSDLHOME/apache-httpd/$GSDLOS/conf/httpd.conf"
159    echo "   each time Enter Library is pressed or otherwise activated."
160    echo "***************************************************************"
161    echo
162    echo
163    fi
164
165    # -Xdock:name      To set the name of the app in the MacOS Dock bar
166    # -Xdock:icon      Path to the MacOS Doc icon (not necessary for GS)   
167    custom_vm_args=""
168    if [ "$GSDLOS" = "darwin" ]; then
169        custom_vm_args="-Xdock:name=$PROGFULLNAME"
170    fi
171
172
173    if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
174        # verbose mode, show all output, but then we can't run the server interface in the background
175   
176    "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
177    else
178        # If we launch the Greenstone Server Interface application in the background (with & at end)
179        # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
180    "$javapath" $custom_vm_args org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
181    fi
182
183    popd > /dev/null
184fi
185
Note: See TracBrowser for help on using the browser.