1 | #!/bin/bash
|
---|
2 | serverlang=en
|
---|
3 |
|
---|
4 | java_min_version=1.5.0_00
|
---|
5 | PROGNAME="gs2-server"
|
---|
6 | if [ -z "$PROGABBR" ]; then
|
---|
7 | PROGABBR="GSI"
|
---|
8 | fi
|
---|
9 |
|
---|
10 | function autoset_gsdl_home() {
|
---|
11 |
|
---|
12 | # remove leading ./ if present
|
---|
13 | prog="${0#./}"
|
---|
14 |
|
---|
15 | isrelative="${prog%%/*}"
|
---|
16 |
|
---|
17 | if [ ! -z "$isrelative" ] ; then
|
---|
18 | # some text is left after stripping
|
---|
19 | # => is relative
|
---|
20 | prog="$PWD/$prog"
|
---|
21 | fi
|
---|
22 |
|
---|
23 | fulldir="${prog%/*}"
|
---|
24 |
|
---|
25 | # remove trailing /. if present
|
---|
26 | eval "$1=\"${fulldir%/.}\""
|
---|
27 | }
|
---|
28 |
|
---|
29 | function 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 |
|
---|
40 | echo "Greenstone 2 Server"
|
---|
41 | echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
|
---|
42 | echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
43 | echo "This is free software, and you are welcome to redistribute it"
|
---|
44 |
|
---|
45 | ## -------- Run the Greenstone 2 Server --------
|
---|
46 |
|
---|
47 | ## ---- Determine GSDLHOME ----
|
---|
48 | gsdl2path=
|
---|
49 |
|
---|
50 | # Some users may set the above line manually
|
---|
51 | if [ -z "$gsdl2path" ]; then
|
---|
52 | autoset_gsdl_home gsdl2path
|
---|
53 | fi
|
---|
54 |
|
---|
55 | # Setup Greenstone2, unless it has already been done
|
---|
56 | if [ -z "$GSDLHOME" ]; then
|
---|
57 | pushd "$gsdl2path" > /dev/null
|
---|
58 | source ./setup.bash
|
---|
59 | popd > /dev/null
|
---|
60 | fi
|
---|
61 |
|
---|
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).
|
---|
67 | if [ ! -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
|
---|
74 | fi
|
---|
75 |
|
---|
76 | # If there's no llssite.cfg file, copy from the template
|
---|
77 | if [ ! -e "$GSDLHOME/llssite.cfg" ]; then
|
---|
78 | if [ -e "$GSDLHOME/llssite.cfg.in" ]; then
|
---|
79 | cp "$GSDLHOME/llssite.cfg.in" "$GSDLHOME/llssite.cfg"
|
---|
80 | else
|
---|
81 | echo "Warning: could not find llssite.cfg.in to create llssite.cfg from."
|
---|
82 | fi
|
---|
83 | fi
|
---|
84 |
|
---|
85 | ## ---- Determine JAVA_HOME ----
|
---|
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.
|
---|
88 | silent=
|
---|
89 |
|
---|
90 | # JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
91 | search4j -m $java_min_version &> /dev/null
|
---|
92 | # for some reason, Mac requires an echo after the above
|
---|
93 | echo
|
---|
94 | if [ "$?" == "0" ]; then
|
---|
95 | # In Java code, '...getResourceAsStream("build.properties")'
|
---|
96 | # needs up to be in the right directory when run
|
---|
97 | pushd "$gsdl2path" > /dev/null
|
---|
98 |
|
---|
99 |
|
---|
100 | #CLASSPATH
|
---|
101 | if [ `isinpath "$CLASSPATH" "$GSDLHOME/lib/java"` == "false" ]; then
|
---|
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"
|
---|
108 |
|
---|
109 | else
|
---|
110 | echo " - CLASSPATH already correct"
|
---|
111 | fi
|
---|
112 |
|
---|
113 | ## ---- Check Java ----
|
---|
114 | # call the script with source, so that we have the variables it sets ($javapath)
|
---|
115 | exit_status=0
|
---|
116 | source ./findjava.sh "$serverlang" "$PROGNAME"
|
---|
117 | exit_status=$?
|
---|
118 | if [ "$exit_status" -eq 1 ]; then
|
---|
119 | exit 1;
|
---|
120 | fi
|
---|
121 | export PATH=$javahome/bin:$PATH
|
---|
122 |
|
---|
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
|
---|
125 |
|
---|
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
|
---|
132 |
|
---|
133 | popd > /dev/null
|
---|
134 | fi
|
---|
135 |
|
---|