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 "$DEFAULT_CONFIG_FILE" ]; then
31 source "$DEFAULT_CONFIG_FILE";
36 echo "-----------------------------------------------------------------------";
37 echo "Type Enter to select the default"
38 echo "-----------------------------------------------------------------------";
40 prompt "Temporary files directory [$TMP] "
41 read X; if [ ! -z "$X" ]; then TMP="$X"; fi;
43 prompt "Install prefix [$PREFIX] ";
44 read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
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";
57 prompt "Executables directory [$BINDIR] "
58 read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
60 prompt "Lib directory [$LIBDIR] "
61 read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
63 prompt "Perl directory [$PERLDIR] "
64 read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
66 prompt "Include files directory [$INCLUDEDIR] "
67 read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
69 prompt "Config files directory [$ETCDIR] "
70 read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
72 prompt "Web Root Directory [$WEBDIR] "
73 read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
75 prompt "Web CGI Directory [$CGIDIR] "
76 read X; if [ ! -z "$X" ]; then CGIDIR="$X"; fi;
78 prompt "Web domain for OPAC in Staff Client [$NEW_OPAC_URL] "
79 read X; if [ ! -z "$X" ]; then NEW_OPAC_URL="$X"; fi;
81 prompt "Package Name for Staff Client [$NEW_XUL_PACKAGE_NAME] "
82 read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_NAME="$X"; fi;
84 prompt "Package Label for Staff Client [$NEW_XUL_PACKAGE_LABEL] "
85 read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_LABEL="$X"; fi;
87 prompt "Templates directory [$TEMPLATEDIR] "
88 read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
90 prompt "XSL Stylesheets directory [$XSLDIR] "
91 read X; if [ ! -z "$X" ]; then XSLDIR="$X"; fi;
93 prompt "Custom circulation rules directory [$CIRCRULESDIR] "
94 read X; if [ ! -z "$X" ]; then CIRCRULESDIR="$X"; fi;
96 prompt "Apache2 apxs binary [$APXS2] "
97 read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
99 prompt "Apache2 headers directory [$APACHE2_HEADERS] "
100 read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
102 prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
103 read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
105 prompt "Build targets [${TARGETS[@]:0}] "
106 read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
108 prompt "Bootstrapping Database Driver [$DBDRVR] "
109 read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
111 prompt "Bootstrapping Database Host [$DBHOST] "
112 read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
114 prompt "Bootstrapping Database Name [$DBNAME] "
115 read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
117 prompt "Bootstrapping Database User [$DBUSER] "
118 read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
120 prompt "Bootstrapping Database Password [$DBPW] "
121 read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
126 function prompt { echo ""; echo -n "$*"; }
128 function writeConfig {
130 rm -f "$CONFIG_FILE";
131 echo "Writing installation config to $CONFIG_FILE...";
133 _write "PREFIX=\"$PREFIX\"";
134 _write "BINDIR=\"$BINDIR\"";
135 _write "LIBDIR=\"$LIBDIR\"";
136 _write "PERLDIR=\"$PERLDIR\"";
137 _write "INCLUDEDIR=\"$INCLUDEDIR\"";
139 _write "TMP=\"$TMP\"";
140 _write "APXS2=\"$APXS2\"";
141 _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
142 _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
144 _write "WEBDIR=\"$WEBDIR\"";
145 _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
146 _write "ETCDIR=\"$ETCDIR\"";
147 _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
148 _write "XSLDIR=\"$XSLDIR\"";
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\"";
154 # print out the targets
156 for target in ${TARGETS[@]:0}; do
157 STR="$STR \"$target\"";
162 _write "OPENSRFDIR=\"OpenSRF/src/\"";
163 _write "OPENILSDIR=\"Open-ILS/src/\"";
164 _write "EVERGREENDIR=\"Evergreen/\"";
167 _write "CGIDIR=\"$CGIDIR\"";
170 _write "DBDRVR=\"$DBDRVR\"";
171 _write "DBHOST=\"$DBHOST\"";
172 _write "DBNAME=\"$DBNAME\"";
173 _write "DBUSER=\"$DBUSER\"";
174 _write "DBPW=\"$DBPW\"";
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...";
182 STR='$main::config{dsn} =';
183 STR="$STR 'dbi:${DBDRVR}:host=";
184 STR="${STR}${DBHOST};dbname=";
185 STR="${STR}${DBNAME}';";
188 STR='$main::config{usr} =';
189 STR="$STR '$DBUSER';";
192 STR='$main::config{pw} =';
196 _write '$main::config{index} = "config.cgi";';
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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
212 prompt "To write a new config, run 'make config'";
218 echo "$*" >> "$CONFIG_FILE";