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