making the install script break out opensrf, openils, and evergreen a little
[Evergreen.git] / install.sh
index d6883b0..2e438c8 100755 (executable)
 # --------------------------------------------------------------------
 # ILS install script
 # --------------------------------------------------------------------
+CONFIG_FILE="install.conf";
+DEFAULT_CONFIG_FILE="install.conf.default";
 
-# *!*!* EDIT THESE *!*!*
-# --------------------------------------------------------------------
-# Here define all of the necessary install variables 
-# --------------------------------------------------------------------
-APXS2="/pines/apps/apache2/bin/apxs";
-PREFIX="/pines/";
-TMP="/tmp/pines/";
-APACHE2_HEADERS="/pines/apps/apache2/include/";
-LIBXML2_HEADERS="/usr/include/libxml2/";
-TARGETS=("OpenSRF" "Open-ILS" "Evergreen");
-# --------------------------------------------------------------------
 
 # --------------------------------------------------------------------
-# if FORCE is set to any non-empty value, we'll use 
-# the default settings
-FORCE=$1 
+# Loads all of the path information from the user setting 
+# install variables as it goes
 # --------------------------------------------------------------------
 
+function fail {
+       MSG="$1";
+       echo "A build error occured: $MSG";
+       exit 99;
+}
 
 
+#function postMessage {
 
+#cat <<-WORDS
+#      --------------------------------------------------------------------
 
-# --------------------------------------------------------------------
-# Loads all of the path information from the user setting 
-# install variables as it goes
-# --------------------------------------------------------------------
-function verifyInstallPaths {
 
-       cat <<-WORDS
+#}
 
-       -----------------------------------------------------------------------
-       Verify the following install directories are sane.
-       Note: * indicates that you must have write privelages for the location
-       -----------------------------------------------------------------------
 
-       -----------------------------------------------------------------------
-       Install prefix            [$PREFIX]*
-       Temporary files directory [$TMP]*
-       Apache2 apxs binary       [$APXS2]
-       Apache2 header directory  [$APACHE2_HEADERS]
-       Libxml2 header directory  [$LIBXML2_HEADERS]
-       Building targets          [${TARGETS[@]:0}];
-       -----------------------------------------------------------------------
-
-       If these are not OK, use control-c to break out and fix the variables 
-       at the top of this script.  Otherwise, type enter.
-
-       WORDS
-       read OK;
-}
 
 # --------------------------------------------------------------------
 # Makes sure the install directories exist and are writable
 # --------------------------------------------------------------------
 function mkInstallDirs {
 
-       mkdir -p "$PREFIX";
+       if installing; then
 
-       if [ "$?" != "0" ]; then
-               echo "Error creating $PREFIX";
-               exit 99;
-       fi
+               mkdir -p "$PREFIX";
+               if [ "$?" != "0" ]; then
+                       fail "Error creating $PREFIX";
+               fi
 
-       mkdir -p "$TMP";
-       if [ "$?" != "0" ]; then
-               echo "Error creating $TMP";
-               exit 99;
-       fi
+               if [ ! -w "$PREFIX" ]; then
+                       fail "We don't have write access to $PREFIX";
+               fi
 
-       if [ ! -w "$PREFIX" ]; then
-               echo "We don't have write access to $PREFIX";
-               exit 99;
        fi
 
-       if [ ! -w "$TMP" ]; then
-               echo "We don't have write access to $TMP";
-               exit 99;
+       if building; then
+
+               mkdir -p "$TMP";
+               if [ "$?" != "0" ]; then
+                       fail "Error creating $TMP";
+               fi
+
+               if [ ! -w "$TMP" ]; then
+                       fail "We don't have write access to $TMP";
+               fi
        fi
 
+       
+
+}
+
+function installing {
+       if [ -z "$INSTALLING" ]; then return 1; fi;
+       return 0;
+}
+
+function building {
+       if [ -z "$BUILDING" ]; then return 1; fi;
+       return 0;
+}
+
+
+
+# --------------------------------------------------------------------
+# Loads the config file.  If it can't fine CONFIG_FILE, it attempts to
+# use DEFAULT_CONFIG_FILE.  If it can't find that, it fails.
+# --------------------------------------------------------------------
+function loadConfig {
+       if [ ! -f "$CONFIG_FILE" ]; then
+               if [ -f "$DEFAULT_CONFIG_FILE" ]; then
+                       echo "+ + + Copying $DEFAULT_CONFIG_FILE to $CONFIG_FILE and using its settings...";
+                       cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE";
+               else
+                       fail "config file \"$CONFIG_FILE\" cannot be found";
+               fi
+       fi
+       source "$CONFIG_FILE";
 }
 
 
+
+
+# install targets
+#
+# opensrf_jserver - custom 'single-domain' jabber server which may be used in place of jabberd2
+# opensrf_router  - jabber router.  
+# opensrf_gateway - mod_ils_gateway, Apache module for proxying API calls
+# opensrf_srfsh   - diagnostic shell interface to OpenSRF
+# opensrf_perl         - install the OpenSRF perl modules
+# opensrf_all          - builds all OpenSRF compenents
+# openils_marcdumper - utility code for converting MARC to MARCXML
+# openils_perl                 - install the Open-ILS perl modules
+# openils_all                  - builds all OpenILS compenents
+# openils_web                  - copies over the javascript and html templates to the web root directory
+# evergreen_xul_client   - client XUL application
+# evergreen_all        - builds all Evergreen components
 function runInstall {
 
-       [ -z "$FORCE" ] && verifyInstallPaths;
-       mkInstallDirs;
+
 
        # pass the collected variables to make
        for target in ${TARGETS[@]:0}; do
 
-               target="$target/src";
+               cat <<-MSG
+
+               --------------------------------------------------------------------
+               Building $target
+               --------------------------------------------------------------------
+
+               MSG
+
+               MAKE="make APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP \
+                       APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS \
+                       BINDIR=$BINDIR LIBDIR=$LIBDIR PERLDIR=$PERLDIR INCLUDEDIR=$INCLUDEDIR";
+
+               case "$target" in
+       
+                       # OpenSRF ---                   
+
+                       "opensrf_all")
+                               if building;    then $MAKE -C "$OPENSRF_DIR" all; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" install; fi;
+                               ;;
 
-               make -C "$target" \
-                       APXS2="$APXS2" \
-                       PREFIX="$PREFIX" \
-                       TMP="$TMP" \
-                       APCHE2_HEADERS="$APACHE2_HEADERS" \
-                       LIBXML2_HEADERS="$LIBXML2_HEADERS" \
-                       all;    
+                       "opensrf_jserver" )
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "jserver"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "jserver-install"; fi;
+                               ;;      
 
+                       "opensrf_router" ) 
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "router"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "router-install"; fi;
+                               ;;
+
+                       "opensrf_gateway" )
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "gateway"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "gateway-install"; fi;
+                               ;;
+
+                       "opensrf_srfsh" ) 
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "srfsh"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "srfsh-install"; fi;
+                               ;;
+
+                       "opensrf_perl")
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "perl-install"; fi;
+                               ;;
+
+
+                       # OpenILS ---                   
+
+                       "openils_all")
+                               if building;    then $MAKE -C "$OPENILS_DIR" all; fi;
+                               if installing; then $MAKE -C "$OPENILS_DIR" install; fi;
+                               ;;
+
+                       "openils_perl")
+                               if installing; then $MAKE -C "$OPENILS_DIR" "perl-install"; fi;
+                               ;;
+
+
+                       # Evergreen ---                         
+
+                       "evergreen_xul_client")
+                               if building;    then $MAKE -C "$EVERGREEN_DIR" xul; fi;
+                               ;;
+
+
+                       *) fail "Unknown target: $target";;
+
+               esac
+
+       done
+}
+
+
+# --------------------------------------------------------------------
+# Checks command line parameters for special behavior
+# Supported params are:
+# clean - cleans all build files
+# build - builds the specified sources
+# install - installs the specified sources
+# --------------------------------------------------------------------
+function checkParams {
+
+       if [ -z "$1" ]; then return; fi;
+
+       for arg in "$@"; do
+
+               lastArg="$arg";
+
+               case "$arg" in
+
+                       "clean") 
+                               cleanMe;;
+
+                       "build")
+                               BUILDING="1";;
+
+                       "install")
+                               INSTALLING="1";;
+
+                       *) fail "Unknown command line argument: $arg";;
+               esac
        done
+
+       if [ "$lastArg" = "clean" ]; then exit 0; fi;
 }
 
 
+function cleanMe {
+       loadConfig;
+       make -C "$OPENSRF_DIR" clean;
+       make -C "$OPENILS_DIR"  clean;
+       make -C "$EVERGREEN_DIR" clean;
+}
+
+checkParams "$@";
+
+
+if building; then echo "Building..."; fi;
+if installing; then echo "Installing..."; fi;
+
 
+# --------------------------------------------------------------------
 # Kick it off...
+# --------------------------------------------------------------------
+loadConfig;
+mkInstallDirs;
 runInstall;
 
+
+