1 | #!/bin/bash
|
---|
2 | serverlang=en
|
---|
3 |
|
---|
4 | java_min_version=1.4.0_00
|
---|
5 |
|
---|
6 | autoset_gsdl_home() {
|
---|
7 |
|
---|
8 | # remove leading ./ if present
|
---|
9 | prog="${0#./}"
|
---|
10 |
|
---|
11 | isrelative="${prog%%/*}"
|
---|
12 |
|
---|
13 | if [ ! -z $isrelative ] ; then
|
---|
14 | # some text is left after stripping
|
---|
15 | # => is relative
|
---|
16 | pwd="$PWD"
|
---|
17 | prog="$pwd/$prog"
|
---|
18 | fi
|
---|
19 |
|
---|
20 | fulldir="${prog%/*}"
|
---|
21 |
|
---|
22 | # remove trailing /. if present
|
---|
23 | eval $1=\""${fulldir%/.}"\"
|
---|
24 | }
|
---|
25 |
|
---|
26 | check_gsdl3home_writable() {
|
---|
27 |
|
---|
28 | echo "Checking if the Greenstone3 web directory is writable ..."
|
---|
29 | (echo "This is a temporary file. It is safe to delete it." > "$GSDL3HOME/testing.tmp" ) 2>/dev/null
|
---|
30 | if [ -e "$GSDL3HOME/testing.tmp" ] ; then
|
---|
31 | /bin/rm "$GSDL3HOME/testing.tmp"
|
---|
32 | gsdl3home_isreadonly=0
|
---|
33 | echo " ... yes."
|
---|
34 | else
|
---|
35 | gsdl3home_isreadonly=1
|
---|
36 | gsdl3_writablehome="/tmp/greenstone/web"
|
---|
37 |
|
---|
38 | echo " ... no."
|
---|
39 | echo "Setting Greenstone3 web home writable area to be: $gsdl3_writablehome"
|
---|
40 | fi
|
---|
41 | }
|
---|
42 |
|
---|
43 | echo "Greenstone 3 Server"
|
---|
44 | echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
|
---|
45 | echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
46 | echo "This is free software, and you are welcome to redistribute it"
|
---|
47 |
|
---|
48 | ## -------- Run the Greenstone 3 Server --------
|
---|
49 |
|
---|
50 |
|
---|
51 | ## ---- Determine GSDL3SRCHOME ----
|
---|
52 | gsdl3path=
|
---|
53 |
|
---|
54 | # Some users may set the above line manually
|
---|
55 | if [ -z "$gsdl3path" ]; then
|
---|
56 | autoset_gsdl_home "gsdl3path"
|
---|
57 | fi
|
---|
58 |
|
---|
59 | # Setup Greenstone3
|
---|
60 | pushd $gsdl3path > /dev/null
|
---|
61 | source ./gs3-setup.sh
|
---|
62 | popd > /dev/null
|
---|
63 |
|
---|
64 | check_gsdl3home_writable
|
---|
65 |
|
---|
66 | opt_properties=
|
---|
67 | if [ $gsdl3home_isreadonly = 1 ] ; then
|
---|
68 | opt_properties="-Dgsdl3home.isreadonly=true -Dgsdl3.writablehome=$gsdl3_writablehome"
|
---|
69 | fi
|
---|
70 |
|
---|
71 | # JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
72 | HINT="`pwd`/packages/jre"
|
---|
73 | javapath=`search4j -p "$HINT" -m $java_min_version -e`
|
---|
74 | if [ "$?" == "0" ]; then
|
---|
75 | # In Java code, '...getResourceAsStream("build.properties")'
|
---|
76 | # needs up to be in the right directory when run
|
---|
77 | pushd "$gsdl3path" > /dev/null
|
---|
78 |
|
---|
79 | "$javapath" $opt_properties org.greenstone.server.Server3 "$GSDL3SRCHOME" $serverlang
|
---|
80 |
|
---|
81 | popd > /dev/null
|
---|
82 | fi
|
---|
83 |
|
---|