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