]> git.evergreen-ils.org Git - Evergreen.git/blob - config.sh
adding fkey for actor.usr.profile -- Thanks to Jonh from AlphaG for spotting the...
[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/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 "Database Driver [$DBDRVR] "
96         read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
97
98         if [ "$DBDRVR" == "Pg" ]; then
99                 prompt "Bootstrapping Database Version (80 for 8.0.x, 81 for 8.1.x, 82 for 8.2.x) [$DBVER] "
100                 read X; if [ ! -z "$X" ]; then DBVER="$X"; fi;
101         fi;
102
103         prompt "Database Host [$DBHOST] "
104         read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
105
106         prompt "Database Port [$DBPORT] "
107         read X; if [ ! -z "$X" ]; then DBPORT="$X"; fi;
108
109         prompt "Database Name [$DBNAME] "
110         read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
111
112         prompt "Database User [$DBUSER] "
113         read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
114
115         prompt "Database Password [$DBPW] "
116         read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
117
118         prompt "Reporter Template Directory [$REPORTERDIR] "
119         read X; if [ ! -z "$X" ]; then REPORTERDIR="$X"; fi;
120
121         writeConfig;
122 }
123
124 function prompt { echo ""; echo -en "$*"; }
125
126 function writeConfig {
127
128         rm -f "$CONFIG_FILE";
129         echo "Writing installation config to $CONFIG_FILE...";
130
131         _write "PREFIX=\"$PREFIX\"";
132         _write "BINDIR=\"$BINDIR\"";
133         _write "LIBDIR=\"$LIBDIR\"";
134         _write "PERLDIR=\"$PERLDIR\"";
135         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
136         _write "SOCK=\"$PREFIX/var/sock\"";
137         _write "PID=\"$PREFIX/var/pid\"";
138         _write "LOG=\"$PREFIX/var/log\"";
139         _write "DATADIR=\"$DATADIR\"";
140
141         _write "TMP=\"$TMP\"";
142         _write "APXS2=\"$APXS2\"";
143         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
144         _write "APR_HEADERS=\"$APR_HEADERS\"";
145         _write "DBI_LIBS=\"$DBI_LIBS\"";
146         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
147
148         _write "OPENSRF_HEADERS=\"$OPENSRF_HEADERS\"";
149         _write "OPENSRF_LIBS=\"$OPENSRF_LIBS\"";
150
151         _write "WEBDIR=\"$WEBDIR\"";
152         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
153         _write "ETCDIR=\"$ETCDIR\"";
154         _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
155         _write "CATALOGSCRIPTDIR=\"$CATALOGSCRIPTDIR\"";
156         _write "PENALTYRULESDIR=\"$PENALTYRULESDIR\"";
157         _write "XSLDIR=\"$XSLDIR\"";
158
159         # print out the targets
160         STR="TARGETS=(";
161         for target in ${TARGETS[@]:0}; do
162                 STR="$STR \"$target\"";
163         done;
164         STR="$STR)";
165         _write "$STR";
166
167         _write "OPENILSDIR=\"Open-ILS/src/\"";
168         _write "EVERGREENDIR=\"Evergreen/\"";
169
170
171         _write "CGIDIR=\"$CGIDIR\"";
172
173         # db vars
174         _write "DBDRVR=\"$DBDRVR\"";
175         _write "DBHOST=\"$DBHOST\"";
176         _write "DBPORT=\"$DBPORT\"";
177         _write "DBNAME=\"$DBNAME\"";
178         _write "DBUSER=\"$DBUSER\"";
179         _write "DBPW=\"$DBPW\"";
180         _write "DBVER=\"$DBVER\"";
181         _write "REPORTERDIR=\"$REPORTERDIR\"";
182         _write "ADMINDIR=\"$ADMINDIR\"";
183
184
185         # Now we'll write out the DB bootstrapping config
186         CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
187         rm -f "$CONFIG_FILE";
188         echo "Writing bootstrapping config to $CONFIG_FILE...";
189
190         STR='$main::config{dsn} =';
191                 STR="$STR 'dbi:${DBDRVR}:host=";
192                 STR="${STR}${DBHOST};dbname=";
193                 STR="${STR}${DBNAME};port=";
194                 STR="${STR}${DBPORT}';";
195         _write "$STR"
196
197         STR='$main::config{usr} =';
198                 STR="$STR '$DBUSER';";
199         _write "$STR"
200         
201         STR='$main::config{pw} =';
202                 STR="$STR '$DBPW';";
203         _write "$STR"
204         
205         _write '$main::config{index} = "config.cgi";';
206
207
208     # --------------------------------------------------------------------
209         # Now we'll write out the offline config
210         CONFIG_FILE='Open-ILS/src/offline/offline-config.pl';
211         rm -f "$CONFIG_FILE";
212         echo "Writing bootstrapping config to $CONFIG_FILE...";
213
214     _write "\$main::config{base_dir} = '$PREFIX/var/data/offline/';";
215     _write "\$main::config{bootstrap} = '$ETCDIR/opensrf_core.xml';";
216
217         STR='$main::config{dsn} =';
218                 STR="$STR 'dbi:${DBDRVR}:host=";
219                 STR="${STR}${DBHOST};dbname=";
220                 STR="${STR}${DBNAME};port=";
221                 STR="${STR}${DBPORT}';";
222         _write "$STR"
223
224         STR='$main::config{usr} =';
225                 STR="$STR '$DBUSER';";
226         _write "$STR"
227         
228         STR='$main::config{pw} =';
229                 STR="$STR '$DBPW';";
230         _write "$STR"
231     # --------------------------------------------------------------------
232         
233
234         prompt "";
235         prompt "";
236         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
237         prompt "!! If installing openils_all / openils_db !!";
238         prompt "!! Before running 'make install' you MUST !!";
239         prompt "!! create a database for Open-ILS.  Use   !!";
240         prompt "!! the settings that you listed above and !!";
241         prompt "!! the install scripts will create the    !!";
242         prompt "!! database for you.  -miker              !!";
243         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
244         prompt "";
245         prompt "";
246
247         prompt "To write a new config, run 'make config'";
248         prompt "";
249         prompt "To edit individual install locations (e.g. changing the lib directory),"
250         prompt "edit the install.conf file generated from this script"
251         prompt ""
252
253 }
254
255 function _write {
256         echo "$*" >> "$CONFIG_FILE";
257 }
258
259
260
261 buildConfig;