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