root/main/tags/2.35a/gsdl/Install.sh @ 33178

Revision 2437, 27.4 KB (checked in by sjboddie, 19 years ago)

*** empty log message ***

  • Property svn:executable set to *
  • Property svn:mime-type set to application/octet-stream
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# make sure we have a tmp directory
215if [ ! -d "$gsdlhome/tmp" ]; then
216    msg="--> Install.sh: [$cmd_mkdir \"$gsdlhome/tmp\"]"
217    echo "$msg"
218    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
219    $cmd_mkdir "$gsdlhome/tmp"
220fi
221
222# make collect directory writable so we can install collections
223msg="--> Install.sh: [$cmd_chmod u+rwx \"$gsdlhome/collect\"]"
224echo "$msg"
225echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
226$cmd_chmod u+rwx "$gsdlhome/collect"
227
228# which collections do we want
229cd "${cd_dir}/collect"
230
231msg="
232The Greenstone demonstration collection has been installed. Would you
233like to install any other collections from the installation cd-rom? [y]"
234echo "$msg"
235echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
236printf "%s" "> "
237read ans
238echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
239if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
240
241    msg="
242Install the greenstone archive (gsarch) - 1Mb? [y]"
243    echo "$msg"
244    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
245    printf "%s" "> "
246    read ans
247    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
248    if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
249    msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/gsarch\" \"${gsdlhome}/collect\"]"
250    echo "$msg"
251    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
252    $cmd_cpr "${cd_dir}/collect/gsarch" "${gsdlhome}/collect"
253    fi
254
255    msg="
256Install the MSWord and PDF demonstration collection (wordpdf) - 3Mb? [y]"
257    echo "$msg"
258    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
259    printf "%s" "> "
260    read ans
261    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
262    if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
263    msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/wordpdf\" \"${gsdlhome}/collect\"]"
264    echo "$msg"
265    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
266    $cmd_cpr "${cd_dir}/collect/wordpdf" "${gsdlhome}/collect"
267    fi
268
269    msg="
270Install the Chinese demonstration collection (chinese) - 1Mb? [y]"
271    echo "$msg"
272    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
273    printf "%s" "> "
274    read ans
275    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
276    if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
277    msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/chinese\" \"${gsdlhome}/collect\"]"
278    echo "$msg"
279    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
280    $cmd_cpr "${cd_dir}/collect/chinese" "${gsdlhome}/collect"
281    fi
282
283    msg="
284Install the food and nutrition library (fnl) - 175 Mb? [y]"
285    echo "$msg"
286    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
287    printf "%s" "> "
288    read ans
289    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
290    if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
291    msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/fnl\" \"${gsdlhome}/collect\"]"
292    echo "$msg"
293    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
294    $cmd_cpr "${cd_dir}/collect/fnl" "${gsdlhome}/collect"
295    fi
296
297    msg="
298Install the language extraction demonstration collection (folktale) - 2Mb? [y]"
299    echo "$msg"
300    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
301    printf "%s" "> "
302    read ans
303    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
304    if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
305    msg="--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/folktale\" \"${gsdlhome}/collect\"]"
306    echo "$msg"
307    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
308    $cmd_cpr "${cd_dir}/collect/folktale" "${gsdlhome}/collect"
309    fi
310fi
311
312# set permissions
313msg="
314Setting permissions ...
315--> Install.sh: [$cmd_chmod -R u+rw \"$gsdlhome\"]"
316echo "$msg"
317echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
318$cmd_chmod -R u+rw "$gsdlhome"
319# gsdl/etc needs to be globally writable
320msg="--> Install.sh: [$cmd_chmod -R a+w \"$gsdlhome/etc\"]"
321echo "$msg"
322echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
323$cmd_chmod -R a+w "$gsdlhome/etc"
324
325# should gsdl/collect and gsdl/tmp be globally writable?
326msg="
327In order for end-user collection building to be enabled the
328Greenstone cgi program must be able to write to the
329${gsdlhome}/collect and ${gsdlhome}/tmp directories.
330On most systems this means they must be globally writable.
331Make these directories globally writable? [y]"
332echo "$msg"
333echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
334printf "%s" "> "
335read ans
336echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
337if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
338    msg="--> Install.sh: [$cmd_chmod -R a+w \"$gsdlhome/collect\"]"
339    echo "$msg"
340    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
341    $cmd_chmod -R a+w "$gsdlhome/collect"
342    msg="--> Install.sh: [$cmd_chmod -R a+w \"$gsdlhome/tmp\"]"
343    echo "$msg"
344    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
345    $cmd_chmod -R a+w "$gsdlhome/tmp"
346fi
347
348# binaries or source code?
349compile="yes"
350if [ "$gsdlos" = "linux" ]; then
351    msg="
352You may either install pre-compiled, statically linked linux [b]inaries
353or install and [c]ompile the Greenstone source code"
354    echo "$msg"
355    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
356
357    found=no
358    while [ "$found" = "no" ]; do
359    msg="Enter \"[b]\" or \"c\""
360    echo "$msg"
361    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
362    printf "%s" "> "
363    read ans
364    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
365    if [ "$ans" = "" ] || [ "$ans" = "b" ]; then
366        compile="no"
367        # install binaries
368        msg="
369Installing linux binaries
370--> Install.sh: [$cmd_cpr \"${cd_dir}/Unix/bin/linux\" \"${gsdlhome}/bin\" ]"
371        echo "$msg"
372        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
373            $cmd_cpr "${cd_dir}/Unix/bin/linux" "${gsdlhome}/bin"
374        msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/bin/linux/\"*]"
375        echo "$msg"
376        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
377        $cmd_chmod a+x "${gsdlhome}/bin/linux/"*
378        msg="--> Install.sh: [$cmd_chmod -R u+rw \"${gsdlhome}/bin/linux\"]"
379        echo "$msg"
380        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
381        $cmd_chmod -R u+rw "${gsdlhome}/bin/linux"
382
383        # move library executable to cgi-bin
384        msg="--> Install.sh: [$cmd_mv \"${gsdlhome}/bin/linux/library\" \"${gsdlhome}/cgi-bin\"]"
385        echo "$msg"
386        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
387        $cmd_mv "${gsdlhome}/bin/linux/library" "${gsdlhome}/cgi-bin"
388       
389        found="yes"
390    elif [ "$ans" = "c" ]; then
391        found="yes"
392    fi
393    done
394fi
395
396if [ "$compile" = "yes" ]; then
397    # install source
398    msg="
399Installing source code
400--> Install.sh [$cmd_cpr \"${cd_dir}/src/lib\" \"$gsdlhome\"]"
401    echo "$msg"
402    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
403    $cmd_cpr "${cd_dir}/src/lib" "$gsdlhome"
404    msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/packages\" \"$gsdlhome\"]"
405    echo "$msg"
406    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
407    $cmd_cpr "${cd_dir}/src/packages" "$gsdlhome"
408    msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/src\" \"$gsdlhome\"]"
409    echo "$msg"
410    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
411    $cmd_cpr "${cd_dir}/src/src" "$gsdlhome"
412    msg="--> Install.sh [$cmd_cpr \"${cd_dir}/src/Unix/\"* \"$gsdlhome\"]"
413    echo "$msg"
414    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
415    $cmd_cpr "${cd_dir}/src/Unix/"* "$gsdlhome"
416    msg="--> Install.sh [$cmd_cp \"${cd_dir}/src/Install.txt\" \"$gsdlhome\"]"
417    echo "$msg"
418    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
419    $cmd_cp "${cd_dir}/src/Install.txt" "$gsdlhome"
420    msg="--> Install.sh: [$cmd_chmod -R u+rw \"$gsdlhome\"]"
421    echo "$msg"
422    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
423    $cmd_chmod -R u+rw "$gsdlhome"
424    msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/configure\"]"
425    echo "$msg"
426    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
427    $cmd_chmod a+x "${gsdlhome}/configure"
428    msg="--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/packages/yaz/configure\"]"
429    echo "$msg"
430    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
431    $cmd_chmod a+x "${gsdlhome}/packages/yaz/configure"
432
433    # compile it
434    msg="--> Install.sh: [cd $gsdlhome]"
435    echo "$msg"
436    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
437    cd "$gsdlhome"
438    msg="configuring ...
439
440--> Install.sh: [./configure]"
441    echo "$msg"
442    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
443    ./configure
444    msg="compiling ...
445
446--> Install.sh: [make]"
447    echo "$msg"
448    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
449    make
450    msg="installing ...
451
452--> Install.sh: [make install]"
453    echo "$msg"
454    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
455    make install
456    msg="--> Install.sh: [cd $thisdir]"
457    echo "$msg"
458    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
459    cd "$thisdir"
460
461    # check that things compiled ok
462    if [ ! -f "${gsdlhome}/cgi-bin/library" ]; then
463    msg="
464ERROR: Compilation failed
465Greenstone was not installed successfully
466Run the uninstall script (${gsdlhome}/Uninstall.sh)
467to clean up the partial installation."
468    echo "$msg"
469    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
470    exit 1
471    fi
472fi
473
474
475# try to find out hostname
476if [ "$gsdlos" = "linux" ]; then
477    hostname=`hostname -f`
478    if [ "$hostname" = "" ]; then
479    hostname=`hostname -i`
480    fi
481fi
482if [ "$hostname" = "" ]; then
483    hostname=`hostname`
484fi
485if [ "$hostname" = "" ]; then
486    hostname="your-computer-name"
487fi
488
489
490# get cgi-bin directory
491msg="
492
493Greenstone needs a valid cgi executable directory (normally called
494cgi-bin on unix systems) from which to run.
495This may be either:
496 1. The default Greenstone cgi-bin directory (${gsdlhome}/cgi-bin).
497    If you use the Greenstone default you will need to configure
498    your webserver to treat this directory as a cgi executable
499    directory. For the Apache webserver you use the ScriptAlias
500    directive to do this (details of how to configure your webserver
501    will be displayed at the end of this installation procedure)."
502echo "$msg"
503echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
504if [ "$logname" != "root" ]; then
505    msg="    Note that you will probably need help from your system
506    administrator to reconfigure your webserver."
507    echo "$msg"
508    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
509fi
510msg=" 2. An existing cgi-bin directory. Normally a cgi-bin directory
511    is created when your webserver is installed. Typically, this
512    might be /home/httpd/cgi-bin, or /usr/local/apache/cgi-bin, or
513    /var/lib/apache/cgi-bin."
514echo "$msg"
515echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
516if [ "$logname" != "root" ]; then
517    msg="    Many systems also allow individual users to have their own
518    cgi-bin in /home/username/public_html/cgi-bin."
519    echo "$msg"
520    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
521fi
522found=no
523remind_cgi="no"
524remind_cgi_nomove="no"
525while [ "$found" = "no" ]; do
526    msg="Enter \"[1]\" or \"2\""
527    echo "$msg"
528    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
529    printf "%s" "> "
530    read ans
531    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
532    if [ "$ans" = "" ] || [ "$ans" = "1" ]; then
533    found="option1"
534    cgi_bin="${gsdlhome}/cgi-bin"
535    # default gsdl cgi-bin, do nothing
536    msg="
537Don't forget to configure your webserver to treat $cgi_bin
538as a cgi executable directory. Don't worry, you'll be
539reminded of this again at the end of the installation
540procedure"
541    echo "$msg"
542    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
543    remind_cgi="yes"
544    elif [ "$ans" = "2" ]; then
545    found="option2"
546    # external cgi-bin
547    msg="
548Enter existing cgi executable directory [/usr/local/apache/cgi-bin]"
549    echo "$msg"
550    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
551    printf "%s" "> "
552    read ans
553    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
554    if [ "$ans" = "" ]; then
555        cgi_bin="/usr/local/apache/cgi-bin"
556    else
557        cgi_bin="$ans"
558    fi
559    if [ ! -d "$cgi_bin" ]; then
560        msg="Warning: The ${cgi_bin} directory does not exist.
561Create it? [y]"
562        echo "$msg"
563        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
564        printf "%s" "> "
565        read ans
566        echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
567        if [ "$ans" = "" ] || [ "$ans" = "y" ]; then
568        msg="--> Install.sh: [$cmd_mkdir \"$cgi_bin\"]"
569        echo "$msg"
570        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
571        $cmd_mkdir "$cgi_bin"
572        if [ -d "$cgi_bin" ]; then
573            msg="Don't forget to configure your webserver to treat $cgi_bin
574as a cgi executable directory. Don't worry, you'll be
575reminded of this again at the end of the installation
576procedure"
577            echo "$msg"
578            echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
579            remind_cgi="yes"
580        else
581            msg="ERROR: failed to create $cgi_bin directory
582Greenstone installation failed.
583Run the uninstall script (${gsdlhome}/Uninstall.sh)
584to clean up the partial installation."
585            echo "$msg"
586            echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
587            exit 1
588        fi
589        fi
590    fi
591
592    if [ ! -w "$cgi_bin" ]; then
593        msg="
594Unable to write to $cgi_bin directory. You will need
595to copy the contents of ${gsdlhome}/cgi-bin
596to $cgi_bin after this installation is completed.
597You'll be reminded of this again at the end of the
598installation procedure."
599        echo "$msg"
600        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
601        remind_cgi_nomove="yes"
602    else
603        # install cgi-bin stuff (update the uninstall script first)
604        cd "$gsdlhome"
605        echo "#!/bin/sh" > Uninstall.sh
606        echo "" >> Uninstall.sh
607        echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> Uninstall.sh
608        echo "$cmd_rm \"${cgi_bin}/library\"" >> Uninstall.sh
609        echo "echo \"remove ${gsdlhome} directory? [y]\"" >> Uninstall.sh
610        echo "read ans" >> Uninstall.sh
611        echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> Uninstall.sh
612        echo "   $cmd_rmr \"$gsdlhome\"" >> Uninstall.sh
613        echo "fi" >> Uninstall.sh
614        $cmd_chmod u+x Uninstall.sh
615        cd "$thisdir"
616
617        msg="
618Installing Greenstone cgi programs in $cgi_bin
619--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/gsdlsite.cfg\" \"$cgi_bin\"]"
620        echo "$msg"
621        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
622        $cmd_mv "${gsdlhome}/cgi-bin/gsdlsite.cfg" "$cgi_bin"
623        msg="--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/library\" \"$cgi_bin\"]"
624        echo "$msg"
625        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
626        $cmd_mv "${gsdlhome}/cgi-bin/library" "$cgi_bin"
627    fi
628    fi
629done
630
631# web address of cgi-bin
632web_cgi="http://${hostname}/cgi-bin"
633if [ "$found" = "option1" ]; then
634    web_cgi="http://${hostname}/gsdl/cgi-bin"
635fi
636msg="
637Please enter the web address of the $cgi_bin
638directory. Typically this might be http://localhost/cgi-bin,
639or http://127.0.0.1/cgi-bin, or http://your-computer-name/cgi-bin,
640or http://nnn.nnn.nnn.nn/cgi-bin. [$web_cgi]"
641echo "$msg"
642echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
643printf "%s" "> "
644read ans
645echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
646if [ "$ans" != "" ]; then
647    web_cgi="$ans"
648fi
649
650# get public_html directory
651msg="
652
653In order for Greenstone to run, the $gsdlhome
654directory and all it contains must be accessible from the web.
655To make this happen you may either:
656 1. Configure your webserver so that $gsdlhome
657    is itself accessible from the web."
658echo "$msg"
659echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
660if [ "$logname" != "root" ]; then
661    msg="    Note that you will probably need help from your system
662    administrator to reconfigure your webserver."
663    echo "$msg"
664    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
665fi
666msg=" 2. Provide an existing web accessible directory from which
667    a symbolic link (ln -s) will be made to $gsdlhome.
668    When your server was installed a web accessible directory
669    will have been created (the Apache webserver uses the
670    DocumentRoot directive to define this directory). Typically
671    this directory might be /home/httpd/html, or /usr/local/apache/htdocs,
672    or /var/lib/apache/htdocs."
673echo "$msg"
674echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
675if [ "$logname" != "root" ]; then
676    msg="    Many systems also allow individual users to have their own
677    web accessible directory in /home/username/public_html."
678    echo "$msg"
679    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
680fi
681msg="    Note that your web server will need to be configured to allow
682    symbolic links from within this directory. For the Apache
683    server that means this directory must be configured with
684    the SymLinksIfOwnerMatch or FollowSymLinks option (most Apache
685    installations are configured this way by default)."
686echo "$msg"
687echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
688found="no"
689remind_ph="no"
690remind_ph_nolink="no"
691while [ "$found" = "no" ]; do
692    msg="Enter \"[1]\" or \"2\""
693    echo "$msg"
694    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
695    printf "%s" "> "
696    read ans
697    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
698    if [ "$ans" = "" ] || [ "$ans" = "1" ]; then
699    found="yes"
700    public_html="$gsdlhome"
701    # no link
702    msg="
703Don't forget to configure your webserver to make $gsdlhome
704accessible from the web. You'll be reminded of this again
705at the end of this installation procedure."
706    echo "$msg"
707    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
708    remind_ph="yes"
709    elif [ "$ans" = "2" ]; then
710    found="yes"
711    # external public_html
712    echo
713    public_html="/home/${logname}/public_html"
714    if [ "$logname" = "root" ]; then
715        public_html="/usr/local/apache/htdocs"
716    fi
717    msg="Enter directory that is also accessible from the web [${public_html}]"
718    echo "$msg"
719    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
720    printf "%s" "> "
721    read ans
722    echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
723    if [ "$ans" != "" ]; then
724        public_html="$ans"
725    fi
726    # create link to gsdl (and update Uninstall.sh)
727    if [ -w "$public_html" ]; then
728        cd "$gsdlhome"
729        echo "#!/bin/sh" > Uninstall.sh
730        echo "" >> Uninstall.sh
731        echo "$cmd_rm \"$public_html/gsdl\"" >> Uninstall.sh
732        echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> Uninstall.sh
733        echo "$cmd_rm \"${cgi_bin}/library\"" >> Uninstall.sh
734        echo "echo \"remove ${gsdlhome} directory? [y]\"" >> Uninstall.sh
735        echo "read ans" >> Uninstall.sh
736        echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> Uninstall.sh
737        echo "   $cmd_rmr \"$gsdlhome\"" >> Uninstall.sh
738        echo "fi" >> Uninstall.sh
739        $cmd_chmod u+x Uninstall.sh
740        cd "$thisdir"
741
742        msg="--> Install.sh: [cd \"$public_html\"]"
743        echo "$msg"
744        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
745        cd "$public_html"
746        msg="--> Install.sh: [$cmd_ln \"$gsdlhome\" gsdl]"
747        echo "$msg"
748        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
749        $cmd_ln "$gsdlhome" gsdl
750        msg="--> Install.sh: [cd \"$thisdir\"]"
751        echo "$msg"
752        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
753        cd "$thisdir"
754    else
755        msg="
756Unable to write to $public_html directory. You will need
757to create a link called gsdl from $public_html to
758$gsdlhome after this installation is completed. You'll be
759reminded of this again at the end of the installation
760procedure."
761        echo "$msg"
762        echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
763        old_ph=$public_html
764        remind_ph_nolink="yes"
765    fi
766    public_html="${public_html}/gsdl"
767    fi
768done
769
770
771# get httpprefix
772msg="
773Enter the web address of the $public_html directory.
774This may be a relative url (e.g. \"/gsdl\") or a
775complete url (e.g. \"http://${hostname}/gsdl\") [/gsdl]"
776echo "$msg"
777echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
778printf "%s" ">"
779httpprefix="/gsdl"
780read ans
781echo "> $ans" >> "${gsdlhome}/INSTALL_RECORD"
782if [ "$ans" != "" ]; then
783    httpprefix="$ans"
784fi
785
786# get initial password
787msg="
788In order to use end-user collection building or to access certain
789parts of the administration pages you must have a password.
790A user with the username \"admin\" will be created for you with
791the password you provide (i.e. to enter any pages requiring user
792authentication enter the \"admin\" username and the password you
793set here).\n";
794echo "$msg"
795echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
796pw=`${gsdlhome}/bin/${gsdlos}/getpw`
797tmp="[admin]
798<comment>
799<enabled>true
800<groups>administrator,colbuilder
801<password>${pw}
802<username>admin
803----------------------------------------------------------------------"
804echo "$tmp" | ${gsdlhome}/bin/${gsdlos}/txt2db "${gsdlhome}/etc/users.db"
805$cmd_chmod a+rw "${gsdlhome}/etc/users.db"
806
807# edit gsdlsite.cfg
808cd "$cgi_bin"
809sed "s|\(gsdlhome  *\)[^ ]*|\1${gsdlhome}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
810sed "s|#*\(httpprefix  *\)[^ ]*|\1${httpprefix}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
811sed "s|\(httpimg  *\)[^ ]*|\1${httpprefix}/images|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg
812
813msg="
814
815Greenstone installation completed successfully."
816echo "$msg"
817echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
818if [ "$remind_cgi" = "yes" ]; then
819    msg="  * Don't forget to configure your webserver to treat
820    $cgi_bin as a cgi executable directory."
821    echo "$msg"
822    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
823
824    apache_web_cgi=`echo "$web_cgi" | sed "s|[^/]*//[^/]*||" | sed "s|/*$|/|"`
825    cgi_bin_slash=`echo "$cgi_bin" | sed "s|/*$|/|"`
826    cgi_bin_noslash=`echo "$cgi_bin" | sed "s|/*$||"`
827
828    msg="    For the Apache webserver this means adding the following
829    ScriptAlias directive to your httpd.conf configuration file.
830
831     ScriptAlias ${apache_web_cgi} \"${cgi_bin_slash}\"
832     <Directory \"${cgi_bin_noslash}\">
833         AllowOverride None
834         Options None
835         Order allow,deny
836         Allow from all
837     </Directory>
838"
839    echo "$msg"
840    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
841fi
842if [ "$remind_cgi_nomove" = "yes" ]; then
843    msg="  * Don't forget to move the contents of ${gsdlhome}/cgi-bin
844    to $cgi_bin
845"
846    echo "$msg"
847    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
848fi
849if [ "$remind_ph" = "yes" ]; then
850    msg="  * Don't forget to configure your webserver to treat
851    $gsdlhome as a web accessible directory."
852    echo "$msg"
853    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
854   
855    apache_httpprefix=`echo "$httpprefix" | sed "s|[^/]*//[^/]*||" | sed "s|/*$|/|"`
856    public_html_slash=`echo "$public_html" | sed "s|/*$|/|"`
857    public_html_noslash=`echo "$public_html" | sed "s|/*$||"`
858   
859    msg="    For the Apache webserver this means adding the following
860    Alias directive to your httpd.conf configuration file.
861
862     Alias ${apache_httpprefix} \"${public_html_slash}\"
863     <Directory \"${public_html_noslash}\">
864         Options Indexes MultiViews FollowSymLinks
865         AllowOverride None
866         Order allow,deny
867         Allow from all
868     </Directory>
869"
870    echo "$msg"
871    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
872fi
873if [ "$remind_ph_nolink" = "yes" ]; then
874    msg="  * Don't forget to create a link called gsdl from $old_ph
875    to ${gsdlhome}.
876"
877    echo "$msg"
878    echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
879fi
880msg="The output of this script has been recorded for you at
881${gsdlhome}/INSTALL_RECORD.
882You may remove Greenstone from your system at any time by running
883the ${gsdlhome}/Uninstall.sh script.
884Access Greenstone by pointing a web browser at
885${web_cgi}/library
886"
887echo "$msg"
888echo "$msg" >> "${gsdlhome}/INSTALL_RECORD"
889
890exit 0
Note: See TracBrowser for help on using the browser.