]> git.evergreen-ils.org Git - Evergreen.git/blob - config.sh
added some output
[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
28 function buildConfig {
29
30         if [ -f "$DEFAULT_CONFIG_FILE" ]; then
31                 source "$DEFAULT_CONFIG_FILE";
32         fi;
33
34
35         echo "";
36         echo "-----------------------------------------------------------------------";
37         echo "Type Enter to select the default"
38         echo "-----------------------------------------------------------------------";
39
40         prompt "Temporary files directory [$TMP] "
41         read X; if [ ! -z "$X" ]; then TMP="$X"; fi;
42
43         prompt "Install prefix [$PREFIX] ";
44         read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
45
46         BINDIR="$PREFIX/bin/";
47         LIBDIR="$PREFIX/lib/";
48         PERLDIR="$LIBDIR/perl5/";
49         INCLUDEDIR="$PREFIX/include/";
50         ETCDIR="$PREFIX/conf";
51         WEBDIR="$PREFIX/var/web";
52         CGIDIR="$PREFIX/var/cgi-bin";
53         TEMPLATEDIR="$PREFIX/var/templates";
54         CIRCRULESDIR="$PREFIX/var/circ";
55         XSLDIR="$PREFIX/var/xsl";
56
57         prompt "Executables directory [$BINDIR] "
58         read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
59
60         prompt "Lib directory [$LIBDIR] "
61         read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
62
63         prompt "Perl directory [$PERLDIR] "
64         read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
65
66         prompt "Include files directory [$INCLUDEDIR] "
67         read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
68
69         prompt "Config files directory [$ETCDIR] "
70         read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
71
72         prompt "Web Root Directory [$WEBDIR] "
73         read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
74
75         prompt "Web CGI Directory [$CGIDIR] "
76         read X; if [ ! -z "$X" ]; then CGIDIR="$X"; fi;
77
78         prompt "Web domain for OPAC in Staff Client [$NEW_OPAC_URL] "
79         read X; if [ ! -z "$X" ]; then NEW_OPAC_URL="$X"; fi;
80
81         prompt "Package Name for Staff Client [$NEW_XUL_PACKAGE_NAME] "
82         read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_NAME="$X"; fi;
83
84         prompt "Package Label for Staff Client [$NEW_XUL_PACKAGE_LABEL] "
85         read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_LABEL="$X"; fi;
86
87         prompt "Templates directory [$TEMPLATEDIR] "
88         read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
89
90         prompt "XSL Stylesheets directory [$XSLDIR] "
91         read X; if [ ! -z "$X" ]; then XSLDIR="$X"; fi;
92
93         prompt "Custom circulation rules directory [$CIRCRULESDIR] "
94         read X; if [ ! -z "$X" ]; then CIRCRULESDIR="$X"; fi;
95
96         prompt "Apache2 apxs binary [$APXS2] "
97         read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
98
99         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
100         read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
101
102         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
103         read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
104
105         prompt "Build targets [${TARGETS[@]:0}] "
106         read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
107
108         prompt "Bootstrapping Database Driver [$DBDRVR] "
109         read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
110
111         prompt "Bootstrapping Database Host [$DBHOST] "
112         read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
113
114         prompt "Bootstrapping Database Name [$DBNAME] "
115         read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
116
117         prompt "Bootstrapping Database User [$DBUSER] "
118         read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
119
120         prompt "Bootstrapping Database Password [$DBPW] "
121         read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
122
123         writeConfig;
124 }
125
126 function prompt { echo ""; echo -n "$*"; }
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
139         _write "TMP=\"$TMP\"";
140         _write "APXS2=\"$APXS2\"";
141         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
142         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
143
144         _write "WEBDIR=\"$WEBDIR\"";
145         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
146         _write "ETCDIR=\"$ETCDIR\"";
147         _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
148         _write "XSLDIR=\"$XSLDIR\"";
149
150         _write "NEW_OPAC_URL=\"$NEW_OPAC_URL\"";
151         _write "NEW_XUL_PACKAGE_NAME=\"$NEW_XUL_PACKAGE_NAME\"";
152         _write "NEW_XUL_PACKAGE_LABEL=\"$NEW_XUL_PACKAGE_LABEL\"";
153
154         # print out the targets
155         STR="TARGETS=(";
156         for target in ${TARGETS[@]:0}; do
157                 STR="$STR \"$target\"";
158         done;
159         STR="$STR)";
160         _write "$STR";
161
162         _write "OPENSRFDIR=\"OpenSRF/src/\"";
163         _write "OPENILSDIR=\"Open-ILS/src/\"";
164         _write "EVERGREENDIR=\"Evergreen/\"";
165
166
167         _write "CGIDIR=\"$CGIDIR\"";
168
169         # db vars
170         _write "DBDRVR=\"$DBDRVR\"";
171         _write "DBHOST=\"$DBHOST\"";
172         _write "DBNAME=\"$DBNAME\"";
173         _write "DBUSER=\"$DBUSER\"";
174         _write "DBPW=\"$DBPW\"";
175
176
177         # Now we'll write out the DB bootstrapping config
178         CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
179         rm -f "$CONFIG_FILE";
180         echo "Writing bootstrapping config to $CONFIG_FILE...";
181
182         STR='$main::config{dsn} =';
183                 STR="$STR 'dbi:${DBDRVR}:host=";
184                 STR="${STR}${DBHOST};dbname=";
185                 STR="${STR}${DBNAME}';";
186         _write "$STR"
187
188         STR='$main::config{usr} =';
189                 STR="$STR '$DBUSER';";
190         _write "$STR"
191         
192         STR='$main::config{pw} =';
193                 STR="$STR '$DBPW';";
194         _write "$STR"
195         
196         _write '$main::config{index} = "config.cgi";';
197
198
199         prompt "";
200         prompt "";
201         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
202         prompt "!! If installing openils_all / openils_db !!";
203         prompt "!! Before running 'make install' you MUST !!";
204         prompt "!! create a database for Open-ILS.  Use   !!";
205         prompt "!! the settings that you listed above and !!";
206         prompt "!! the install scripts will create the    !!";
207         prompt "!! database for you.  -miker              !!";
208         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
209         prompt "";
210         prompt "";
211
212         prompt "To write a new config, run 'make config'";
213         prompt "";
214
215 }
216
217 function _write {
218         echo "$*" >> "$CONFIG_FILE";
219 }
220
221
222
223 buildConfig;