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";
29 function buildConfig {
31 if [ -f "$CONFIG_FILE" ]; then
32 source "$CONFIG_FILE";
34 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
35 source "$DEFAULT_CONFIG_FILE";
39 if [ -n "$USE_DEFAULT" ]; then
40 prompt "Default config requested, not prompting for values...\n";
47 echo "-----------------------------------------------------------------------";
48 echo "Type Enter to select the default"
49 echo "-----------------------------------------------------------------------";
51 prompt "Install prefix [$PREFIX] ";
52 read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
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";
69 ADMINDIR="$PREFIX/var/admin";
71 prompt "Apache2 apxs binary [$APXS2] "
72 read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
74 prompt "Apache2 headers directory [$APACHE2_HEADERS] "
75 read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
77 prompt "Apache2 APR headers directory [$APR_HEADERS] "
78 read X; if [ ! -z "$X" ]; then APR_HEADERS="$X"; fi;
80 prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
81 read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
83 prompt "Build targets [${TARGETS[@]:0}] "
84 read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
86 prompt "Database Driver [$DBDRVR] "
87 read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
89 if [ "$DBDRVR" == "Pg" ]; then
90 prompt "Bootstrapping Database Version (80 for 8.0.x, 81 for 8.1.x, 82 for 8.2.x) [$DBVER] "
91 read X; if [ ! -z "$X" ]; then DBVER="$X"; fi;
94 prompt "Database Host [$DBHOST] "
95 read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
97 prompt "Database Port [$DBPORT] "
98 read X; if [ ! -z "$X" ]; then DBPORT="$X"; fi;
100 prompt "Database Name [$DBNAME] "
101 read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
103 prompt "Database User [$DBUSER] "
104 read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
106 prompt "Database Password [$DBPW] "
107 read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
109 prompt "Reporter Template Directory [$REPORTERDIR] "
110 read X; if [ ! -z "$X" ]; then REPORTERDIR="$X"; fi;
115 function prompt { echo ""; echo -en "$*"; }
117 function writeConfig {
119 rm -f "$CONFIG_FILE";
120 echo "Writing installation config to $CONFIG_FILE...";
122 _write "PREFIX=\"$PREFIX\"";
123 _write "BINDIR=\"$BINDIR\"";
124 _write "LIBDIR=\"$LIBDIR\"";
125 _write "PERLDIR=\"$PERLDIR\"";
126 _write "INCLUDEDIR=\"$INCLUDEDIR\"";
127 _write "SOCK=\"$PREFIX/var/sock\"";
128 _write "PID=\"$PREFIX/var/pid\"";
129 _write "LOG=\"$PREFIX/var/log\"";
130 _write "DATADIR=\"$DATADIR\"";
132 _write "TMP=\"$TMP\"";
133 _write "APXS2=\"$APXS2\"";
134 _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
135 _write "APR_HEADERS=\"$APR_HEADERS\"";
136 _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
138 _write "WEBDIR=\"$WEBDIR\"";
139 _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
140 _write "ETCDIR=\"$ETCDIR\"";
141 _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
142 _write "CATALOGSCRIPTDIR=\"$CATALOGSCRIPTDIR\"";
143 _write "PENALTYRULESDIR=\"$PENALTYRULESDIR\"";
144 _write "XSLDIR=\"$XSLDIR\"";
146 # print out the targets
148 for target in ${TARGETS[@]:0}; do
149 STR="$STR \"$target\"";
154 _write "OPENSRFDIR=\"OpenSRF/src/\"";
155 _write "OPENILSDIR=\"Open-ILS/src/\"";
156 _write "EVERGREENDIR=\"Evergreen/\"";
159 _write "CGIDIR=\"$CGIDIR\"";
162 _write "DBDRVR=\"$DBDRVR\"";
163 _write "DBHOST=\"$DBHOST\"";
164 _write "DBPORT=\"$DBPORT\"";
165 _write "DBNAME=\"$DBNAME\"";
166 _write "DBUSER=\"$DBUSER\"";
167 _write "DBPW=\"$DBPW\"";
168 _write "DBVER=\"$DBVER\"";
169 _write "REPORTERDIR=\"$REPORTERDIR\"";
170 _write "ADMINDIR=\"$ADMINDIR\"";
173 # Now we'll write out the DB bootstrapping config
174 CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
175 rm -f "$CONFIG_FILE";
176 echo "Writing bootstrapping config to $CONFIG_FILE...";
178 STR='$main::config{dsn} =';
179 STR="$STR 'dbi:${DBDRVR}:host=";
180 STR="${STR}${DBHOST};dbname=";
181 STR="${STR}${DBNAME};port=";
182 STR="${STR}${DBPORT}';";
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'";
211 prompt "To edit individual install locations (e.g. changing the lib directory),"
212 prompt "edit the install.conf file generated from this script"
218 echo "$*" >> "$CONFIG_FILE";