initial "report class" xml and schema generator script
[Evergreen.git] / config.sh
index 7949d31..4e5b6b4 100755 (executable)
--- a/config.sh
+++ b/config.sh
@@ -2,6 +2,7 @@
 # --------------------------------------------------------------------
 # Copyright (C) 2005  Georgia Public Library Service 
 # Bill Erickson <highfalutin@gmail.com>
+# Mike Rylander <mrylander@gmail.com>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -26,16 +27,6 @@ DEFAULT_CONFIG_FILE="install.conf.default";
 
 function buildConfig {
 
-#      if [ -f "$CONFIG_FILE" ]; then
-#              echo "";
-#              echo "Using existing config file \"$CONFIG_FILE\""; 
-#              echo "To generate a new config, remove \"$CONFIG_FILE\"";
-#              echo "";
-#              sleep 3;        
-#              exit 0;
-#      fi
-
-
        if [ -f "$DEFAULT_CONFIG_FILE" ]; then
                source "$DEFAULT_CONFIG_FILE";
        fi;
@@ -47,74 +38,55 @@ function buildConfig {
        echo "-----------------------------------------------------------------------";
 
        prompt "Install prefix [$PREFIX] ";
-       read X;
-       if [ ! -z "$X" ]; then 
-               PREFIX="$X"; 
-               BINDIR="$PREFIX/bin/";
-               LIBDIR="$PREFIX/lib/";
-               PERLDIR="$LIBDIR/perl5/";
-               INCLUDEDIR="$PREFIX/include/";
-       fi
-
-       prompt "Executables directory [$BINDIR] "
-       read X;
-       if [ ! -z "$X" ]; then BINDIR="$X"; fi;
-
-       prompt "Lib directory [$LIBDIR] "
-       read X;
-       if [ ! -z "$X" ]; then LIBDIR="$X"; fi;
-
-       prompt "Perl directory [$PERLDIR] "
-       read X;
-       if [ ! -z "$X" ]; then PERLDIR="$X"; fi;
-
-       prompt "Include files directory [$INCLUDEDIR] "
-       read X;
-       if [ ! -z "$X" ]; then INCLUDEDIR="$X"; fi;
-
-       prompt "Temporary files directory [$TMP] "
-       read X;
-       if [ ! -z "$X" ]; then TMP="$X"; fi;
+       read X; if [ ! -z "$X" ]; then PREFIX="$X"; fi
+
+       BINDIR="$PREFIX/bin/";
+       LIBDIR="$PREFIX/lib/";
+       PERLDIR="$LIBDIR/perl5/";
+       INCLUDEDIR="$PREFIX/include/";
+       ETCDIR="$PREFIX/conf";
+       WEBDIR="$PREFIX/var/web";
+       CGIDIR="$PREFIX/var/cgi-bin";
+       TEMPLATEDIR="$PREFIX/var/templates";
+       CIRCRULESDIR="$PREFIX/var/circ";
+       XSLDIR="$PREFIX/var/xsl";
+       TMP="$(pwd)/.tmp";
+
+       prompt "Web domain for OPAC in Staff Client [$NEW_OPAC_URL] "
+       read X; if [ ! -z "$X" ]; then NEW_OPAC_URL="$X"; fi;
+
+       prompt "Package Name for Staff Client [$NEW_XUL_PACKAGE_NAME] "
+       read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_NAME="$X"; fi;
+
+       prompt "Package Label for Staff Client [$NEW_XUL_PACKAGE_LABEL] "
+       read X; if [ ! -z "$X" ]; then NEW_XUL_PACKAGE_LABEL="$X"; fi;
 
        prompt "Apache2 apxs binary [$APXS2] "
-       read X;
-       if [ ! -z "$X" ]; then APXS2="$X"; fi;
+       read X; if [ ! -z "$X" ]; then APXS2="$X"; fi;
 
        prompt "Apache2 headers directory [$APACHE2_HEADERS] "
-       read X;
-       if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
+       read X; if [ ! -z "$X" ]; then APACHE2_HEADERS="$X"; fi;
 
        prompt "Libxml2 headers directory [$LIBXML2_HEADERS] "
-       read X;
-       if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
+       read X; if [ ! -z "$X" ]; then LIBXML2_HEADERS="$X"; fi;
 
        prompt "Build targets [${TARGETS[@]:0}] "
-       read X;
-       if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
-
-
-       cat <<-WORDS
+       read X; if [ ! -z "$X" ]; then TARGETS=("$X"); fi;
 
-       -----------------------------------------------------------------------
-       Verify the following install directories are sane.
-       Note: * indicates that you must have write privelages for the location
-       -----------------------------------------------------------------------
+       prompt "Bootstrapping Database Driver [$DBDRVR] "
+       read X; if [ ! -z "$X" ]; then DBDRVR="$X"; fi;
 
-       -----------------------------------------------------------------------
-       Install prefix             [$PREFIX]*
-       Temporary files directory  [$TMP]*
-       Apache2 apxs binary        [$APXS2]
-       Apache2 headers directory  [$APACHE2_HEADERS]
-       Libxml2 headers directory  [$LIBXML2_HEADERS]
-       Build targets              [${TARGETS[@]:0}]
-       -----------------------------------------------------------------------
+       prompt "Bootstrapping Database Host [$DBHOST] "
+       read X; if [ ! -z "$X" ]; then DBHOST="$X"; fi;
 
-       If these are not OK, use control-c to break out rerun this script.
-       Otherwise, type enter.
+       prompt "Bootstrapping Database Name [$DBNAME] "
+       read X; if [ ! -z "$X" ]; then DBNAME="$X"; fi;
 
-       WORDS
+       prompt "Bootstrapping Database User [$DBUSER] "
+       read X; if [ ! -z "$X" ]; then DBUSER="$X"; fi;
 
-       read OK;
+       prompt "Bootstrapping Database Password [$DBPW] "
+       read X; if [ ! -z "$X" ]; then DBPW="$X"; fi;
 
        writeConfig;
 }
@@ -124,7 +96,7 @@ function prompt { echo ""; echo -n "$*"; }
 function writeConfig {
 
        rm -f "$CONFIG_FILE";
-       echo "Writing config to $CONFIG_FILE...";
+       echo "Writing installation config to $CONFIG_FILE...";
 
        _write "PREFIX=\"$PREFIX\"";
        _write "BINDIR=\"$BINDIR\"";
@@ -137,6 +109,16 @@ function writeConfig {
        _write "APACHE2_HEADERS=\"$APACHE2_HEADERS\"";
        _write "LIBXML2_HEADERS=\"$LIBXML2_HEADERS\"";
 
+       _write "WEBDIR=\"$WEBDIR\"";
+       _write "TEMPLATEDIR=\"$TEMPLATEDIR\"";
+       _write "ETCDIR=\"$ETCDIR\"";
+       _write "CIRCRULESDIR=\"$CIRCRULESDIR\"";
+       _write "XSLDIR=\"$XSLDIR\"";
+
+       _write "NEW_OPAC_URL=\"$NEW_OPAC_URL\"";
+       _write "NEW_XUL_PACKAGE_NAME=\"$NEW_XUL_PACKAGE_NAME\"";
+       _write "NEW_XUL_PACKAGE_LABEL=\"$NEW_XUL_PACKAGE_LABEL\"";
+
        # print out the targets
        STR="TARGETS=(";
        for target in ${TARGETS[@]:0}; do
@@ -145,9 +127,60 @@ function writeConfig {
        STR="$STR)";
        _write "$STR";
 
-       _write "OPENSRF_DIR=\"OpenSRF/src/\"";
-       _write "OPENILS_DIR=\"Open-ILS/src/\"";
-       _write "EVERGREEN_DIR=\"Evergreen/\"";
+       _write "OPENSRFDIR=\"OpenSRF/src/\"";
+       _write "OPENILSDIR=\"Open-ILS/src/\"";
+       _write "EVERGREENDIR=\"Evergreen/\"";
+
+
+       _write "CGIDIR=\"$CGIDIR\"";
+
+       # db vars
+       _write "DBDRVR=\"$DBDRVR\"";
+       _write "DBHOST=\"$DBHOST\"";
+       _write "DBNAME=\"$DBNAME\"";
+       _write "DBUSER=\"$DBUSER\"";
+       _write "DBPW=\"$DBPW\"";
+
+
+       # Now we'll write out the DB bootstrapping config
+       CONFIG_FILE='Open-ILS/src/cgi-bin/setup.pl';
+       rm -f "$CONFIG_FILE";
+       echo "Writing bootstrapping config to $CONFIG_FILE...";
+
+       STR='$main::config{dsn} =';
+               STR="$STR 'dbi:${DBDRVR}:host=";
+               STR="${STR}${DBHOST};dbname=";
+               STR="${STR}${DBNAME}';";
+       _write "$STR"
+
+       STR='$main::config{usr} =';
+               STR="$STR '$DBUSER';";
+       _write "$STR"
+       
+       STR='$main::config{pw} =';
+               STR="$STR '$DBPW';";
+       _write "$STR"
+       
+       _write '$main::config{index} = "config.cgi";';
+
+
+       prompt "";
+       prompt "";
+       prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
+       prompt "!! If installing openils_all / openils_db !!";
+       prompt "!! Before running 'make install' you MUST !!";
+       prompt "!! create a database for Open-ILS.  Use   !!";
+       prompt "!! the settings that you listed above and !!";
+       prompt "!! the install scripts will create the    !!";
+       prompt "!! database for you.  -miker              !!";
+       prompt "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
+       prompt "";
+       prompt "";
+
+       prompt "To write a new config, run 'make config'";
+       prompt "";
+       prompt "To edit individual install locations (e.g. changing the lib directory),"
+       prompt "edit the install.conf file generated from this script"
 
 }