making the install script break out opensrf, openils, and evergreen a little
[Evergreen.git] / config.sh
1 #!/bin/bash
2 # --------------------------------------------------------------------
3 # Copyright (C) 2005  Georgia Public Library Service 
4 # Bill Erickson <highfalutin@gmail.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 # --------------------------------------------------------------------
16
17
18 # --------------------------------------------------------------------
19 # Prompts the user for config settings and writes a custom config
20 # file based on these settings
21 # --------------------------------------------------------------------
22
23
24 CONFIG_FILE="install.conf";
25 DEFAULT_CONFIG_FILE="install.conf.default";
26
27 function buildConfig {
28
29 #       if [ -f "$CONFIG_FILE" ]; then
30 #               echo "";
31 #               echo "Using existing config file \"$CONFIG_FILE\""; 
32 #               echo "To generate a new config, remove \"$CONFIG_FILE\"";
33 #               echo "";
34 #               sleep 3;        
35 #               exit 0;
36 #       fi
37
38
39         if [ -f "$DEFAULT_CONFIG_FILE" ]; then
40                 source "$DEFAULT_CONFIG_FILE";
41         fi;
42
43
44         echo "";
45         echo "-----------------------------------------------------------------------";
46         echo "Type Enter to select the default"
47         echo "-----------------------------------------------------------------------";
48
49         prompt "Temporary files directory [$TMP] "
50         read X;
51         if [ ! -z "$X" ]; then TMP="$X"; fi;
52
53         prompt "Install prefix [$PREFIX] ";
54         read X;
55         if [ ! -z "$X" ]; then 
56                 PREFIX="$X"; 
57                 BINDIR="$PREFIX/bin/";
58                 LIBDIR="$PREFIX/lib/";
59                 PERLDIR="$LIBDIR/perl5/";
60                 INCLUDEDIR="$PREFIX/include/";
61         fi
62
63         prompt "Executables directory [$BINDIR] "
64         read X;
65         if [ ! -z "$X" ]; then BINDIR="$X"; fi;
66
67         prompt "Lib directory [$LIBDIR] "
68         read X;
69         if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
70
71         prompt "Perl directory [$PERLDIR] "
72         read X;
73         if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
74
75         prompt "Include files directory [$INCLUDEDIR] "
76         read X;
77         if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
78
79         prompt "Config files directory [$ETCDIR] "
80         read X;
81         if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
82
83         prompt "Web Root Directory [$WEB] "
84         read X;
85         if [ ! -z "$X" ]; then WEB="$X"; fi;
86
87         
88         prompt "Apache2 apxs binary [$APXS2] "
89         read X;
90         if [ ! -z "$X" ]; then APXS2="$X"; fi;
91
92         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
93         read X;
94         if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
95
96         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
97         read X;
98         if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
99
100         prompt "Build targets [${TARGETS[@]:0}] "
101         read X;
102         if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
103
104
105         cat <<-WORDS
106
107         -----------------------------------------------------------------------
108         Verify the following install directories are sane.
109         Note: * indicates that you must have write privelages for the location
110         -----------------------------------------------------------------------
111
112         -----------------------------------------------------------------------
113         Install prefix             [$PREFIX]*
114         Temporary files directory  [$TMP]*
115         Apache2 apxs binary        [$APXS2]
116         Apache2 headers directory  [$APACHE2_HEADERS]
117         Libxml2 headers directory  [$LIBXML2_HEADERS]
118         Build targets              [${TARGETS[@]:0}]
119         -----------------------------------------------------------------------
120
121         If these are not OK, use control-c to break out rerun this script.
122         Otherwise, type enter.
123
124         WORDS
125
126         read OK;
127
128         writeConfig;
129 }
130
131 function prompt { echo ""; echo -n "$*"; }
132
133 function writeConfig {
134
135         rm -f "$CONFIG_FILE";
136         echo "Writing config to $CONFIG_FILE...";
137
138         _write "PREFIX=\"$PREFIX\"";
139         _write "BINDIR=\"$BINDIR\"";
140         _write "LIBDIR=\"$LIBDIR\"";
141         _write "PERLDIR=\"$PERLDIR\"";
142         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
143
144         _write "TMP=\"$TMP\"";
145         _write "APXS2=\"$APXS2\"";
146         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
147         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
148
149         # print out the targets
150         STR="TARGETS=(";
151         for target in ${TARGETS[@]:0}; do
152                 STR="$STR \"$target\"";
153         done;
154         STR="$STR)";
155         _write "$STR";
156
157         _write "OPENSRF_DIR=\"OpenSRF/src/\"";
158         _write "OPENILS_DIR=\"Open-ILS/src/\"";
159         _write "EVERGREEN_DIR=\"Evergreen/\"";
160
161 }
162
163 function _write {
164         echo "$*" >> "$CONFIG_FILE";
165 }
166
167
168
169 buildConfig;