2 # --------------------------------------------------------------------
3 # Copyright (C) 2005 Georgia Public Library Service
4 # Bill Erickson <highfalutin@gmail.com>
5 # Mike Rylander <mrylander@gmail.com>
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.
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 # --------------------------------------------------------------------
19 # --------------------------------------------------------------------
20 # Prompts the user for config settings and writes a custom config
21 # file based on these settings
22 # --------------------------------------------------------------------
25 CONFIG_FILE="install.conf";
26 DEFAULT_CONFIG_FILE="install.conf.default";
28 function buildConfig {
30 # if [ -f "$CONFIG_FILE" ]; then
32 # echo "Using existing config file \"$CONFIG_FILE\"";
33 # echo "To generate a new config, remove \"$CONFIG_FILE\"";
40 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
41 source "$DEFAULT_CONFIG_FILE";
46 echo "-----------------------------------------------------------------------";
47 echo "Type Enter to select the default"
48 echo "-----------------------------------------------------------------------";
50 prompt "Temporary files directory [$TMP] "
51 read X; if [ ! -z "$X" ]; then TMP="$X"; fi;
53 prompt "Install prefix [$PREFIX] ";
54 read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
56 BINDIR="$PREFIX/bin/";
57 LIBDIR="$PREFIX/lib/";
58 PERLDIR="$LIBDIR/perl5/";
59 INCLUDEDIR="$PREFIX/include/";
60 ETCDIR="$PREFIX/conf";
61 WEBDIR="$PREFIX/var/web";
62 CGIDIR="$PREFIX/var/cgi-bin";
63 TEMPLATEDIR="$PREFIX/var/templates";
64 CIRCRULESDIR="$PREFIX/var/circ";
65 XSLDIR="$PREFIX/var/xsl";
67 prompt "Executables directory [$BINDIR] "
68 read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
70 prompt "Lib directory [$LIBDIR] "
71 read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
73 prompt "Perl directory [$PERLDIR] "
74 read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
76 prompt "Include files directory [$INCLUDEDIR] "
77 read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
79 prompt "Config files directory [$ETCDIR] "
80 read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
82 prompt "Web Root Directory [$WEBDIR] "
83 read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
85 prompt "Web CGI Directory [$CGIDIR] "
86 read X; if [ ! -z "$X" ]; then CGIDIR="$X"; fi;
88 prompt "Templates directory [$TEMPLATEDIR] "
89 read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
91 prompt "XSL Stylesheets directory [$XSLDIR] "
92 read X; if [ ! -z "$X" ]; then XSLDIR="$X"; fi;
94 prompt "Custom circulation rules directory [$CIRCRULESDIR] "
95 read X; if [ ! -z "$X" ]; then CIRCRULESDIR="$X"; fi;
97 prompt "Apache2 apxs binary [$APXS2] "
98 read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
100 prompt "Apache2 headers directory [$APACHE2_HEADERS] "
101 read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
103 prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
104 read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
106 prompt "Build targets [${TARGETS[@]:0}] "
107 read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
109 prompt "Bootstrapping Database Driver [$DBDRVR] "
110 read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
112 prompt "Bootstrapping Database Host [$DBHOST] "
113 read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
115 prompt "Bootstrapping Database Name [$DBNAME] "
116 read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
118 prompt "Bootstrapping Database User [$DBUSER] "
119 read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
121 prompt "Bootstrapping Database Password [$DBPW] "
122 read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
127 function prompt { echo ""; echo -n "$*"; }
129 function writeConfig {
131 rm -f "$CONFIG_FILE";
132 echo "Writing installation config to $CONFIG_FILE...";
134 _write "PREFIX=\"$PREFIX\"";
135 _write "BINDIR=\"$BINDIR\"";
136 _write "LIBDIR=\"$LIBDIR\"";
137 _write "PERLDIR=\"$PERLDIR\"";
138 _write "INCLUDEDIR=\"$INCLUDEDIR\"";
140 _write "TMP=\"$TMP\"";
141 _write "APXS2=\"$APXS2\"";
142 _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
143 _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
145 _write "WEBDIR=\"$WEBDIR\"";
146 _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
147 _write "ETCDIR=\"$ETCDIR\"";
148 _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
149 _write "XSLDIR=\"$XSLDIR\"";
151 # print out the targets
153 for target in ${TARGETS[@]:0}; do
154 STR="$STR \"$target\"";
159 _write "OPENSRFDIR=\"OpenSRF/src/\"";
160 _write "OPENILSDIR=\"Open-ILS/src/\"";
161 _write "EVERGREENDIR=\"Evergreen/\"";
164 _write "CGIDIR=\"$CGIDIR\"";
167 _write "DBDRVR=\"$DBDRVR\"";
168 _write "DBHOST=\"$DBHOST\"";
169 _write "DBNAME=\"$DBNAME\"";
170 _write "DBUSER=\"$DBUSER\"";
171 _write "DBPW=\"$DBPW\"";
174 # Now we'll write out the DB bootstrapping config
175 CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
176 rm -f "$CONFIG_FILE";
177 echo "Writing bootstrapping config to $CONFIG_FILE...";
179 STR='$main::config{dsn} =';
180 STR="$STR 'dbi:${DBDRVR}:host=";
181 STR="${STR}${DBHOST};dbname=";
182 STR="${STR}${DBNAME}';";
185 STR='$main::config{usr} =';
186 STR="$STR '$DBUSER';";
189 STR='$main::config{pw} =';
193 _write '$main::config{index} = "config.cgi";';
198 prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
199 prompt "!! If installing openils_all / openils_db !!";
200 prompt "!! Before running 'make install' you MUST !!";
201 prompt "!! create a database for Open-ILS. Use !!";
202 prompt "!! the settings that you listed above and !!";
203 prompt "!! the install scripts will create the !!";
204 prompt "!! database for you. -miker !!";
205 prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
209 prompt "To write a new config, run 'make config'";
215 echo "$*" >> "$CONFIG_FILE";