source: main/trunk/greenstone3/gs3-server.sh@ 27837

Last change on this file since 27837 was 27837, checked in by davidb, 11 years ago

gs3-server.sh script does (after all) need to set up the Greenstone writable directory. This logic also exists in build.xml, but is duplicated here to help Server3.java startup

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
RevLine 
[19937]1#!/bin/bash
[13235]2serverlang=en
3
[15131]4java_min_version=1.4.0_00
5
[18559]6autoset_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]26check_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 if [ ! -d "$gsdl3_writablehome" ] ; then
42 echo "Creating the directory: $gsdl3_writablehome"
43
44 mkdir -p "$gsdl3_writablehome"
45 mkdir -p "$gsdl3_writablehome/packages"
46 mkdir -p "$gsdl3_writablehome/logs"
47
48 chmod a+rwx "$gsdl3_writablehome"
49 chmod a+rwx "$gsdl3_writablehome/packages"
50 chmod a+rwx "$gsdl3_writablehome/logs"
51
52 echo "Copying to $gsdl3_writablehome/packages/tomcat"
53 /bin/cp -r "$GSDL3SRCHOME/packages/tomcat" "$gsdl3_writablehome/packages/."
54
55 echo "=> Copying Greenstone's web/WEB-INF to writable area"
56
57 gsdl3_home=$GSDL3HOME
58 /bin/cp -r "$gsdl3_home/WEB-INF" "$gsdl3_writablehome/."
59 /bin/cp -r "$gsdl3_home/index.html" "$gsdl3_writablehome/."
60 fi
[27830]61 fi
62}
63
[13235]64echo "Greenstone 3 Server"
[18559]65echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
[13235]66echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
67echo "This is free software, and you are welcome to redistribute it"
68
69## -------- Run the Greenstone 3 Server --------
70
71
72## ---- Determine GSDL3SRCHOME ----
73gsdl3path=
74
75# Some users may set the above line manually
[14727]76if [ -z "$gsdl3path" ]; then
[20187]77 autoset_gsdl_home "gsdl3path"
[13235]78fi
79
[20188]80# Setup Greenstone3
81pushd $gsdl3path > /dev/null
82source ./gs3-setup.sh
83popd > /dev/null
[13235]84
[27830]85check_gsdl3home_writable
86
87opt_properties=
88if [ $gsdl3home_isreadonly = 1 ] ; then
89 opt_properties="-Dgsdl3home.isreadonly=true -Dgsdl3.writablehome=$gsdl3_writablehome"
90fi
91
[14727]92# JRE_HOME or JAVA_HOME must be set correctly to run this program
[20059]93HINT="`pwd`/packages/jre"
94javapath=`search4j -p "$HINT" -m $java_min_version -e`
[15132]95if [ "$?" == "0" ]; then
[18559]96 # In Java code, '...getResourceAsStream("build.properties")'
97 # needs up to be in the right directory when run
[20059]98 pushd "$gsdl3path" > /dev/null
[18559]99
[27830]100 "$javapath" $opt_properties org.greenstone.server.Server3 "$GSDL3SRCHOME" $serverlang
[18559]101
102 popd > /dev/null
[15132]103fi
[13235]104
Note: See TracBrowser for help on using the repository browser.