2 # --------------------------------------------------------------------
3 # Copyright (C) 2005 Georgia Public Library Service
4 # Bill Erickson <highfalutin@gmail.com>
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.
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 # --------------------------------------------------------------------
18 # --------------------------------------------------------------------
19 # Prompts the user for config settings and writes a custom config
20 # file based on these settings
21 # --------------------------------------------------------------------
24 CONFIG_FILE="install.conf";
25 DEFAULT_CONFIG_FILE="install.conf.default";
27 function buildConfig {
29 # if [ -f "$CONFIG_FILE" ]; then
31 # echo "Using existing config file \"$CONFIG_FILE\"";
32 # echo "To generate a new config, remove \"$CONFIG_FILE\"";
39 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
40 source "$DEFAULT_CONFIG_FILE";
45 echo "-----------------------------------------------------------------------";
46 echo "Type Enter to select the default"
47 echo "-----------------------------------------------------------------------";
49 prompt "Temporary files directory [$TMP] "
50 read X; if [ ! -z "$X" ]; then TMP="$X"; fi;
52 prompt "Install prefix [$PREFIX] ";
54 if [ ! -z "$X" ]; then
56 BINDIR="$PREFIX/bin/";
57 LIBDIR="$PREFIX/lib/";
58 PERLDIR="$LIBDIR/perl5/";
59 INCLUDEDIR="$PREFIX/include/";
62 TEMPLATEDIR="$PREFIX/templates";
65 prompt "Executables directory [$BINDIR] "
66 read X; if [ ! -z "$X" ]; then BINDIR="$X"; fi;
68 prompt "Lib directory [$LIBDIR] "
69 read X; if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
71 prompt "Perl directory [$PERLDIR] "
72 read X; if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
74 prompt "Include files directory [$INCLUDEDIR] "
75 read X; if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
77 prompt "Config files directory [$ETCDIR] "
78 read X; if [ ! -z "$X" ]; then ETCDIR="$X"; fi;
80 prompt "Web Root Directory [$WEBDIR] "
81 read X; if [ ! -z "$X" ]; then WEBDIR="$X"; fi;
83 prompt "Templates directory [$TEMPLATEDIR] "
84 read X; if [ ! -z "$X" ]; then TEMPLATEDIR="$X"; fi;
86 prompt "Apache2 apxs binary [$APXS2] "
87 read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
89 prompt "Apache2 headers directory [$APACHE2_HEADERS] "
90 read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
92 prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
93 read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
95 prompt "Build targets [${TARGETS[@]:0}] "
96 read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
101 function prompt { echo ""; echo -n "$*"; }
103 function writeConfig {
105 rm -f "$CONFIG_FILE";
106 echo "Writing config to $CONFIG_FILE...";
108 _write "PREFIX=\"$PREFIX\"";
109 _write "BINDIR=\"$BINDIR\"";
110 _write "LIBDIR=\"$LIBDIR\"";
111 _write "PERLDIR=\"$PERLDIR\"";
112 _write "INCLUDEDIR=\"$INCLUDEDIR\"";
114 _write "TMP=\"$TMP\"";
115 _write "APXS2=\"$APXS2\"";
116 _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
117 _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
119 _write "WEBDIR=\"$WEBDIR\"";
120 _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
121 _write "ETCDIR=\"$ETCDIR\"";
123 # print out the targets
125 for target in ${TARGETS[@]:0}; do
126 STR="$STR \"$target\"";
131 _write "OPENSRFDIR=\"OpenSRF/src/\"";
132 _write "OPENILSDIR=\"Open-ILS/src/\"";
133 _write "EVERGREENDIR=\"Evergreen/\"";
135 prompt "To write a new config, run 'make config'";
141 echo "$*" >> "$CONFIG_FILE";