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