source: trunk/gsdl/Install.sh@ 2729

Last change on this file since 2729 was 2729, checked in by sjboddie, 23 years ago

Install.sh now explicitly sets executable permissions for everything in
the bin/script directory

  • Property svn:executable set to *
  • Property svn:mime-type set to application/octet-stream
File size: 28.7 KB
Line 
1#!/bin/sh
2
3## Install.sh -- Install Greenstone
4
5cmd_cp="cp"
6cmd_cpr="cp -r"
7cmd_chmod="chmod"
8cmd_mkdir="mkdir -p"
9cmd_ln="ln -s"
10cmd_mv="mv"
11cmd_rm="rm -i"
12cmd_rmr="rm -r"
13
14thisdir=`pwd`
15cd ..
16cd_dir=`pwd`
17cd "$thisdir"
18
19# script must be run from within cdrom/unix directory
20if [ ! -f "${thisdir}/Install.sh" ]; then
21 echo "Install.sh must be run from the directory in which it resides"
22 echo "Greenstone was not installed"
23 exit 1
24fi
25
26# check that various important directories are on the cd
27if [ ! -d "${cd_dir}/gsdl" ]; then
28 echo
29 echo "ERROR: Could not locate ${cd_dir}/gsdl"
30 echo "Greenstone was not installed"
31 exit 1
32fi
33if [ ! -d "${cd_dir}/Unix/bin/linux" ]; then
34 echo
35 echo "ERROR: Could not locate ${cd_dir}/Unix/bin/linux"
36 echo "Greenstone was not installed"
37 exit 1
38fi
39
40
41# install to /usr/local by default if user is "root", otherwise
42# default to users home directory
43gsdlos=`uname | tr A-Z a-z`
44if [ "$gsdlos" = "linux" ]; then
45 logname=`whoami`
46else
47 logname=""
48fi
49if [ "$logname" = "" ]; then
50 logname=`logname`
51fi
52gsdlhome="/home/${logname}"
53if [ "$logname" = "root" ]; then
54 gsdlhome="/usr/local"
55fi
56
57# get gsdlhome
58msg="This script will install Greenstone on your system. You may want
59to skim through the Install.pdf document that resides in the docs
60directory on this cd-rom before continuing with the installation.
61
62Note that when prompted for input, hitting \"enter\" will select
63the default (given in square brackets [] at the end of each question).
64If you're unsure which option to select, use the default.
65
66Note also that Install.sh prints out information on any commands
67it runs on your system in the form \"--> Install.sh: [command]\".
68
69It is assumed throughout this installation procedure that you
70have a webserver installed on your system.
71
72For later reference the output of this install script will be
73recorded in a file called INSTALL_RECORD in the directory into
74which you choose to install Greenstone.
75
76Continue? [y]"
77echo "$msg"
78printf "%s" "> "
79read ans
80log="${log}${msg}
81> $ans
82"
83if [ "$ans" != "" ] && [ "$ans" != "y" ]; then
84 echo "Greenstone was not installed"
85 exit 0
86fi
87
88msg="
89Which directory should Greenstone be installed to?
90Make sure that this directory is on a partition with sufficient
91free disk space for the installation option you intend
92selecting.
93"
94if [ "$gsdlos" = "linux" ]; then
95msg="${msg}--A standard linux binary installation requires approximately
96 50Mb of free disk space (not including additional collections).
97"
98fi
99msg="${msg}--Compiling Greenstone from source code requires approximately
100 155Mb of free disk space (not including additional collections).
101--Optional Greenstone demonstration collections may require up
102 to 200Mb of free disk space (you'll be told the size of
103 individual collections before you install them)
104Enter directory to install Greenstone into. A gsdl directory
105will be created in this directory. [${gsdlhome}]"
106echo "$msg"
107printf "%s" "> "
108read ans
109log="${log}${msg}
110> $ans
111"
112if [ "$ans" != "" ]; then
113 gsdlhome="$ans"
114fi
115
116if [ ! -d "$gsdlhome" ]; then
117 msg="
118Warning: The ${gsdlhome} directory does not exist.
119Create it? [y]"
120 echo "$msg"
121 printf "%s" "> "
122 read ans
123 log="${log}${msg}
124> $ans
125"
126 if [ "$ans" = "" ]; then
127 ans="y"
128 fi
129 if [ "$ans" = "y" ]; then
130 msg="--> Install.sh: [$cmd_mkdir \"$gsdlhome\"]"
131 echo "$msg"
132 log="${log}${msg}
133"
134 $cmd_mkdir "$gsdlhome"
135 if [ ! -d "$gsdlhome" ]; then
136 echo "ERROR: failed to create $gsdlhome directory"
137 echo "Greenstone was not installed"
138 exit 1
139 fi
140 else
141 echo "Greenstone was not installed"
142 exit 0
143 fi
144fi
145
146# from now on $gsdlhome includes the "/gsdl"
147gsdlhome="${gsdlhome}/gsdl"
148msg="--> Install.sh: [$cmd_mkdir \"${gsdlhome}\"]"
149echo "$msg"
150log="${log}${msg}
151"
152$cmd_mkdir "$gsdlhome"
153if [ ! -d "$gsdlhome" ]; then
154 echo "ERROR: failed to create $gsdlhome directory"
155 echo "Greenstone was not installed"
156 exit 1
157fi
158# set permissions on gsdlhome directory
159msg="--> Install.sh: [$cmd_chmod u+rwx \"${gsdlhome}\"]"
160echo "$msg"
161log="${log}${msg}
162"
163$cmd_chmod u+rwx "$gsdlhome"
164
165# create initial Uninstall.sh
166cd "$gsdlhome"
167echo "#!/bin/sh" > Uninstall.sh
168echo "" >> Uninstall.sh
169echo "echo \"remove ${gsdlhome} directory? [y]\"" >> Uninstall.sh
170echo "read ans" >> Uninstall.sh
171echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> Uninstall.sh
172echo " $cmd_rmr \"$gsdlhome\"" >> Uninstall.sh
173echo "fi" >> Uninstall.sh
174$cmd_chmod u+x Uninstall.sh
175cd "$thisdir"
176
177# create initial INSTALL_RECORD
178echo "$log" >> "${gsdlhome}/INSTALL_RECORD"
179
180msg="
181If this installation fails or is cancelled, run the uninstall
182script (${gsdlhome}/Uninstall.sh) to clean up the partial
183installation.
184Continue? [y]"
185echo "$msg"
186echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
187printf "%s" "> "
188read ans
189echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
190if [ "$ans" != "" ] && [ "$ans" != "y" ]; then
191 msg="Greenstone was not installed"
192 echo "$msg"
193 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
194 exit 0
195fi
196
197msg="
198Installing Greenstone directory structure to ${gsdlhome}"
199echo "$msg"
200echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
201
202# copy gsdl directory across
203msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/gsdl/\"* \"$gsdlhome\"]"
204echo "$msg"
205echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
206$cmd_cpr "${cd_dir}/gsdl/"* "$gsdlhome"
207
208# copy setup shell scripts across too
209msg="--> Install.sh: [$cmd_cp \"${cd_dir}/src/Unix/setup.\"* \"$gsdlhome\"]"
210echo "$msg"
211echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
212$cmd_cp "${cd_dir}/src/Unix/setup."* "$gsdlhome"
213
214# and docs directory
215msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/docs\" \"$gsdlhome\"]"
216echo "$msg"
217echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
218$cmd_cpr "${cd_dir}/docs" "$gsdlhome"
219
220# make sure we have a tmp directory
221if [ ! -d "$gsdlhome/tmp" ]; then
222 msg="--> Install.sh: [$cmd_mkdir \"$gsdlhome/tmp\"]"
223 echo "$msg"
224 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
225 $cmd_mkdir "$gsdlhome/tmp"
226fi
227
228# make collect directory writable so we can install collections
229msg="--> Install.sh: [$cmd_chmod u+rwx \"$gsdlhome/collect\"]"
230echo "$msg"
231echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
232$cmd_chmod u+rwx "$gsdlhome/collect"
233
234# which collections do we want
235cd "${cd_dir}/collect"
236
237msg="
238The Greenstone demonstration collection has been installed. Would you
239like to install any other collections from the installation cd-rom? [y]"
240echo "$msg"
241echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
242printf "%s" "> "
243read ans
244echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
245if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
246
247 msg="
248Install the greenstone archive (gsarch) - 1Mb? [y]"
249 echo "$msg"
250 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
251 printf "%s" "> "
252 read ans
253 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
254 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
255 msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/gsarch\" \"${gsdlhome}/collect\"]"
256 echo "$msg"
257 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
258 $cmd_cpr "${cd_dir}/collect/gsarch" "${gsdlhome}/collect"
259 fi
260
261 msg="
262Install the MSWord and PDF demonstration collection (wordpdf) - 3Mb? [y]"
263 echo "$msg"
264 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
265 printf "%s" "> "
266 read ans
267 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
268 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
269 msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/wordpdf\" \"${gsdlhome}/collect\"]"
270 echo "$msg"
271 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
272 $cmd_cpr "${cd_dir}/collect/wordpdf" "${gsdlhome}/collect"
273 fi
274
275 msg="
276Install the Chinese demonstration collection (chinese) - 1Mb? [y]"
277 echo "$msg"
278 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
279 printf "%s" "> "
280 read ans
281 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
282 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
283 msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/chinese\" \"${gsdlhome}/collect\"]"
284 echo "$msg"
285 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
286 $cmd_cpr "${cd_dir}/collect/chinese" "${gsdlhome}/collect"
287 fi
288
289 msg="
290Install the food and nutrition library (fnl) - 175 Mb? [y]"
291 echo "$msg"
292 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
293 printf "%s" "> "
294 read ans
295 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
296 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
297 msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/fnl\" \"${gsdlhome}/collect\"]"
298 echo "$msg"
299 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
300 $cmd_cpr "${cd_dir}/collect/fnl" "${gsdlhome}/collect"
301 fi
302
303 msg="
304Install the language extraction demonstration collection (folktale) - 2Mb? [y]"
305 echo "$msg"
306 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
307 printf "%s" "> "
308 read ans
309 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
310 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
311 msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/folktale\" \"${gsdlhome}/collect\"]"
312 echo "$msg"
313 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
314 $cmd_cpr "${cd_dir}/collect/folktale" "${gsdlhome}/collect"
315 fi
316fi
317
318# set permissions
319msg="
320Setting permissions ...
321--> Install.sh: [$cmd_chmod -R u+rw \"$gsdlhome\"]"
322--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/bin/script/\"*]"
323echo "$msg"
324echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
325$cmd_chmod -R u+rw "$gsdlhome"
326$cmd_chmod a+x "${gsdlhome}/bin/script/"*
327
328# certain files in gsdl/etc need to be globally writable
329msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/errout.txt\"]"
330echo "$msg"
331echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
332$cmd_chmod a+w "$gsdlhome/etc/errout.txt"
333msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/initout.txt\"]"
334echo "$msg"
335echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
336$cmd_chmod a+w "$gsdlhome/etc/initout.txt"
337msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/key.db\"]"
338echo "$msg"
339echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
340$cmd_chmod a+w "$gsdlhome/etc/key.db"
341msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/users.db\"]"
342echo "$msg"
343echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
344$cmd_chmod a+w "$gsdlhome/etc/users.db"
345msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/main.cfg\"]"
346echo "$msg"
347echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
348$cmd_chmod a+w "$gsdlhome/etc/main.cfg"
349msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/history.db\"]"
350echo "$msg"
351echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
352$cmd_chmod a+w "$gsdlhome/etc/history.db"
353msg="--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc/usage.txt\"]"
354echo "$msg"
355echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
356$cmd_chmod a+w "$gsdlhome/etc/usage.txt"
357
358
359# should gsdl/collect and gsdl/tmp be globally writable?
360msg="
361In order for end-user collection building to be enabled the
362Greenstone cgi program must be able to write to the
363${gsdlhome}/collect and ${gsdlhome}/tmp directories.
364On most systems this means they must be globally writable.
365Make these directories globally writable? [y]"
366echo "$msg"
367echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
368printf "%s" "> "
369read ans
370echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
371if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
372 msg="--> Install.sh: [$cmd_chmod -R a+w \"$gsdlhome/collect\"]"
373 echo "$msg"
374 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
375 $cmd_chmod -R a+w "$gsdlhome/collect"
376 msg="--> Install.sh: [$cmd_chmod -R a+w \"$gsdlhome/tmp\"]"
377 echo "$msg"
378 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
379 $cmd_chmod -R a+w "$gsdlhome/tmp"
380fi
381
382# binaries or source code?
383compile="yes"
384if [ "$gsdlos" = "linux" ]; then
385 msg="
386You may either install pre-compiled, statically linked linux [b]inaries
387(i386 only) or install and [c]ompile the Greenstone source code"
388 echo "$msg"
389 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
390
391 found=no
392 while [ "$found" = "no" ]; do
393 msg="Enter \"[b]\" or \"c\""
394 echo "$msg"
395 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
396 printf "%s" "> "
397 read ans
398 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
399 if [ "$ans" = "" ] || [ "$ans" = "b" ]; then
400 compile="no"
401 # install binaries
402 msg="
403Installing linux binaries
404--> Install.sh: [$cmd_cpr \"${cd_dir}/Unix/bin/linux\" \"${gsdlhome}/bin\" ]"
405 echo "$msg"
406 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
407 $cmd_cpr "${cd_dir}/Unix/bin/linux" "${gsdlhome}/bin"
408 msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/bin/linux/\"*]"
409 echo "$msg"
410 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
411 $cmd_chmod a+x "${gsdlhome}/bin/linux/"*
412 msg="--> Install.sh: [$cmd_chmod -R u+rw \"${gsdlhome}/bin/linux\"]"
413 echo "$msg"
414 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
415 $cmd_chmod -R u+rw "${gsdlhome}/bin/linux"
416
417 # move library executable to cgi-bin
418 msg="--> Install.sh: [$cmd_mv \"${gsdlhome}/bin/linux/library\" \"${gsdlhome}/cgi-bin\"]"
419 echo "$msg"
420 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
421 $cmd_mv "${gsdlhome}/bin/linux/library" "${gsdlhome}/cgi-bin"
422
423 found="yes"
424 elif [ "$ans" = "c" ]; then
425 found="yes"
426 fi
427 done
428fi
429
430if [ "$compile" = "yes" ]; then
431 # install source
432 msg="
433Installing source code
434--> Install.sh [$cmd_cpr \"${cd_dir}/src/lib\" \"$gsdlhome\"]"
435 echo "$msg"
436 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
437 $cmd_cpr "${cd_dir}/src/lib" "$gsdlhome"
438 msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/packages\" \"$gsdlhome\"]"
439 echo "$msg"
440 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
441 $cmd_cpr "${cd_dir}/src/packages" "$gsdlhome"
442 msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/src\" \"$gsdlhome\"]"
443 echo "$msg"
444 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
445 $cmd_cpr "${cd_dir}/src/src" "$gsdlhome"
446 msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/Unix/\"* \"$gsdlhome\"]"
447 echo "$msg"
448 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
449 $cmd_cpr "${cd_dir}/src/Unix/"* "$gsdlhome"
450 msg="--> Install.sh [$cmd_cp \"${cd_dir}/src/Install.txt\" \"$gsdlhome\"]"
451 echo "$msg"
452 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
453 $cmd_cp "${cd_dir}/src/Install.txt" "$gsdlhome"
454 msg="--> Install.sh: [$cmd_chmod -R u+rw \"$gsdlhome\"]"
455 echo "$msg"
456 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
457 $cmd_chmod -R u+rw "$gsdlhome"
458 msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/configure\"]"
459 echo "$msg"
460 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
461 $cmd_chmod a+x "${gsdlhome}/configure"
462 msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/packages/yaz/configure\"]"
463 echo "$msg"
464 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
465 $cmd_chmod a+x "${gsdlhome}/packages/yaz/configure"
466
467 # compile it
468 msg="--> Install.sh: [cd $gsdlhome]"
469 echo "$msg"
470 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
471 cd "$gsdlhome"
472 msg="configuring ...
473
474--> Install.sh: [./configure]"
475 echo "$msg"
476 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
477 ./configure
478 msg="compiling ...
479
480--> Install.sh: [make]"
481 echo "$msg"
482 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
483 make
484 msg="installing ...
485
486--> Install.sh: [make install]"
487 echo "$msg"
488 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
489 make install
490 msg="--> Install.sh: [cd $thisdir]"
491 echo "$msg"
492 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
493 cd "$thisdir"
494
495 # check that things compiled ok
496 if [ ! -f "${gsdlhome}/cgi-bin/library" ]; then
497 msg="
498ERROR: Compilation failed
499Greenstone was not installed successfully
500Run the uninstall script (${gsdlhome}/Uninstall.sh)
501to clean up the partial installation."
502 echo "$msg"
503 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
504 exit 1
505 fi
506fi
507
508
509# try to find out hostname
510if [ "$gsdlos" = "linux" ]; then
511 hostname=`hostname -f`
512 if [ "$hostname" = "" ]; then
513 hostname=`hostname -i`
514 fi
515fi
516if [ "$hostname" = "" ]; then
517 hostname=`hostname`
518fi
519if [ "$hostname" = "" ]; then
520 hostname="your-computer-name"
521fi
522
523
524# get cgi-bin directory
525msg="
526
527Greenstone needs a valid cgi executable directory (normally called
528cgi-bin on unix systems) from which to run.
529This may be either:
530 1. The default Greenstone cgi-bin directory (${gsdlhome}/cgi-bin).
531 If you use the Greenstone default you will need to configure
532 your webserver to treat this directory as a cgi executable
533 directory. For the Apache webserver you use the ScriptAlias
534 directive to do this (details of how to configure your webserver
535 will be displayed at the end of this installation procedure)."
536echo "$msg"
537echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
538if [ "$logname" != "root" ]; then
539 msg=" Note that you will probably need help from your system
540 administrator to reconfigure your webserver."
541 echo "$msg"
542 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
543fi
544msg=" 2. An existing cgi-bin directory. Normally a cgi-bin directory
545 is created when your webserver is installed. Typically, this
546 might be /home/httpd/cgi-bin, or /usr/local/apache/cgi-bin, or
547 /var/lib/apache/cgi-bin."
548echo "$msg"
549echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
550if [ "$logname" != "root" ]; then
551 msg=" Many systems also allow individual users to have their own
552 cgi-bin in /home/username/public_html/cgi-bin."
553 echo "$msg"
554 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
555fi
556found=no
557remind_cgi="no"
558remind_cgi_nomove="no"
559while [ "$found" = "no" ]; do
560 msg="Enter \"[1]\" or \"2\""
561 echo "$msg"
562 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
563 printf "%s" "> "
564 read ans
565 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
566 if [ "$ans" = "" ] || [ "$ans" = "1" ]; then
567 found="option1"
568 cgi_bin="${gsdlhome}/cgi-bin"
569 # default gsdl cgi-bin, do nothing
570 msg="
571Don't forget to configure your webserver to treat $cgi_bin
572as a cgi executable directory. Don't worry, you'll be
573reminded of this again at the end of the installation
574procedure"
575 echo "$msg"
576 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
577 remind_cgi="yes"
578 elif [ "$ans" = "2" ]; then
579 found="option2"
580 # external cgi-bin
581 msg="
582Enter existing cgi executable directory [/usr/local/apache/cgi-bin]"
583 echo "$msg"
584 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
585 printf "%s" "> "
586 read ans
587 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
588 if [ "$ans" = "" ]; then
589 cgi_bin="/usr/local/apache/cgi-bin"
590 else
591 cgi_bin="$ans"
592 fi
593 if [ ! -d "$cgi_bin" ]; then
594 msg="Warning: The ${cgi_bin} directory does not exist.
595Create it? [y]"
596 echo "$msg"
597 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
598 printf "%s" "> "
599 read ans
600 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
601 if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
602 msg="--> Install.sh: [$cmd_mkdir \"$cgi_bin\"]"
603 echo "$msg"
604 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
605 $cmd_mkdir "$cgi_bin"
606 if [ -d "$cgi_bin" ]; then
607 msg="Don't forget to configure your webserver to treat $cgi_bin
608as a cgi executable directory. Don't worry, you'll be
609reminded of this again at the end of the installation
610procedure"
611 echo "$msg"
612 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
613 remind_cgi="yes"
614 else
615 msg="ERROR: failed to create $cgi_bin directory
616Greenstone installation failed.
617Run the uninstall script (${gsdlhome}/Uninstall.sh)
618to clean up the partial installation."
619 echo "$msg"
620 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
621 exit 1
622 fi
623 fi
624 fi
625
626 if [ ! -w "$cgi_bin" ]; then
627 msg="
628Unable to write to $cgi_bin directory. You will need
629to copy the contents of ${gsdlhome}/cgi-bin
630to $cgi_bin after this installation is completed.
631You'll be reminded of this again at the end of the
632installation procedure."
633 echo "$msg"
634 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
635 remind_cgi_nomove="yes"
636 else
637 # install cgi-bin stuff (update the uninstall script first)
638 cd "$gsdlhome"
639 echo "#!/bin/sh" > Uninstall.sh
640 echo "" >> Uninstall.sh
641 echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> Uninstall.sh
642 echo "$cmd_rm \"${cgi_bin}/library\"" >> Uninstall.sh
643 echo "echo \"remove ${gsdlhome} directory? [y]\"" >> Uninstall.sh
644 echo "read ans" >> Uninstall.sh
645 echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> Uninstall.sh
646 echo " $cmd_rmr \"$gsdlhome\"" >> Uninstall.sh
647 echo "fi" >> Uninstall.sh
648 $cmd_chmod u+x Uninstall.sh
649 cd "$thisdir"
650
651 msg="
652Installing Greenstone cgi programs in $cgi_bin
653--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/gsdlsite.cfg\" \"$cgi_bin\"]"
654 echo "$msg"
655 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
656 $cmd_mv "${gsdlhome}/cgi-bin/gsdlsite.cfg" "$cgi_bin"
657 msg="--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/library\" \"$cgi_bin\"]"
658 echo "$msg"
659 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
660 $cmd_mv "${gsdlhome}/cgi-bin/library" "$cgi_bin"
661 fi
662 fi
663done
664
665# web address of cgi-bin
666web_cgi="http://${hostname}/cgi-bin"
667if [ "$found" = "option1" ]; then
668 web_cgi="http://${hostname}/gsdl/cgi-bin"
669fi
670msg="
671Please enter the web address of the $cgi_bin
672directory. Typically this might be http://localhost/cgi-bin,
673or http://127.0.0.1/cgi-bin, or http://your-computer-name/cgi-bin,
674or http://nnn.nnn.nnn.nn/cgi-bin. [$web_cgi]"
675echo "$msg"
676echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
677printf "%s" "> "
678read ans
679echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
680if [ "$ans" != "" ]; then
681 web_cgi="$ans"
682fi
683
684# get public_html directory
685msg="
686
687In order for Greenstone to run, the $gsdlhome
688directory and all it contains must be accessible from the web.
689To make this happen you may either:
690 1. Configure your webserver so that $gsdlhome
691 is itself accessible from the web."
692echo "$msg"
693echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
694if [ "$logname" != "root" ]; then
695 msg=" Note that you will probably need help from your system
696 administrator to reconfigure your webserver."
697 echo "$msg"
698 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
699fi
700msg=" 2. Provide an existing web accessible directory from which
701 a symbolic link (ln -s) will be made to $gsdlhome.
702 When your server was installed a web accessible directory
703 will have been created (the Apache webserver uses the
704 DocumentRoot directive to define this directory). Typically
705 this directory might be /home/httpd/html, or /usr/local/apache/htdocs,
706 or /var/lib/apache/htdocs."
707echo "$msg"
708echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
709if [ "$logname" != "root" ]; then
710 msg=" Many systems also allow individual users to have their own
711 web accessible directory in /home/username/public_html."
712 echo "$msg"
713 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
714fi
715msg=" Note that your web server will need to be configured to allow
716 symbolic links from within this directory. For the Apache
717 server that means this directory must be configured with
718 the SymLinksIfOwnerMatch or FollowSymLinks option (most Apache
719 installations are configured this way by default)."
720echo "$msg"
721echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
722found="no"
723remind_ph="no"
724remind_ph_nolink="no"
725while [ "$found" = "no" ]; do
726 msg="Enter \"[1]\" or \"2\""
727 echo "$msg"
728 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
729 printf "%s" "> "
730 read ans
731 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
732 if [ "$ans" = "" ] || [ "$ans" = "1" ]; then
733 found="yes"
734 public_html="$gsdlhome"
735 # no link
736 msg="
737Don't forget to configure your webserver to make $gsdlhome
738accessible from the web. You'll be reminded of this again
739at the end of this installation procedure."
740 echo "$msg"
741 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
742 remind_ph="yes"
743 elif [ "$ans" = "2" ]; then
744 found="yes"
745 # external public_html
746 echo
747 public_html="/home/${logname}/public_html"
748 if [ "$logname" = "root" ]; then
749 public_html="/usr/local/apache/htdocs"
750 fi
751 msg="Enter directory that is also accessible from the web [${public_html}]"
752 echo "$msg"
753 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
754 printf "%s" "> "
755 read ans
756 echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
757 if [ "$ans" != "" ]; then
758 public_html="$ans"
759 fi
760 # create link to gsdl (and update Uninstall.sh)
761 if [ -w "$public_html" ]; then
762 cd "$gsdlhome"
763 echo "#!/bin/sh" > Uninstall.sh
764 echo "" >> Uninstall.sh
765 echo "$cmd_rm \"$public_html/gsdl\"" >> Uninstall.sh
766 echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> Uninstall.sh
767 echo "$cmd_rm \"${cgi_bin}/library\"" >> Uninstall.sh
768 echo "echo \"remove ${gsdlhome} directory? [y]\"" >> Uninstall.sh
769 echo "read ans" >> Uninstall.sh
770 echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> Uninstall.sh
771 echo " $cmd_rmr \"$gsdlhome\"" >> Uninstall.sh
772 echo "fi" >> Uninstall.sh
773 $cmd_chmod u+x Uninstall.sh
774 cd "$thisdir"
775
776 msg="--> Install.sh: [cd \"$public_html\"]"
777 echo "$msg"
778 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
779 cd "$public_html"
780 msg="--> Install.sh: [$cmd_ln \"$gsdlhome\" gsdl]"
781 echo "$msg"
782 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
783 $cmd_ln "$gsdlhome" gsdl
784 msg="--> Install.sh: [cd \"$thisdir\"]"
785 echo "$msg"
786 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
787 cd "$thisdir"
788 else
789 msg="
790Unable to write to $public_html directory. You will need
791to create a link called gsdl from $public_html to
792$gsdlhome after this installation is completed. You'll be
793reminded of this again at the end of the installation
794procedure."
795 echo "$msg"
796 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
797 old_ph=$public_html
798 remind_ph_nolink="yes"
799 fi
800 public_html="${public_html}/gsdl"
801 fi
802done
803
804
805# get httpprefix
806msg="
807Enter the web address of the $public_html directory.
808This may be a relative url (e.g. \"/gsdl\") or a
809complete url (e.g. \"http://${hostname}/gsdl\") [/gsdl]"
810echo "$msg"
811echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
812printf "%s" ">"
813httpprefix="/gsdl"
814read ans
815echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
816if [ "$ans" != "" ]; then
817 httpprefix="$ans"
818fi
819
820# get initial password
821msg="
822In order to use end-user collection building or to access certain
823parts of the administration pages you must have a password.
824A user with the username \"admin\" will be created for you with
825the password you provide (i.e. to enter any pages requiring user
826authentication enter the \"admin\" username and the password you
827set here).
828";
829echo "$msg"
830echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
831pw=`${gsdlhome}/bin/${gsdlos}/getpw`
832tmp="[admin]
833<comment>
834<enabled>true
835<groups>administrator,colbuilder
836<password>${pw}
837<username>admin
838----------------------------------------------------------------------"
839echo "$tmp" | ${gsdlhome}/bin/${gsdlos}/txt2db "${gsdlhome}/etc/users.db"
840$cmd_chmod a+rw "${gsdlhome}/etc/users.db"
841
842# edit gsdlsite.cfg
843cd "$cgi_bin"
844sed "s|\(gsdlhome *\)[^ ]*|\1${gsdlhome}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
845sed "s|#*\(httpprefix *\)[^ ]*|\1${httpprefix}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
846sed "s|\(httpimg *\)[^ ]*|\1${httpprefix}/images|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
847
848msg="
849
850Greenstone installation completed successfully."
851echo "$msg"
852echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
853if [ "$remind_cgi" = "yes" ]; then
854 msg=" * Don't forget to configure your webserver to treat
855 $cgi_bin as a cgi executable directory."
856 echo "$msg"
857 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
858
859 apache_web_cgi=`echo "$web_cgi" | sed "s|[^/]*//[^/]*||" | sed "s|/*$|/|"`
860 cgi_bin_slash=`echo "$cgi_bin" | sed "s|/*$|/|"`
861 cgi_bin_noslash=`echo "$cgi_bin" | sed "s|/*$||"`
862
863 msg=" For the Apache webserver this means adding the following
864 ScriptAlias directive to your httpd.conf configuration file.
865
866 ScriptAlias ${apache_web_cgi} \"${cgi_bin_slash}\"
867 <Directory \"${cgi_bin_noslash}\">
868 AllowOverride None
869 Options None
870 Order allow,deny
871 Allow from all
872 </Directory>
873"
874 echo "$msg"
875 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
876fi
877if [ "$remind_cgi_nomove" = "yes" ]; then
878 msg=" * Don't forget to move the contents of ${gsdlhome}/cgi-bin
879 to $cgi_bin
880"
881 echo "$msg"
882 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
883fi
884if [ "$remind_ph" = "yes" ]; then
885 msg=" * Don't forget to configure your webserver to treat
886 $gsdlhome as a web accessible directory."
887 echo "$msg"
888 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
889
890 apache_httpprefix=`echo "$httpprefix" | sed "s|[^/]*//[^/]*||" | sed "s|/*$|/|"`
891 public_html_slash=`echo "$public_html" | sed "s|/*$|/|"`
892 public_html_noslash=`echo "$public_html" | sed "s|/*$||"`
893
894 msg=" For the Apache webserver this means adding the following
895 Alias directive to your httpd.conf configuration file.
896
897 Alias ${apache_httpprefix} \"${public_html_slash}\"
898 <Directory \"${public_html_noslash}\">
899 Options Indexes MultiViews FollowSymLinks
900 AllowOverride None
901 Order allow,deny
902 Allow from all
903 </Directory>
904"
905 echo "$msg"
906 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
907fi
908if [ "$remind_ph_nolink" = "yes" ]; then
909 msg=" * Don't forget to create a link called gsdl from $old_ph
910 to ${gsdlhome}.
911"
912 echo "$msg"
913 echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
914fi
915msg="The output of this script has been recorded for you at
916${gsdlhome}/INSTALL_RECORD.
917You may remove Greenstone from your system at any time by running
918the ${gsdlhome}/Uninstall.sh script.
919Access Greenstone by pointing a web browser at
920${web_cgi}/library
921"
922echo "$msg"
923echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
924
925exit 0
Note: See TracBrowser for help on using the repository browser.