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

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

Minor edit to when PROGABBR is set

  • Property svn:executable set to *
File size: 3.7 KB
RevLine 
[18852]1#!/bin/bash
[18682]2serverlang=en
3
[20635]4java_min_version=1.5.0_00
[19770]5PROGNAME="gs2-server"
[20819]6if [ -z "$PROGABBR" ]; then
7 PROGABBR="GSI"
8fi
[18682]9
10function autoset_gsdl_home() {
11
12 # remove leading ./ if present
[19158]13 prog="${0#./}"
[18682]14
[19158]15 isrelative="${prog%%/*}"
[18682]16
[19158]17 if [ ! -z "$isrelative" ] ; then
[18682]18 # some text is left after stripping
19 # => is relative
[19158]20 prog="$PWD/$prog"
[18682]21 fi
22
[19158]23 fulldir="${prog%/*}"
[18682]24
25 # remove trailing /. if present
[19158]26 eval "$1=\"${fulldir%/.}\""
[18682]27}
28
29function isinpath() {
30 for file in `echo $1 | sed 's/:/ /g'`; do
31 if [ "$file" == "$2" ]; then
32 echo true
33 return
34 fi
35 done
36 echo false
37}
38
39
40echo "Greenstone 2 Server"
41echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
42echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
43echo "This is free software, and you are welcome to redistribute it"
44
45## -------- Run the Greenstone 2 Server --------
46
47## ---- Determine GSDLHOME ----
48gsdl2path=
49
50# Some users may set the above line manually
51if [ -z "$gsdl2path" ]; then
52 autoset_gsdl_home gsdl2path
53fi
54
55# Setup Greenstone2, unless it has already been done
56if [ -z "$GSDLHOME" ]; then
[19158]57 pushd "$gsdl2path" > /dev/null
[19739]58 source ./setup.bash
[18682]59 popd > /dev/null
60fi
61
[19040]62
63# First test that there is actually something that can be run...
64# Exit if the apache-httpd folder doesn't exist for some reason
65# (The errors reported when the apache webserver does not exist
66# in the correct location are not at all helpful).
67if [ ! -d "$GSDLHOME/apache-httpd" ]; then
68 echo ""
69 echo "UNABLE TO CONTINUE: There is no apache-httpd directory."
70 echo "It does not look like the local apache webserver has been installed."
71 echo "Exiting..."
72 echo ""
73 exit 1
74fi
75
[19023]76# If there's no llssite.cfg file, copy from the template
77if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
78 if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
[19158]79 cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
[19023]80 else
[19158]81 echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
[19023]82 fi
[19158]83fi
[18682]84
[20392]85## ---- Determine JAVA_HOME ----
[19445]86# Set this to true if you want the Greenstone server interface to run in the background
87# and not print any error messages to the x-term.
[19450]88silent=
[19445]89
[18682]90# JRE_HOME or JAVA_HOME must be set correctly to run this program
91search4j -m $java_min_version &> /dev/null
[19739]92# for some reason, Mac requires an echo after the above
93echo
[18682]94if [ "$?" == "0" ]; then
95 # In Java code, '...getResourceAsStream("build.properties")'
96 # needs up to be in the right directory when run
[19158]97 pushd "$gsdl2path" > /dev/null
[18682]98
99
100 #CLASSPATH
101 if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
[19158]102 CLASSPATH="$GSDLHOME/lib/java:$CLASSPATH"
103 for JARFILE in lib/java/*.jar; do
104 CLASSPATH="$CLASSPATH:$GSDLHOME/$JARFILE"
105 done
106 export CLASSPATH
107 echo " - Adjusted CLASSPATH"
[20657]108
109 else
110 echo " - CLASSPATH already correct"
[18682]111 fi
112
[19738]113 ## ---- Check Java ----
114 # call the script with source, so that we have the variables it sets ($javapath)
115 exit_status=0
[19770]116 source ./findjava.sh "$serverlang" "$PROGNAME"
[19738]117 exit_status=$?
118 if [ "$exit_status" -eq 1 ]; then
119 exit 1;
120 fi
[20650]121 export PATH=$javahome/bin:$PATH
[19738]122
[19445]123 if [ "x$silent" == "x" -o "x$silent" != "xtrue" ]; then
124 # verbose mode, show all output, but then we can't run the server interface in the background
[20650]125
[19445]126 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $*
127 else
128 # If we launch the Greenstone Server Interface application in the background (with & at end)
129 # need to redirect any STDERR (STDOUT) output to /dev/null first, else output will hog the x-term.
130 "$javapath" org.greenstone.server.Server2 "$GSDLHOME" "$serverlang" $* > /dev/null &
131 fi
[18682]132
133 popd > /dev/null
134fi
135
Note: See TracBrowser for help on using the repository browser.