Fix broken optional database name prefixing
authorAndy Witter <awitter@georgialibraries.org>
Mon, 14 Sep 2015 16:09:32 +0000 (12:09 -0400)
committerAndy Witter <awitter@georgialibraries.org>
Mon, 14 Sep 2015 16:09:32 +0000 (12:09 -0400)
Signed-off-by: Andy Witter <awitter@georgialibraries.org>
GenaSYS.sh

index ecfa883..2a9c04e 100755 (executable)
@@ -25,8 +25,8 @@
     PURPOSE_="Generate config files needed for Evergreen-ILS Cluster"
    SYNOPSIS_="$NAME_"
    REQUIRES_="standard GNU commands, apt, dpkg"
-    VERSION_="1.50"
-       DATE_="2010-09-23; last update: 2015-09-09"
+    VERSION_="1.51"
+       DATE_="2010-09-23; last update: 2015-09-14"
      AUTHOR_="Andy Witter <awitter@georgialibraries.org>"
         URL_="http://evergreen-ils.org"
    CATEGORY_="devel"
@@ -340,6 +340,29 @@ if [ "$USE_HOSTNAME_PREFIX" = "y" ] || [ "$USE_HOSTNAME_PREFIX" = "Y" ]
 fi
 }
 
+Ask_Database_Prefix () { ### Get the prefix for the database name.
+echo
+TitleBar "Database Prefix Configuration"
+echo
+while true; do
+    echo "The prefix used for the hostname can also"
+    echo "be used to prefix the database name."
+    echo
+    read -n 1 -p "Do you want to add a prefix to the database name in this cluster? [y/n] : " USE_DATABASE_PREFIX
+    case $USE_DATABASE_PREFIX in
+        [Yy]* ) echo ; break;;
+        [Nn]* ) echo ; break;;
+        * ) echo " Please answer yes or no.";;
+    esac
+done
+if [ "$USE_DATABASE_PREFIX" = "y" ] || [ "$USE_DATABASE_PREFIX" = "Y" ]
+        then
+        echo 
+        echo -e "The database name prefix $COL_BR_YELLOW $HOSTNAME_PREFIX $COL_RESET will be used."
+        echo
+fi
+}
+
 Choose_SSL_Cert () { ### Prompt for CA or self signed certificate.
 echo;echo;echo;echo
 #echo -e $COL_BR_BLUE"_____SSL_Certificate_Configuration_____"$COL_RESET 
@@ -1105,6 +1128,15 @@ fi
 Write_Config_File USE_HOSTNAME_PREFIX
 Write_Config_File HOSTNAME_PREFIX
 
+if [ -z "$USE_DATABASE_PREFIX" ] || [ "$USE_CONFIG_FILE" == "0" ]
+then 
+       if [ "$USE_HOSTNAME_PREFIX" = "y" ] || [ "$USE_HOSTNAME_PREFIX" = "Y" ]
+       then
+               Ask_Database_Prefix
+       fi
+fi
+Write_Config_File USE_DATABASE_PREFIX
+
 if [ -z $USE_CA_CERT ]  || [ "$USE_CONFIG_FILE" == "0" ] 
 then
        Choose_SSL_Cert
@@ -1747,9 +1779,9 @@ NETCFGFILE="$OUTDIR/${CLUSTERDOMAINNAME}_network_config.txt"
 
 ## begin preparation of opensrf.xml
 cp $TEMPLATEDIR/opensrf.xml/opensrf.xml-header $TMPOPENSRF_XML
-if [ "$USE_HOSTNAME_PREFIX" = "y" ] || [ "$USE_HOSTNAME_PREFIX" = "Y" ]
+if [ "$USE_DATABASE_PREFIX" = "y" ] || [ "$USE_DATABASE_PREFIX" = "Y" ]
 then
-       sed -i "s^<db>evergreen^<db>${PREFIX}_evergreen^g" $TMPOPENSRF_XML
+       sed -i "s^<db>evergreen^<db>${HOSTNAME_PREFIX}_evergreen^g" $TMPOPENSRF_XML
 fi
 #sed -i "s^DatabasePassword^$DATABASE_PASSWORD^g" $TMPOPENSRF_XML
 sed -i "s^DatabasePassword^$(echo $DATABASE_PASSWORD | sed  -e 's^&^\\\&^g' -e 's/\^/\\\^/g')^g" $TMPOPENSRF_XML