1 | #!/bin/sh
|
---|
2 |
|
---|
3 | if [ ! -f gs3-setup.sh ]; then
|
---|
4 | echo "You must run this script from within the Greenstone 3 home directory"
|
---|
5 | exit 1
|
---|
6 | fi
|
---|
7 |
|
---|
8 | source gs3-setup.sh
|
---|
9 |
|
---|
10 | gsdl3home=$GSDL3HOME
|
---|
11 |
|
---|
12 | #########################
|
---|
13 | # CHECK NECESSARY BITS
|
---|
14 | #########################
|
---|
15 | if test -z "$CVSROOT" ; then
|
---|
16 | echo "You need to set the environment variable CVSROOT before running"
|
---|
17 | echo "this script. Please use the same path that you used to check out"
|
---|
18 | echo "the Greentone repository. If you are not using anonymous cvs, you"
|
---|
19 | echo "also need to set the variable CVS_RSH to ssh."
|
---|
20 | exit;
|
---|
21 | fi
|
---|
22 |
|
---|
23 | ############################
|
---|
24 | # GET INFO FROM USER
|
---|
25 | ############################
|
---|
26 |
|
---|
27 | # Prompt for the computer name
|
---|
28 | hostname="localhost"
|
---|
29 | echo ""
|
---|
30 | echo "Enter the full address of the host computer from which the greenstone"
|
---|
31 | echo "collections will be served, for example:"
|
---|
32 | echo "bob.greenstone.ac.nz"
|
---|
33 | echo "or press enter for default [Default = localhost]."
|
---|
34 | echo ""
|
---|
35 | printf "%s" "> "
|
---|
36 | read ans
|
---|
37 | if [ "$ans" != "" ] ; then
|
---|
38 | hostname="$ans"
|
---|
39 | fi
|
---|
40 |
|
---|
41 | # Prompt for the port number
|
---|
42 | portnumber="8080"
|
---|
43 | echo ""
|
---|
44 | echo "Enter the port number that the tomcat webserver will serve on,"
|
---|
45 | echo "or press enter for default [Default = 8080]."
|
---|
46 | echo ""
|
---|
47 | printf "%s" "> "
|
---|
48 | read ans
|
---|
49 | if [ "$ans" != "" ] ; then
|
---|
50 | portnumber="$ans"
|
---|
51 | fi
|
---|
52 |
|
---|
53 | #################################
|
---|
54 | # CHECKOUT ALL THE BITS FROM CVS
|
---|
55 | #################################
|
---|
56 |
|
---|
57 | # firstly, remove unwanted directories
|
---|
58 | cvs update -dRP
|
---|
59 |
|
---|
60 | # now check out extra bits
|
---|
61 | cd packages
|
---|
62 | if [ ! -d mgpp ]; then
|
---|
63 | cvs co -P mgpp
|
---|
64 | fi
|
---|
65 | cd $gsdl3home
|
---|
66 |
|
---|
67 | ###############################
|
---|
68 | # SETUP TOMCAT
|
---|
69 | ###############################
|
---|
70 |
|
---|
71 | cd comms/jakarta/
|
---|
72 | # unpack tomcat and rename directory
|
---|
73 | if [ ! -d tomcat ]; then
|
---|
74 | unzip jakarta-tomcat-4.1.30.zip
|
---|
75 | mv jakarta-tomcat-4.1.30 tomcat
|
---|
76 | fi
|
---|
77 |
|
---|
78 | #edit the tomcat setclasspath script to add our classpath
|
---|
79 | if [ ! -f ./tomcat/bin/setclasspath.sh.orig ]; then
|
---|
80 | mv ./tomcat/bin/setclasspath.sh ./tomcat/bin/setclasspath.sh.orig
|
---|
81 | cat ./tomcat/bin/setclasspath.sh.orig | sed 's,CLASSPATH=,CLASSPATH=\"$CLASSPATH\":,' > ./tomcat/bin/setclasspath.sh
|
---|
82 | fi
|
---|
83 |
|
---|
84 | # copy the modified server.xml into tomcat
|
---|
85 | if [ ! -f ./tomcat/conf/server-withexamples.xml.config ]; then
|
---|
86 | mv ./tomcat/conf/server.xml ./tomcat/conf/server-withexamples.xml.config
|
---|
87 | cat server.xml.in | sed "s|@gsdl3home@|${gsdl3home}|" > ./tomcat/conf/server.xml
|
---|
88 | fi
|
---|
89 |
|
---|
90 | # Edit the server.xml config file to set the port number
|
---|
91 | if [ "$portnumber" != "8080" ] ; then
|
---|
92 | cat ./tomcat/conf/server.xml | sed "s|8080|${portnumber}|" > server.xml.tmp
|
---|
93 | mv server.xml.tmp ./tomcat/conf/server.xml
|
---|
94 | fi
|
---|
95 |
|
---|
96 | #make everyone happy by giving the right permissions to the shell scripts
|
---|
97 | chmod a+x ./tomcat/bin/*.sh
|
---|
98 |
|
---|
99 | cd $gsdl3home
|
---|
100 |
|
---|
101 | ###############################
|
---|
102 | # SETUP SOAP
|
---|
103 | ###############################
|
---|
104 | cd comms/soap
|
---|
105 | # unpack soap and rename directory
|
---|
106 | if [ ! -d soap ]; then
|
---|
107 | unzip soap-bin-2.3.1.zip
|
---|
108 | mv soap-2_3_1 soap
|
---|
109 | cp soap/lib/soap.jar $gsdl3home/lib/java
|
---|
110 | # move the localsite deployment description into the soap webapp - localsite comes predeployed
|
---|
111 | cp DeployedServices.ds soap/webapps/soap/
|
---|
112 | # disable soap by renaming the web.xml file
|
---|
113 | mv ./soap/webapps/soap/WEB-INF/web.xml ./soap/webapps/soap/WEB-INF/web.xml.disabled
|
---|
114 | fi
|
---|
115 | cd $gsdl3home
|
---|
116 |
|
---|
117 | #edit the SOAPServer config file
|
---|
118 | if [ ! -f ./resources/java/SOAPServer.cfg ]; then
|
---|
119 | sed "s|@gsdl3home@|${gsdl3home}|" ./resources/java/SOAPServer.cfg.in > ./resources/java/SOAPServer.cfg
|
---|
120 | fi
|
---|
121 |
|
---|
122 | ################################
|
---|
123 | # SETUP MYSQL + SAMPLE DATABASES
|
---|
124 | ################################
|
---|
125 |
|
---|
126 | if [ ! -d packages/mysql/data ]; then
|
---|
127 | cd packages/mysql
|
---|
128 | unzip mysql-4.0.20-linux.zip
|
---|
129 | mkdir var
|
---|
130 | mkdir var/log
|
---|
131 | chmod 777 var var/log
|
---|
132 |
|
---|
133 | ./scripts/mysql_install_db --datadir=./data --basedir=. --user=root --force
|
---|
134 | ./bin/mysqld_safe --user=root --datadir=./data --basedir=. --pid_file=gsdl3.pid --socket=/tmp/mysql.sock --err-log=./var/log/mysql.log &
|
---|
135 | sleep 2
|
---|
136 | ./bin/mysql --user=root --execute="GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@localhost;"
|
---|
137 | ./bin/mysql --user=root --execute="GRANT SELECT,INSERT,DELETE,UPDATE,DROP,CREATE ON *.* TO gsdl3admin@'%';"
|
---|
138 | ./bin/mysql --user=root --execute="GRANT SELECT ON *.* TO gsdl3reader@localhost;"
|
---|
139 |
|
---|
140 | # set up any sample collections databases
|
---|
141 | #gs3mgdemo
|
---|
142 | ./bin/mysql --user=root --execute="create database localsite_gs3mgdemo;"
|
---|
143 | ./bin/mysql --user=root localsite_gs3mgdemo < $gsdl3home/web/sites/localsite/collect/gs3mgdemo/mysqldatadump.sql
|
---|
144 |
|
---|
145 | ./bin/mysqladmin --user=root --socket=/tmp/mysql.sock shutdown
|
---|
146 | cd $gsdl3home
|
---|
147 | fi
|
---|
148 |
|
---|
149 | #################################
|
---|
150 | # WEB.XML FILE
|
---|
151 | #################################
|
---|
152 | # Edit the web/WEB-INF/web.xml to set gsdl3home
|
---|
153 | if [ ! -f ./web/WEB-INF/web.xml ]; then
|
---|
154 | sed "s|@gsdl3home@|${gsdl3home}|" ./web/WEB-INF/web.xml.in > ./web/WEB-INF/web.xml
|
---|
155 | fi
|
---|
156 |
|
---|
157 | #################################
|
---|
158 | # SITE CONFIG FILES
|
---|
159 | #################################
|
---|
160 |
|
---|
161 | # Edit the siteConfig.xml found in any site within the sites folder - port and hostname
|
---|
162 | for SITE in $gsdl3home/web/sites/*; do
|
---|
163 | if [ -f $SITE/siteConfig.xml ] ; then
|
---|
164 | echo "Processing $SITE"
|
---|
165 | if [ "$hostname" != "localhost" ] ; then
|
---|
166 | sed "s|localhost|${hostname}|" $SITE/siteConfig.xml > $SITE/siteConfig.tmp && mv $SITE/siteConfig.tmp $SITE/siteConfig.xml
|
---|
167 | fi
|
---|
168 | if [ "$portnumber" != "8080" ] ; then
|
---|
169 | sed "s|8080|${portnumber}|" $SITE/siteConfig.xml > $SITE/siteConfig.tmp && mv $SITE/siteConfig.tmp $SITE/siteConfig.xml
|
---|
170 | fi
|
---|
171 | fi
|
---|
172 | done
|
---|
173 |
|
---|
174 | ############################
|
---|
175 | # GSDL3 SCRIPTS
|
---|
176 | #############################
|
---|
177 |
|
---|
178 | # We also edit the GSDL3 launching script and the SOAP deployment script
|
---|
179 | cp gs3-launch.sh.in gs3-launch.sh
|
---|
180 | cp gs3-soap-deploy-site.sh.in gs3-soap-deploy-site.sh
|
---|
181 |
|
---|
182 | if [ "$hostname" != "localhost" ] ; then
|
---|
183 | sed "s|localhost|${hostname}|" gs3-launch.sh > gs3-launch.tmp && mv gs3-launch.tmp gs3-launch.sh
|
---|
184 | sed "s|localhost|${hostname}|" gs3-soap-deploy-site.sh > gs3-soap.tmp && mv gs3-soap.tmp gs3-soap-deploy-site.sh
|
---|
185 |
|
---|
186 | fi
|
---|
187 | if [ "$portnumber" != "8080" ] ; then
|
---|
188 | sed "s|8080|${portnumber}|" gs3-launch.sh > gs3-launch.tmp && mv gs3-launch.tmp gs3-launch.sh
|
---|
189 | sed "s|8080|${portnumber}|" gs3-soap-deploy-site.sh > gs3-soap.tmp && mv gs3-soap.tmp gs3-soap-deploy-site.sh
|
---|
190 | fi
|
---|
191 |
|
---|
192 | # Make them executable
|
---|
193 | chmod a+x gs3-launch.sh
|
---|
194 | chmod a+x gs3-soap-deploy-site.sh
|
---|
195 |
|
---|
196 | ############################
|
---|
197 | # UNPACK SAMPLE COLLECTIONS
|
---|
198 | ############################
|
---|
199 |
|
---|
200 | # how can we stop these being done more than once? and do we need to?
|
---|
201 | cd web/sites/localsite/collect
|
---|
202 | # unpack import, index and metadata
|
---|
203 | for f in */index; do
|
---|
204 | cd $f
|
---|
205 | if test -f index.zip; then
|
---|
206 | unzip index.zip
|
---|
207 | fi
|
---|
208 | cd ../../
|
---|
209 | done
|
---|
210 |
|
---|
211 | for f in *; do
|
---|
212 | cd $f
|
---|
213 | if test -f import.zip; then
|
---|
214 | unzip import.zip
|
---|
215 | fi
|
---|
216 | if test -f archives.zip; then
|
---|
217 | unzip archives.zip
|
---|
218 | fi
|
---|
219 | if test -f metadata.zip; then
|
---|
220 | unzip metadata.zip
|
---|
221 | fi
|
---|
222 | cd ../
|
---|
223 | done
|
---|
224 |
|
---|
225 | cd $gsdl3home
|
---|
226 |
|
---|
227 | #######################
|
---|
228 | # COMPILATION
|
---|
229 | ######################
|
---|
230 |
|
---|
231 | echo "############################################################"
|
---|
232 | echo "Will now configure and make the code - this may take a while"
|
---|
233 | echo "############################################################"
|
---|
234 |
|
---|
235 | ./configure
|
---|
236 | make
|
---|
237 | make install
|
---|
238 | make docs
|
---|
239 |
|
---|
240 | # compile the test servlet
|
---|
241 | cd $gsdl3home/web/WEB-INF/classes
|
---|
242 | javac TestServlet.java
|
---|
243 | cd $gsdl3home
|
---|
244 |
|
---|
245 | #######################
|
---|
246 | # COPY JAR FILES
|
---|
247 | #######################
|
---|
248 |
|
---|
249 | # any jar files used by applets need to go into the web/lib directory. so we link to them
|
---|
250 | cd $gsdl3home/web/lib
|
---|
251 | ln -sf ../../lib/java/phind.jar
|
---|
252 | ln -sf ../../lib/java/xml-apis.jar
|
---|
253 | ln -sf ../../lib/java/xercesImpl.jar
|
---|
254 | cd $gsdl3home
|
---|
255 |
|
---|
256 |
|
---|
257 |
|
---|
258 | # And provide a nice little postscript
|
---|
259 | echo ""
|
---|
260 | echo "****************************************************************"
|
---|
261 | echo "Greenstone 3 - Installation Complete!"
|
---|
262 | echo ""
|
---|
263 | echo "Run ./gs3-launch.sh to start the web server"
|
---|
264 | echo ""
|
---|
265 | echo "****************************************************************"
|
---|
266 | echo ""
|
---|
267 |
|
---|
268 | exit 0
|
---|