more install goodness
[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 CONFIG_FILE="install.conf";
19 DEFAULT_CONFIG_FILE="install.conf.default";
20
21 function buildConfig {
22
23         if [ -f "$DEFAULT_CONFIG_FILE" ]; then
24                 source "$DEFAULT_CONFIG_FILE";
25         fi;
26
27
28         echo "";
29         echo "-----------------------------------------------------------------------";
30         echo "Type Enter to select the default"
31         echo "-----------------------------------------------------------------------";
32
33         prompt "Install prefix [$PREFIX] ";
34         read X;
35         if [ ! -z "$X" ]; then PREFIX="$X"; fi;
36
37         prompt "Temporary files directory [$TMP] "
38         read X;
39         if [ ! -z "$X" ]; then TMP="$X"; fi;
40
41         prompt "Apache2 apxs binary [$APXS2] "
42         read X;
43         if [ ! -z "$X" ]; then APXS2="$X"; fi;
44
45         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
46         read X;
47         if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
48
49         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
50         read X;
51         if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
52
53         prompt "Build targets [${TARGETS[@]:0}] "
54         read X;
55         if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
56
57
58         cat <<-WORDS
59
60         -----------------------------------------------------------------------
61         Verify the following install directories are sane.
62         Note: * indicates that you must have write privelages for the location
63         -----------------------------------------------------------------------
64
65         -----------------------------------------------------------------------
66         Install prefix             [$PREFIX]*
67         Temporary files directory  [$TMP]*
68         Apache2 apxs binary        [$APXS2]
69         Apache2 headers directory  [$APACHE2_HEADERS]
70         Libxml2 headers directory  [$LIBXML2_HEADERS]
71         Build targets              [${TARGETS[@]:0}]
72         -----------------------------------------------------------------------
73
74         If these are not OK, use control-c to break out rerun this script.
75         Otherwise, type enter.
76
77         WORDS
78
79         read OK;
80
81         writeConfig;
82 }
83
84 function prompt { echo ""; echo -n "$*"; }
85
86 function writeConfig {
87
88         rm -f "$CONFIG_FILE";
89         echo "Writing config to $CONFIG_FILE...";
90
91         _write "PREFIX=\"$PREFIX\"";
92         _write "TMP=\"$TMP\"";
93         _write "APXS2=\"$APXS2\"";
94         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
95         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
96
97         # print out the targets
98         STR="TARGETS=(";
99         for target in ${TARGETS[@]:0}; do
100                 STR="$STR \"$target\"";
101         done;
102         STR="$STR)";
103         _write "$STR";
104
105         _write "OPENSRF_DIR=\"OpenSRF/src/\"";
106         _write "OPENILS_DIR=\"Open-ILS/src/\"";
107         _write "EVERGREEN_DIR=\"Evergreen/\"";
108
109 }
110
111 function _write {
112         echo "$*" >> "$CONFIG_FILE";
113 }
114
115
116
117 buildConfig;