]> git.evergreen-ils.org Git - Evergreen.git/blob - config.sh
preferred language and date filter fixes
[Evergreen.git] / config.sh
1 #!/bin/bash
2 # --------------------------------------------------------------------
3 # Copyright (C) 2005  Georgia Public Library Service 
4 # Bill Erickson <highfalutin@gmail.com>
5 # Mike Rylander <mrylander@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 # Prompts the user for config settings and writes a custom config
21 # file based on these settings
22 # --------------------------------------------------------------------
23
24
25 CONFIG_FILE="install.conf";
26 DEFAULT_CONFIG_FILE="install.conf.default";
27 USE_DEFAULT="$1";
28
29 function buildConfig {
30
31         if [ -f "$CONFIG_FILE" ]; then
32                 source "$CONFIG_FILE";
33         else
34                 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
35                         source "$DEFAULT_CONFIG_FILE";
36                 fi;
37         fi;
38
39     if [ -n "$USE_DEFAULT" ]; then
40         prompt "Default config requested, not prompting for values...\n";
41         writeConfig;
42         return 0;
43     fi;
44
45
46         echo "";
47         echo "-----------------------------------------------------------------------";
48         echo "Type Enter to select the default"
49         echo "-----------------------------------------------------------------------";
50
51         prompt "Install prefix [$PREFIX] ";
52         read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
53
54         BINDIR="$PREFIX/bin/";
55         LIBDIR="$PREFIX/lib/";
56         PERLDIR="$LIBDIR/perl5/";
57         INCLUDEDIR="$PREFIX/include/";
58         ETCDIR="$PREFIX/conf";
59         WEBDIR="$PREFIX/var/web";
60         DATADIR="$PREFIX/var/data";
61         CGIDIR="$PREFIX/var/cgi-bin";
62         TEMPLATEDIR="$PREFIX/var/templates";
63         CIRCRULESDIR="$PREFIX/var/circ";
64         CATALOGSCRIPTDIR="$PREFIX/var/catalog";
65         PENALTYRULESDIR="$PREFIX/var/penalty";
66         XSLDIR="$PREFIX/var/xsl";
67         REPORTERDIR="$PREFIX/var/web/reporter";
68         TMP="$(pwd)/.tmp";
69         ADMINDIR="$PREFIX/var/admin";
70
71         prompt "Apache2 apxs binary [$APXS2] "
72         read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
73
74         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
75         read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
76
77         prompt "Apache2 APR headers directory [$APR_HEADERS] "
78         read X; if [ ! -z "$X" ]; then APR_HEADERS="$X"; fi;
79
80         prompt "Libdbi libraries directory [$DBI_LIBS] "
81         read X; if [ ! -z "$X" ]; then DBI_LIBS="$X"; fi;
82
83         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
84         read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
85
86         prompt "OpenSRF headers directory [$OPENSRF_HEADERS] "
87         read X; if [ ! -z "$X" ]; then OPENSRF_HEADERS="$X"; fi;
88
89         prompt "OpenSRF libraries directory [$OPENSRF_LIBS] "
90         read X; if [ ! -z "$X" ]; then OPENSRF_LIBS="$X"; fi;
91
92         prompt "Build targets [${TARGETS[@]:0}] "
93         read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
94
95         prompt "Should we build Python modules? (Y/N) [$EG_PYTHON_INSTALL] "
96         read X; 
97     if [ "$X" = "Y" ]; 
98         then EG_PYTHON_INSTALL="Y"; 
99         else EG_PYTHON_INSTALL="";
100     fi;
101
102         prompt "Database Driver [$DBDRVR] "
103         read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
104
105         prompt "Database Host [$DBHOST] "
106         read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
107
108         prompt "Database Port [$DBPORT] "
109         read X; if [ ! -z "$X" ]; then DBPORT="$X"; fi;
110
111         prompt "Database Name [$DBNAME] "
112         read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
113
114         prompt "Database User [$DBUSER] "
115         read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
116
117         prompt "Database Password [$DBPW] "
118         read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
119
120         prompt "Reporter Template Directory [$REPORTERDIR] "
121         read X; if [ ! -z "$X" ]; then REPORTERDIR="$X"; fi;
122
123         writeConfig;
124 }
125
126 function prompt { echo ""; echo -en "$*"; }
127
128 function writeConfig {
129
130         rm -f "$CONFIG_FILE";
131         echo "Writing installation config to $CONFIG_FILE...";
132
133         _write "PREFIX=\"$PREFIX\"";
134         _write "BINDIR=\"$BINDIR\"";
135         _write "LIBDIR=\"$LIBDIR\"";
136         _write "PERLDIR=\"$PERLDIR\"";
137         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
138         _write "SOCK=\"$PREFIX/var/sock\"";
139         _write "PID=\"$PREFIX/var/pid\"";
140         _write "LOG=\"$PREFIX/var/log\"";
141         _write "DATADIR=\"$DATADIR\"";
142
143         _write "TMP=\"$TMP\"";
144         _write "APXS2=\"$APXS2\"";
145         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
146         _write "APR_HEADERS=\"$APR_HEADERS\"";
147         _write "DBI_LIBS=\"$DBI_LIBS\"";
148         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
149
150         _write "OPENSRF_HEADERS=\"$OPENSRF_HEADERS\"";
151         _write "OPENSRF_LIBS=\"$OPENSRF_LIBS\"";
152
153         _write "WEBDIR=\"$WEBDIR\"";
154         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
155         _write "ETCDIR=\"$ETCDIR\"";
156         _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
157         _write "CATALOGSCRIPTDIR=\"$CATALOGSCRIPTDIR\"";
158         _write "PENALTYRULESDIR=\"$PENALTYRULESDIR\"";
159         _write "XSLDIR=\"$XSLDIR\"";
160
161         # print out the targets
162         STR="TARGETS=(";
163         for target in ${TARGETS[@]:0}; do
164                 STR="$STR \"$target\"";
165         done;
166         STR="$STR)";
167         _write "$STR";
168
169     _write "EG_PYTHON_INSTALL=\"$EG_PYTHON_INSTALL\"";
170         _write "OPENILSDIR=\"Open-ILS/src/\"";
171         _write "EVERGREENDIR=\"Evergreen/\"";
172
173
174         _write "CGIDIR=\"$CGIDIR\"";
175
176         # db vars
177         _write "DBDRVR=\"$DBDRVR\"";
178         _write "DBHOST=\"$DBHOST\"";
179         _write "DBPORT=\"$DBPORT\"";
180         _write "DBNAME=\"$DBNAME\"";
181         _write "DBUSER=\"$DBUSER\"";
182         _write "DBPW=\"$DBPW\"";
183         _write "REPORTERDIR=\"$REPORTERDIR\"";
184         _write "ADMINDIR=\"$ADMINDIR\"";
185
186
187         # Now we'll write out the DB bootstrapping config
188         CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
189         rm -f "$CONFIG_FILE";
190         echo "Writing bootstrapping config to $CONFIG_FILE...";
191
192         STR='$main::config{dsn} =';
193                 STR="$STR 'dbi:${DBDRVR}:host=";
194                 STR="${STR}${DBHOST};dbname=";
195                 STR="${STR}${DBNAME};port=";
196                 STR="${STR}${DBPORT}';";
197         _write "$STR"
198
199         STR='$main::config{usr} =';
200                 STR="$STR '$DBUSER';";
201         _write "$STR"
202         
203         STR='$main::config{pw} =';
204                 STR="$STR '$DBPW';";
205         _write "$STR"
206         
207         _write '$main::config{index} = "config.cgi";';
208
209
210     # --------------------------------------------------------------------
211         # Now we'll write out the offline config
212         CONFIG_FILE='Open-ILS/src/offline/offline-config.pl';
213         rm -f "$CONFIG_FILE";
214         echo "Writing bootstrapping config to $CONFIG_FILE...";
215
216     _write "\$main::config{base_dir} = '$PREFIX/var/data/offline/';";
217     _write "\$main::config{bootstrap} = '$ETCDIR/opensrf_core.xml';";
218
219         STR='$main::config{dsn} =';
220                 STR="$STR 'dbi:${DBDRVR}:host=";
221                 STR="${STR}${DBHOST};dbname=";
222                 STR="${STR}${DBNAME};port=";
223                 STR="${STR}${DBPORT}';";
224         _write "$STR"
225
226         STR='$main::config{usr} =';
227                 STR="$STR '$DBUSER';";
228         _write "$STR"
229         
230         STR='$main::config{pw} =';
231                 STR="$STR '$DBPW';";
232         _write "$STR"
233     # --------------------------------------------------------------------
234         
235
236         prompt "";
237         prompt "";
238         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
239         prompt "!! If installing openils_all / openils_db !!";
240         prompt "!! Before running 'make install' you MUST !!";
241         prompt "!! create a database for Open-ILS.  Use   !!";
242         prompt "!! the settings that you listed above and !!";
243         prompt "!! the install scripts will create the    !!";
244         prompt "!! database for you.  -miker              !!";
245         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
246         prompt "";
247         prompt "";
248
249         prompt "To write a new config, run 'make config'";
250         prompt "";
251         prompt "To edit individual install locations (e.g. changing the lib directory),"
252         prompt "edit the install.conf file generated from this script"
253         prompt ""
254
255 }
256
257 function _write {
258         echo "$*" >> "$CONFIG_FILE";
259 }
260
261
262
263 buildConfig;