[19937] | 1 | #!/bin/bash
|
---|
[13235] | 2 | serverlang=en
|
---|
| 3 |
|
---|
[15131] | 4 | java_min_version=1.4.0_00
|
---|
| 5 |
|
---|
[18559] | 6 | autoset_gsdl_home() {
|
---|
| 7 |
|
---|
| 8 | # remove leading ./ if present
|
---|
[20187] | 9 | prog="${0#./}"
|
---|
[18559] | 10 |
|
---|
[20187] | 11 | isrelative="${prog%%/*}"
|
---|
[18559] | 12 |
|
---|
| 13 | if [ ! -z $isrelative ] ; then
|
---|
| 14 | # some text is left after stripping
|
---|
| 15 | # => is relative
|
---|
[20187] | 16 | pwd="$PWD"
|
---|
[18559] | 17 | prog="$pwd/$prog"
|
---|
| 18 | fi
|
---|
| 19 |
|
---|
[20187] | 20 | fulldir="${prog%/*}"
|
---|
[18559] | 21 |
|
---|
| 22 | # remove trailing /. if present
|
---|
[20187] | 23 | eval $1=\""${fulldir%/.}"\"
|
---|
[18559] | 24 | }
|
---|
| 25 |
|
---|
[27830] | 26 | check_gsdl3home_writable() {
|
---|
[18559] | 27 |
|
---|
[27830] | 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"
|
---|
[27837] | 40 |
|
---|
| 41 |
|
---|
[27862] | 42 | # if [ ! -d "$gsdl3_writablehome" ] ; then
|
---|
| 43 | # echo "Creating the directory: $gsdl3_writablehome"
|
---|
[27837] | 44 |
|
---|
[27862] | 45 | # mkdir -p "$gsdl3_writablehome"
|
---|
| 46 | # mkdir -p "$gsdl3_writablehome/packages"
|
---|
| 47 | # mkdir -p "$gsdl3_writablehome/logs"
|
---|
| 48 | # mkdir -p "$gsdl3_writablehome/ext/solr"
|
---|
[27837] | 49 |
|
---|
[27862] | 50 | # chmod a+rwx "$gsdl3_writablehome"
|
---|
| 51 | # chmod a+rwx "$gsdl3_writablehome/packages"
|
---|
| 52 | # chmod a+rwx "$gsdl3_writablehome/logs"
|
---|
| 53 | # chmod a+rwx "$gsdl3_writablehome/ext/solr"
|
---|
[27837] | 54 |
|
---|
[27862] | 55 | ## echo "Copying to $gsdl3_writablehome/packages/tomcat"
|
---|
| 56 | ## /bin/cp -r "$GSDL3SRCHOME/packages/tomcat" "$gsdl3_writablehome/packages/."
|
---|
| 57 |
|
---|
| 58 | ## echo "=> Copying Greenstone's web/WEB-INF to writable area"
|
---|
[27837] | 59 |
|
---|
[27862] | 60 | ## gsdl3_home=$GSDL3HOME
|
---|
| 61 | ## /bin/cp -r "$gsdl3_home/WEB-INF" "$gsdl3_writablehome/."
|
---|
| 62 | ## /bin/cp -r "$gsdl3_home/index.html" "$gsdl3_writablehome/."
|
---|
| 63 | ## fi
|
---|
[27830] | 64 | fi
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[13235] | 67 | echo "Greenstone 3 Server"
|
---|
[18559] | 68 | echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
|
---|
[13235] | 69 | echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
| 70 | echo "This is free software, and you are welcome to redistribute it"
|
---|
| 71 |
|
---|
| 72 | ## -------- Run the Greenstone 3 Server --------
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | ## ---- Determine GSDL3SRCHOME ----
|
---|
| 76 | gsdl3path=
|
---|
| 77 |
|
---|
| 78 | # Some users may set the above line manually
|
---|
[14727] | 79 | if [ -z "$gsdl3path" ]; then
|
---|
[20187] | 80 | autoset_gsdl_home "gsdl3path"
|
---|
[13235] | 81 | fi
|
---|
| 82 |
|
---|
[20188] | 83 | # Setup Greenstone3
|
---|
| 84 | pushd $gsdl3path > /dev/null
|
---|
| 85 | source ./gs3-setup.sh
|
---|
| 86 | popd > /dev/null
|
---|
[13235] | 87 |
|
---|
[27862] | 88 |
|
---|
[27830] | 89 | check_gsdl3home_writable
|
---|
| 90 |
|
---|
| 91 | opt_properties=
|
---|
| 92 | if [ $gsdl3home_isreadonly = 1 ] ; then
|
---|
| 93 | opt_properties="-Dgsdl3home.isreadonly=true -Dgsdl3.writablehome=$gsdl3_writablehome"
|
---|
[27873] | 94 | else
|
---|
| 95 | opt_properties="-Dgsdl3.writablehome=$GSDL3HOME"
|
---|
| 96 | fi
|
---|
[27862] | 97 |
|
---|
[27873] | 98 | # Calling ant target to initialize the gsdl3-writablehome area (if it doesn't already exist)
|
---|
| 99 | # ... including the all important global.properties.
|
---|
[27862] | 100 |
|
---|
[27873] | 101 | ant $opt_properties configure-web
|
---|
[27862] | 102 |
|
---|
[27830] | 103 |
|
---|
[14727] | 104 | # JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
[20059] | 105 | HINT="`pwd`/packages/jre"
|
---|
| 106 | javapath=`search4j -p "$HINT" -m $java_min_version -e`
|
---|
[15132] | 107 | if [ "$?" == "0" ]; then
|
---|
[18559] | 108 | # In Java code, '...getResourceAsStream("build.properties")'
|
---|
| 109 | # needs up to be in the right directory when run
|
---|
[20059] | 110 | pushd "$gsdl3path" > /dev/null
|
---|
[18559] | 111 |
|
---|
[27830] | 112 | "$javapath" $opt_properties org.greenstone.server.Server3 "$GSDL3SRCHOME" $serverlang
|
---|
[18559] | 113 |
|
---|
| 114 | popd > /dev/null
|
---|
[15132] | 115 | fi
|
---|
[13235] | 116 |
|
---|