]> git.evergreen-ils.org Git - working/Evergreen.git/blob - install.sh
making the install script break out opensrf, openils, and evergreen a little
[working/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 # install targets
113 #
114 # opensrf_jserver - custom 'single-domain' jabber server which may be used in place of jabberd2
115 # opensrf_router  - jabber router.  
116 # opensrf_gateway - mod_ils_gateway, Apache module for proxying API calls
117 # opensrf_srfsh   - diagnostic shell interface to OpenSRF
118 # opensrf_perl          - install the OpenSRF perl modules
119 # opensrf_all           - builds all OpenSRF compenents
120 # openils_marcdumper - utility code for converting MARC to MARCXML
121 # openils_perl                  - install the Open-ILS perl modules
122 # openils_all                   - builds all OpenILS compenents
123 # openils_web                   - copies over the javascript and html templates to the web root directory
124 # evergreen_xul_client   - client XUL application
125 # evergreen_all - builds all Evergreen components
126 function runInstall {
127
128
129
130         # pass the collected variables to make
131         for target in ${TARGETS[@]:0}; do
132
133                 cat <<-MSG
134
135                 --------------------------------------------------------------------
136                 Building $target
137                 --------------------------------------------------------------------
138
139                 MSG
140
141                 MAKE="make APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP \
142                         APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS \
143                         BINDIR=$BINDIR LIBDIR=$LIBDIR PERLDIR=$PERLDIR INCLUDEDIR=$INCLUDEDIR";
144
145                 case "$target" in
146         
147                         # OpenSRF ---                   
148
149                         "opensrf_all")
150                                 if building;    then $MAKE -C "$OPENSRF_DIR" all; fi;
151                                 if installing; then $MAKE -C "$OPENSRF_DIR" install; fi;
152                                 ;;
153
154                         "opensrf_jserver" )
155                                 if building;    then $MAKE -C "$OPENSRF_DIR" "jserver"; fi;
156                                 if installing; then $MAKE -C "$OPENSRF_DIR" "jserver-install"; fi;
157                                 ;;      
158
159                         "opensrf_router" ) 
160                                 if building;    then $MAKE -C "$OPENSRF_DIR" "router"; fi;
161                                 if installing; then $MAKE -C "$OPENSRF_DIR" "router-install"; fi;
162                                 ;;
163
164                         "opensrf_gateway" )
165                                 if building;    then $MAKE -C "$OPENSRF_DIR" "gateway"; fi;
166                                 if installing; then $MAKE -C "$OPENSRF_DIR" "gateway-install"; fi;
167                                 ;;
168
169                         "opensrf_srfsh" ) 
170                                 if building;    then $MAKE -C "$OPENSRF_DIR" "srfsh"; fi;
171                                 if installing; then $MAKE -C "$OPENSRF_DIR" "srfsh-install"; fi;
172                                 ;;
173
174                         "opensrf_perl")
175                                 if installing; then $MAKE -C "$OPENSRF_DIR" "perl-install"; fi;
176                                 ;;
177
178
179                         # OpenILS ---                   
180
181                         "openils_all")
182                                 if building;    then $MAKE -C "$OPENILS_DIR" all; fi;
183                                 if installing; then $MAKE -C "$OPENILS_DIR" install; fi;
184                                 ;;
185
186                         "openils_perl")
187                                 if installing; then $MAKE -C "$OPENILS_DIR" "perl-install"; fi;
188                                 ;;
189
190
191                         # Evergreen ---                         
192
193                         "evergreen_xul_client")
194                                 if building;    then $MAKE -C "$EVERGREEN_DIR" xul; fi;
195                                 ;;
196
197
198                         *) fail "Unknown target: $target";;
199
200                 esac
201
202         done
203 }
204
205
206 # --------------------------------------------------------------------
207 # Checks command line parameters for special behavior
208 # Supported params are:
209 # clean - cleans all build files
210 # build - builds the specified sources
211 # install - installs the specified sources
212 # --------------------------------------------------------------------
213 function checkParams {
214
215         if [ -z "$1" ]; then return; fi;
216
217         for arg in "$@"; do
218
219                 lastArg="$arg";
220
221                 case "$arg" in
222
223                         "clean") 
224                                 cleanMe;;
225
226                         "build")
227                                 BUILDING="1";;
228
229                         "install")
230                                 INSTALLING="1";;
231
232                         *) fail "Unknown command line argument: $arg";;
233                 esac
234         done
235
236         if [ "$lastArg" = "clean" ]; then exit 0; fi;
237 }
238
239
240 function cleanMe {
241         loadConfig;
242         make -C "$OPENSRF_DIR" clean;
243         make -C "$OPENILS_DIR"  clean;
244         make -C "$EVERGREEN_DIR" clean;
245 }
246
247 checkParams "$@";
248
249
250 if building; then echo "Building..."; fi;
251 if installing; then echo "Installing..."; fi;
252
253
254 # --------------------------------------------------------------------
255 # Kick it off...
256 # --------------------------------------------------------------------
257 loadConfig;
258 mkInstallDirs;
259 runInstall;
260
261
262