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