-
Notifications
You must be signed in to change notification settings - Fork 2
/
gs3-server.sh
executable file
·127 lines (92 loc) · 3.46 KB
/
gs3-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
serverlang=en
java_min_version=1.4.0_00
autoset_gsdl_home() {
# remove leading ./ if present
prog="${0#./}"
isrelative="${prog%%/*}"
if [ ! -z $isrelative ] ; then
# some text is left after stripping
# => is relative
pwd="$PWD"
prog="$pwd/$prog"
fi
fulldir="${prog%/*}"
# remove trailing /. if present
eval $1=\""${fulldir%/.}"\"
}
check_gsdl3home_writable() {
echo "Checking if the Greenstone3 web directory is writable ..."
(echo "This is a temporary file. It is safe to delete it." > "$GSDL3HOME/testing.tmp" ) 2>/dev/null
if [ -e "$GSDL3HOME/testing.tmp" ] ; then
/bin/rm "$GSDL3HOME/testing.tmp"
gsdl3home_isreadonly=0
echo " ... yes."
else
gsdl3home_isreadonly=1
gsdl3_writablehome="/tmp/greenstone/web"
echo " ... no."
echo "Setting Greenstone3 web home writable area to be: $gsdl3_writablehome"
# if [ ! -d "$gsdl3_writablehome" ] ; then
# echo "Creating the directory: $gsdl3_writablehome"
# mkdir -p "$gsdl3_writablehome"
# mkdir -p "$gsdl3_writablehome/packages"
# mkdir -p "$gsdl3_writablehome/logs"
# mkdir -p "$gsdl3_writablehome/ext/solr"
# chmod a+rwx "$gsdl3_writablehome"
# chmod a+rwx "$gsdl3_writablehome/packages"
# chmod a+rwx "$gsdl3_writablehome/logs"
# chmod a+rwx "$gsdl3_writablehome/ext/solr"
## echo "Copying to $gsdl3_writablehome/packages/tomcat"
## /bin/cp -r "$GSDL3SRCHOME/packages/tomcat" "$gsdl3_writablehome/packages/."
## echo "=> Copying Greenstone's web/WEB-INF to writable area"
## gsdl3_home=$GSDL3HOME
## /bin/cp -r "$gsdl3_home/WEB-INF" "$gsdl3_writablehome/."
## /bin/cp -r "$gsdl3_home/index.html" "$gsdl3_writablehome/."
## fi
fi
}
echo "Greenstone 3 Server"
echo "Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato"
echo "This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
echo "This is free software, and you are welcome to redistribute it"
## -------- Run the Greenstone 3 Server --------
## ---- Determine GSDL3SRCHOME ----
gsdl3path=
# Some users may set the above line manually
if [ -z "$gsdl3path" ]; then
autoset_gsdl_home "gsdl3path"
fi
# Setup Greenstone3
pushd $gsdl3path > /dev/null
source ./gs3-setup.sh
popd > /dev/null
check_gsdl3home_writable
opt_properties=
if [ $gsdl3home_isreadonly = 1 ] ; then
opt_properties="-Dgsdl3home.isreadonly=true -Dgsdl3.writablehome=$gsdl3_writablehome"
else
opt_properties="-Dgsdl3.writablehome=$GSDL3HOME"
fi
# Calling ant target to initialize the gsdl3-writablehome area (if it doesn't already exist)
# ... including the all important global.properties.
ant $opt_properties configure-web
# JRE_HOME or JAVA_HOME must be set correctly to run this program
HINT="`pwd`/packages/jre"
if [ "$GSDLOS" = "darwin" ]; then
if [ ! -d "$HINT" ]; then
HINT=`/usr/libexec/java_home`
fi
# set the mac icon for when launching this script manually
if [ -f "gs3-server.app/Contents/Resources/AutomatorApplet.icns" ]; then
opt_properties="$opt_properties -Xdock:icon=gs3-server.app/Contents/Resources/AutomatorApplet.icns"
fi
fi
javapath=`search4j -p "$HINT" -m $java_min_version -e`
if [ "$?" == "0" ]; then
# In Java code, '...getResourceAsStream("build.properties")'
# needs up to be in the right directory when run
pushd "$gsdl3path" > /dev/null
"$javapath" $opt_properties org.greenstone.server.Server3 "$GSDL3SRCHOME" $serverlang
popd > /dev/null
fi