]> git.evergreen-ils.org Git - Evergreen.git/blob - config.sh
movin on, adding exceptions, more more more
[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; if [ ! -z "$X" ]; then TMP="$X"; fi;
51
52         prompt "Install prefix [$PREFIX] ";
53         read X;
54         if [ ! -z "$X" ]; then 
55                 PREFIX="$X"; 
56                 BINDIR="$PREFIX/bin/";
57                 LIBDIR="$PREFIX/lib/";
58                 PERLDIR="$LIBDIR/perl5/";
59                 INCLUDEDIR="$PREFIX/include/";
60                 WEBDIR="$PREFIX/web";
61                 ETCDIR="$PREFIX/etc";
62                 TEMPLATEDIR="$PREFIX/templates";
63         fi
64
65         prompt "Executables directory [$BINDIR] "
66         read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
67
68         prompt "Lib directory [$LIBDIR] "
69         read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
70
71         prompt "Perl directory [$PERLDIR] "
72         read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
73
74         prompt "Include files directory [$INCLUDEDIR] "
75         read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
76
77         prompt "Config files directory [$ETCDIR] "
78         read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
79
80         prompt "Web Root Directory [$WEBDIR] "
81         read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
82
83         prompt "Templates directory [$TEMPLATEDIR] "
84         read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
85
86         prompt "Apache2 apxs binary [$APXS2] "
87         read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
88
89         prompt "Apache2 headers directory [$APACHE2_HEADERS] "
90         read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
91
92         prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
93         read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
94
95         prompt "Build targets [${TARGETS[@]:0}] "
96         read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
97
98         writeConfig;
99 }
100
101 function prompt { echo ""; echo -n "$*"; }
102
103 function writeConfig {
104
105         rm -f "$CONFIG_FILE";
106         echo "Writing config to $CONFIG_FILE...";
107
108         _write "PREFIX=\"$PREFIX\"";
109         _write "BINDIR=\"$BINDIR\"";
110         _write "LIBDIR=\"$LIBDIR\"";
111         _write "PERLDIR=\"$PERLDIR\"";
112         _write "INCLUDEDIR=\"$INCLUDEDIR\"";
113
114         _write "TMP=\"$TMP\"";
115         _write "APXS2=\"$APXS2\"";
116         _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
117         _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
118
119         _write "WEBDIR=\"$WEBDIR\"";
120         _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
121         _write "ETCDIR=\"$ETCDIR\"";
122
123         # print out the targets
124         STR="TARGETS=(";
125         for target in ${TARGETS[@]:0}; do
126                 STR="$STR \"$target\"";
127         done;
128         STR="$STR)";
129         _write "$STR";
130
131         _write "OPENSRFDIR=\"OpenSRF/src/\"";
132         _write "OPENILSDIR=\"Open-ILS/src/\"";
133         _write "EVERGREENDIR=\"Evergreen/\"";
134
135         prompt "To write a new config, run 'make config'";
136         prompt "";
137
138 }
139
140 function _write {
141         echo "$*" >> "$CONFIG_FILE";
142 }
143
144
145
146 buildConfig;