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