adding support for alternate APR header dirs
[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 "Install prefix [$PREFIX] ";
41         read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
42
43         BINDIR="$PREFIX/bin/";
44         LIBDIR="$PREFIX/lib/";
45         PERLDIR="$LIBDIR/perl5/";
46         INCLUDEDIR="$PREFIX/include/";
47         ETCDIR="$PREFIX/conf";
48         WEBDIR="$PREFIX/var/web";
49         CGIDIR="$PREFIX/var/cgi-bin";
50         TEMPLATEDIR="$PREFIX/var/templates";
51         CIRCRULESDIR="$PREFIX/var/circ";
52         XSLDIR="$PREFIX/var/xsl";
53         TMP="$(pwd)/.tmp";
54
55         prompt "Web domain for OPAC in Staff Client [$NEW_OPAC_URL] "
56         read X; if [ ! -z "$X" ]; then NEW_OPAC_URL="$X"; fi;
57
58         prompt "Package Name for Staff Client [$NEW_XUL_PACKAGE_NAME] "
59         read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_NAME="$X"; fi;
60
61         prompt "Package Label for Staff Client [$NEW_XUL_PACKAGE_LABEL] "
62         read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_LABEL="$X"; fi;
63
64         prompt "Apache2 apxs binary [$APXS2] "
65         read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
66
67         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
68         read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
69
70         prompt "Apache2 APR headers directory [$APR_HEADERS] "
71         read X; if [ ! -z "$X" ]; then APR_HEADERS="$X"; fi;
72
73         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
74         read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
75
76         prompt "Build targets [${TARGETS[@]:0}] "
77         read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
78
79         prompt "Bootstrapping Database Driver [$DBDRVR] "
80         read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
81
82         prompt "Bootstrapping Database Host [$DBHOST] "
83         read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
84
85         prompt "Bootstrapping Database Name [$DBNAME] "
86         read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
87
88         prompt "Bootstrapping Database User [$DBUSER] "
89         read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
90
91         prompt "Bootstrapping Database Password [$DBPW] "
92         read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
93
94         writeConfig;
95 }
96
97 function prompt { echo ""; echo -n "$*"; }
98
99 function writeConfig {
100
101         rm -f "$CONFIG_FILE";
102         echo "Writing installation config to $CONFIG_FILE...";
103
104         _write "PREFIX=\"$PREFIX\"";
105         _write "BINDIR=\"$BINDIR\"";
106         _write "LIBDIR=\"$LIBDIR\"";
107         _write "PERLDIR=\"$PERLDIR\"";
108         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
109         _write "SOCK=\"$PREFIX/var/sock\"";
110         _write "PID=\"$PREFIX/var/pid\"";
111         _write "LOG=\"$PREFIX/var/log\"";
112
113         _write "TMP=\"$TMP\"";
114         _write "APXS2=\"$APXS2\"";
115         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
116         _write "APR_HEADERS=\"$APR_HEADERS\"";
117         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
118
119         _write "WEBDIR=\"$WEBDIR\"";
120         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
121         _write "ETCDIR=\"$ETCDIR\"";
122         _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
123         _write "XSLDIR=\"$XSLDIR\"";
124
125         _write "NEW_OPAC_URL=\"$NEW_OPAC_URL\"";
126         _write "NEW_XUL_PACKAGE_NAME=\"$NEW_XUL_PACKAGE_NAME\"";
127         _write "NEW_XUL_PACKAGE_LABEL=\"$NEW_XUL_PACKAGE_LABEL\"";
128
129         # print out the targets
130         STR="TARGETS=(";
131         for target in ${TARGETS[@]:0}; do
132                 STR="$STR \"$target\"";
133         done;
134         STR="$STR)";
135         _write "$STR";
136
137         _write "OPENSRFDIR=\"OpenSRF/src/\"";
138         _write "OPENILSDIR=\"Open-ILS/src/\"";
139         _write "EVERGREENDIR=\"Evergreen/\"";
140
141
142         _write "CGIDIR=\"$CGIDIR\"";
143
144         # db vars
145         _write "DBDRVR=\"$DBDRVR\"";
146         _write "DBHOST=\"$DBHOST\"";
147         _write "DBNAME=\"$DBNAME\"";
148         _write "DBUSER=\"$DBUSER\"";
149         _write "DBPW=\"$DBPW\"";
150
151
152         # Now we'll write out the DB bootstrapping config
153         CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
154         rm -f "$CONFIG_FILE";
155         echo "Writing bootstrapping config to $CONFIG_FILE...";
156
157         STR='$main::config{dsn} =';
158                 STR="$STR 'dbi:${DBDRVR}:host=";
159                 STR="${STR}${DBHOST};dbname=";
160                 STR="${STR}${DBNAME}';";
161         _write "$STR"
162
163         STR='$main::config{usr} =';
164                 STR="$STR '$DBUSER';";
165         _write "$STR"
166         
167         STR='$main::config{pw} =';
168                 STR="$STR '$DBPW';";
169         _write "$STR"
170         
171         _write '$main::config{index} = "config.cgi";';
172
173
174         prompt "";
175         prompt "";
176         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
177         prompt "!! If installing openils_all / openils_db !!";
178         prompt "!! Before running 'make install' you MUST !!";
179         prompt "!! create a database for Open-ILS.  Use   !!";
180         prompt "!! the settings that you listed above and !!";
181         prompt "!! the install scripts will create the    !!";
182         prompt "!! database for you.  -miker              !!";
183         prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
184         prompt "";
185         prompt "";
186
187         prompt "To write a new config, run 'make config'";
188         prompt "";
189         prompt "To edit individual install locations (e.g. changing the lib directory),"
190         prompt "edit the install.conf file generated from this script"
191         prompt ""
192
193 }
194
195 function _write {
196         echo "$*" >> "$CONFIG_FILE";
197 }
198
199
200
201 buildConfig;