]> git.evergreen-ils.org Git - Evergreen.git/blob - install.sh
adding circ id to the all_circs view; adding BEFORE DELETE trigger to perform aging
[Evergreen.git] / install.sh
1 #!/bin/bash
2 # vim:noet:ts=4
3 # --------------------------------------------------------------------
4 # Copyright (C) 2005  Georgia Public Library Service 
5 # Bill Erickson <highfalutin@gmail.com>
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 # --------------------------------------------------------------------
17
18
19 # --------------------------------------------------------------------
20 # ILS install script
21 # --------------------------------------------------------------------
22 CONFIG_FILE="install.conf";
23 DEFAULT_CONFIG_FILE="install.conf.default";
24 verbose="-s" #clear this to get full build output
25
26
27 # --------------------------------------------------------------------
28 # Loads all of the path information from the user setting 
29 # install variables as it goes
30 # --------------------------------------------------------------------
31
32 function fail {
33         MSG="$1";
34         echo "A build error occured: $MSG";
35         exit 99;
36 }
37
38
39 #function postMessage {
40
41 #cat <<-WORDS
42 #       --------------------------------------------------------------------
43
44
45 #}
46
47
48
49 # --------------------------------------------------------------------
50 # Makes sure the install directories exist and are writable
51 # --------------------------------------------------------------------
52
53 function mkDir {
54         mkdir -p "$1";
55         [ "$?" != "0" ] && fail "Error creating $1";
56         [ ! -w "$1" ] && fail "We don't have write access to $1";
57 }
58
59 function mkInstallDirs {
60
61         installing      && mkDir "$PREFIX";
62         building        && mkDir "$TMP";
63         installing      && mkDir "$SOCK";
64         installing      && mkDir "$PID";
65         installing      && mkDir "$LOG";
66
67
68         # add the opensrf user and group
69          if installing; then
70                 if [ ! $(grep "^opensrf:" /etc/group) ]; then groupadd opensrf; fi
71                 if [ ! $(grep "^opensrf:" /etc/passwd) ]; then useradd -g opensrf opensrf; fi
72         fi;
73
74 }
75
76 function installing {
77         if [ -z "$INSTALLING" ]; then return 1; fi;
78         return 0;
79 }
80
81 function building {
82         if [ -z "$BUILDING" ]; then return 1; fi;
83         return 0;
84 }
85
86 function testing {
87         if [ -z "$TESTING" ]; then return 1; fi;
88         return 0;
89 }
90
91
92 # --------------------------------------------------------------------
93 # Loads the config file.  If it can't fine CONFIG_FILE, it attempts to
94 # use DEFAULT_CONFIG_FILE.  If it can't find that, it fails.
95 # --------------------------------------------------------------------
96 function loadConfig {
97         if [ ! -f "$CONFIG_FILE" ]; then
98                 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
99                         echo "+ + + Copying $DEFAULT_CONFIG_FILE to $CONFIG_FILE and using its settings...";
100                         cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE";
101                 else
102                         fail "config file \"$CONFIG_FILE\" cannot be found";
103                 fi
104         fi
105         source "$CONFIG_FILE";
106 }
107
108
109
110
111 function runInstall {
112
113         # pass the collected variables to make
114         for target in ${TARGETS[@]:0}; do
115
116                 echo ""
117                 echo "-------------- [ $target ] -------------------------------------------";
118                 echo ""
119
120                 MAKE="make $verbose APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP APR_HEADERS=$APR_HEADERS \
121                         APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS DBPORT=$DBPORT\
122                         BINDIR=$BINDIR DBI_LIBS=$DBI_LIBS LIBDIR=$LIBDIR PERLDIR=$PERLDIR EG_PYTHON_INSTALL=$EG_PYTHON_INSTALL INCLUDEDIR=$INCLUDEDIR \
123                         WEBDIR=$WEBDIR TEMPLATEDIR=$TEMPLATEDIR ETCDIR=$ETCDIR REPORTERDIR=$REPORTERDIR\
124                         OPENSRF_HEADERS=$OPENSRF_HEADERS OPENSRF_LIBS=$OPENSRF_LIBS OPENILSDIR=$OPENILSDIR EVERGREENDIR=$EVERGREENDIR \
125                         CIRCRULESDIR=$CIRCRULESDIR CATALOGSCRIPTDIR=$CATALOGSCRIPTDIR CGIDIR=$CGIDIR \
126                         DBDRVR=$DBDRVR DBHOST=$DBHOST DBVER=$DBVER DATADIR=$DATADIR ADMINDIR=$ADMINDIR\
127                         PENALTYRULESDIR=$PENALTYRULESDIR DBNAME=$DBNAME DBUSER=$DBUSER DBPW=$DBPW XSLDIR=$XSLDIR NEW_OPAC_URL=$NEW_OPAC_URL \
128                         NEW_XUL_PACKAGE_NAME=$NEW_XUL_PACKAGE_NAME NEW_XUL_PACKAGE_LABEL=$NEW_XUL_PACKAGE_LABEL";
129
130
131                 case "$target" in
132         
133                         # OpenILS ---                   
134
135                         "openils_all" )
136                                 if building;    then $MAKE -C "$OPENILSDIR" all; fi;
137                                 if testing;             then $MAKE -C "$OPENILSDIR/../examples" test; fi;
138                                 if installing; then $MAKE -C "$OPENILSDIR" install; fi;
139                                 ;;
140
141                         "openils_core" )
142                                 if building; then 
143                                         $MAKE -C "$OPENILSDIR" "c_apps";
144                                         $MAKE -C "$OPENILSDIR" "python-build";
145                                 fi;
146                                 if installing; then 
147                                         $MAKE -C "$OPENILSDIR" "perl-install"; 
148                                         $MAKE -C "$OPENILSDIR" "python-install"; 
149                                         $MAKE -C "$OPENILSDIR" "string-templates-install"; 
150                                         $MAKE -C "$OPENILSDIR" "xsl-install"; 
151                                         $MAKE -C "$OPENILSDIR" "c_apps-install"; 
152                                         $MAKE -C "$OPENILSDIR" "circ_rules-install"; 
153                                         $MAKE -C "$OPENILSDIR" "autojs-install"; 
154                                 fi;
155                                 ;;
156
157                         "openils_web" )
158                                 if building; then $MAKE -C "$OPENILSDIR" "mod_xmlent"; fi;
159                                 #if building; then $MAKE -C "$OPENILSDIR" "mod_ils_rest_gateway"; fi;
160                                 if installing; then
161                                         $MAKE -C "$OPENILSDIR" "web-install";
162                                         $MAKE -C "$OPENILSDIR" "cgi-bootstrap";
163                                         $MAKE -C "$OPENILSDIR" "reporter-install";
164                                 fi;
165                                 ;;
166
167                         "openils_marcdumper" )
168                                 if building;    then $MAKE -C "$OPENILSDIR" "marcdumper"; fi;
169                                 if installing; then $MAKE -C "$OPENILSDIR" "marcdumper-install"; fi;
170                                 ;;
171
172                         "openils_db" )
173                                 if installing; then 
174                                         $MAKE -C "$OPENILSDIR" "storage-bootstrap"; 
175                                 fi;
176                                 ;;
177
178                         "openils_reporter" )
179                                 if installing; then 
180                                         $MAKE -C "$OPENILSDIR" "reporter-install";
181                                 fi;
182                                 ;;
183
184                         "openils_client_xul" )
185                                 if building; then
186                                         $MAKE -C "$OPENILSDIR" "client-xul";
187                                 fi;
188                                 ;;
189
190                         "openils_server_xul" )
191                                 if installing; then
192                                         $MAKE -C "$OPENILSDIR" "server-xul";
193                                 fi;
194                                 ;;
195
196                         # Evergreen ---                         
197
198                         "evergreen_core" )
199                                 if installing;  then $MAKE -C "$EVERGREENDIR" "install"; fi;
200                                 ;;      
201
202                         "evergreen_xul_client" )
203                                 if building;    then $MAKE -C "$EVERGREENDIR" xul; fi;
204                                 ;;
205
206
207                         *) fail "Unknown target: $target";;
208
209                 esac
210
211         done
212
213         if installing; then
214                 echo -e "\nNow run: chown -R opensrf:opensrf $PREFIX"
215         fi
216 }
217
218
219 # --------------------------------------------------------------------
220 # Checks command line parameters for special behavior
221 # Supported params are:
222 # clean - cleans all build files
223 # build - builds the specified sources
224 # install - installs the specified sources
225 # test - tests the specified sources
226 # --------------------------------------------------------------------
227 function checkParams {
228
229         if [ -z "$1" ]; then usage; fi;
230
231         for arg in "$@"; do
232
233                 lastArg="$arg";
234
235                 case "$arg" in
236
237                         "clean") 
238                                 cleanMe;;
239
240                         "build")
241                                 BUILDING="1";;
242
243                         "install")
244                                 INSTALLING="1";;
245                         
246                         "verbose")
247                                 verbose="";;
248
249                         "test")
250                                 TESTING="1";;
251
252                         *) fail "Unknown option => $arg";
253                 esac
254         done
255
256         if [ "$lastArg" = "clean" ]; then exit 0; fi;
257 }
258
259
260 function cleanMe {
261         loadConfig;
262         make "TMP=$TMP" -s -C "$OPENILSDIR"  clean;
263         make "TMP=$TMP" -s -C "$EVERGREENDIR" clean;
264         make "TMP=$TMP" -s -C "$OPENILSDIR/../xul/staff_client"  clean;
265 }
266
267 function usage {
268         echo "usage: $0 [ build | install | clean ]";
269         exit;
270 }
271
272 checkParams "$@";
273
274 if building; then echo "Building..."; fi;
275 if testing; then echo "Testing..."; fi;
276 if installing; then echo "Installing..."; fi;
277
278
279 # --------------------------------------------------------------------
280 # Kick it off...
281 # --------------------------------------------------------------------
282 loadConfig;
283 mkInstallDirs;
284 runInstall;
285