1 | #!/bin/sh
|
---|
2 |
|
---|
3 | ## Install.sh -- Install the Gatherer
|
---|
4 |
|
---|
5 |
|
---|
6 | # script must be run from within the directory in which it lives
|
---|
7 | thisdir=`pwd`
|
---|
8 | if [ ! -f "${thisdir}/Install.sh" ]; then
|
---|
9 | echo "Install.sh must be run from the directory in which it resides"
|
---|
10 | exit 1
|
---|
11 | fi
|
---|
12 |
|
---|
13 |
|
---|
14 | # see if we can find java
|
---|
15 | java="java"
|
---|
16 |
|
---|
17 | # if JAVAHOME is set we'll use it to determine where java lives, otherwise
|
---|
18 | # we just hope it's on the search path
|
---|
19 | if [ "$JAVAHOME" != "" ] ; then
|
---|
20 | java="$JAVAHOME/bin/java"
|
---|
21 | else
|
---|
22 | java=`which java 2> /dev/null`
|
---|
23 | if [ ! -x "$java" ]; then
|
---|
24 | echo "Failed to locate Java. You must install a java runtime environment"
|
---|
25 | echo "(version 1.4 or greater) before installing the Gatherer."
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 | fi
|
---|
29 |
|
---|
30 | javaversion=`$java -version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'`
|
---|
31 | jvmajor=`echo $javaversion | sed -n 's/^\([0-9]*\).*$/\1/p'`
|
---|
32 | jvminor=`echo $javaversion | sed -n 's/^[0-9]*\.\([0-9]*\).*$/\1/p'`
|
---|
33 | jok=1
|
---|
34 | if [ $jvmajor -lt 1 ] ; then
|
---|
35 | jok=0
|
---|
36 | fi
|
---|
37 | if [ $jvmajor -eq 1 ] && [ $jvminor -lt 3 ] ; then
|
---|
38 | jok=0
|
---|
39 | fi
|
---|
40 | if [ $jok -eq 0 ] ; then
|
---|
41 | echo "The version of the java runtime environment you have installed is too"
|
---|
42 | echo "old to run the Gatherer. Please install a new version of the JRE (version"
|
---|
43 | echo "1.4 or newer) and rerun this installation."
|
---|
44 | exit 1
|
---|
45 | fi
|
---|
46 |
|
---|
47 |
|
---|
48 | # make sure perl is ok
|
---|
49 | perl=`which perl 2> /dev/null`
|
---|
50 | echo "perl: $perl"
|
---|
51 | if [ ! -x "$perl" ] ; then
|
---|
52 | echo "The Gatherer requires perl in order to operate but this installation"
|
---|
53 | echo "could not detect perl on your system. Please ensure that perl is installed"
|
---|
54 | echo "and is on your search path then rerun this installation script."
|
---|
55 | exit 1
|
---|
56 | fi
|
---|
57 |
|
---|
58 |
|
---|
59 | # Try to find greenstone - greenstone defaults to being installed to
|
---|
60 | # either /usr/local/gsdl (if installed as root) or ~/gsdl. We'll look
|
---|
61 | # there first
|
---|
62 | gsdlhome=
|
---|
63 | if [ -d "/usr/local/gsdl" ] ; then
|
---|
64 | gsdlhome="/usr/local/gsdlhome"
|
---|
65 | fi
|
---|
66 | gsdlos=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
---|
67 | if [ "$gsdlos" = "linux" ]; then
|
---|
68 | logname=`whoami`
|
---|
69 | else
|
---|
70 | logname=`logname`
|
---|
71 | fi
|
---|
72 | if [ -d "/home/${logname}/gsdl" ] ; then
|
---|
73 | gsdlhome="/home/${logname}/gsdl"
|
---|
74 | fi
|
---|
75 |
|
---|
76 | if [ "$GSDLHOME" != "" ] ; then
|
---|
77 | gsdlhome=$GSDLHOME
|
---|
78 | fi
|
---|
79 |
|
---|
80 | if [ "$gsdlhome" != "" ] ; then
|
---|
81 | echo "A Greenstone installation has been detected at ${gsdlhome}."
|
---|
82 | echo "To use this Greenstone installation with the Gatherer hit enter."
|
---|
83 | echo "To use an alternative Greenstone installation enter the path to"
|
---|
84 | echo "that installation now and hit enter"
|
---|
85 | printf "%s" "> "
|
---|
86 | read ans
|
---|
87 | if [ "$ans" != "" ] ; then
|
---|
88 | gsdlhome="$ans"
|
---|
89 | fi
|
---|
90 | else
|
---|
91 | echo "No Greenstone installation could be detected. If you have Greenstone"
|
---|
92 | echo "installed please enter the full path to your gsdl directory and hit"
|
---|
93 | echo "enter. If you don't have Greenstone installed please exit this"
|
---|
94 | echo "installation script by hitting ctrl-c and install Greenstone before"
|
---|
95 | echo "installing the Gatherer."
|
---|
96 | printf "%s" "> "
|
---|
97 | read ans
|
---|
98 | gsdlhome="$ans"
|
---|
99 | fi
|
---|
100 | # check the the given greenstone installation looks ok
|
---|
101 | if [ ! -x "${gsdlhome}/bin/script/import.pl" ] ; then
|
---|
102 | echo "The Greenstone installation at ${gsdlhome} does not"
|
---|
103 | echo "appear to be complete. Try reinstalling Greenstone then running"
|
---|
104 | echo "the install script again."
|
---|
105 | exit 1
|
---|
106 | fi
|
---|
107 |
|
---|
108 |
|
---|
109 | # ask the installer for the http path to their greenstone installation
|
---|
110 | echo "Please enter the http path to your Greenstone installation's"
|
---|
111 | echo "library cgi program. Typically this might be"
|
---|
112 | echo "http://localhost/cgi-bin/library,"
|
---|
113 | echo "or http://localhost:8080/cgi-bin/library,"
|
---|
114 | echo "or http://127.0.0.1/cgi-bin/library,"
|
---|
115 | echo "or http://your-computer-name/cgi-bin/library,"
|
---|
116 | echo "or http://nnn.nnn.nnn.nn/cgi-bin/library."
|
---|
117 | printf "%s" "> "
|
---|
118 | read ans
|
---|
119 | librarypath="$ans"
|
---|
120 | # don't include leading "http://" or trailing "library" in library path
|
---|
121 | librarypath=`echo "$librarypath" | sed 's|^http://||'`
|
---|
122 | librarypath=`echo "$librarypath" | sed 's|library$||'`
|
---|
123 |
|
---|
124 | # finally, edit the Gatherer shell script
|
---|
125 | sed "s|\*\*GSDLHOME\*\*|${gsdlhome}|" Gatherer > tmp123.txt && mv tmp123.txt Gatherer
|
---|
126 | sed "s|\*\*LIBRARYPATH\*\*|${librarypath}|" Gatherer > tmp123.txt && mv tmp123.txt Gatherer
|
---|
127 |
|
---|
128 | chmod u+x Gatherer
|
---|
129 |
|
---|
130 | echo "Greenstone Librarian Interface - Installation Complete!"
|
---|
131 | echo "Change to the directory 'gli' and run './Gatherer' to start the application."
|
---|
132 |
|
---|
133 | exit 0
|
---|