source: main/trunk/greenstone2/gs2-server.sh@ 23590

Last change on this file since 23590 was 23590, checked in by ak19, 13 years ago

Changed the script files that launch GS applications to contain an extra Java VM argument called Xdock:name for Darwin (MacOS) machines that will set the program abbreviation as the visible name of the top Mac menubar when the application is running in the Dock menu at the bottom.

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