[ucarp/el6] Init fixes.

Jon Ciesla limb at fedoraproject.org
Mon Nov 12 20:46:55 UTC 2012


commit 20ecf82b26a9e45fa0faf729163eab2a48c9618e
Author: Jon Ciesla <limburgher at gmail.com>
Date:   Mon Nov 12 14:44:59 2012 -0600

    Init fixes.

 ucarp.init |   31 ++++++++++++++++++++++---------
 ucarp.spec |    9 ++++++++-
 2 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/ucarp.init b/ucarp.init
index c7f6296..0680c07 100755
--- a/ucarp.init
+++ b/ucarp.init
@@ -24,8 +24,11 @@
 [ ${NETWORKING} = "no" ] && exit 0
 
 get_files() {
-    FILES=`find ${CONFDIR} -maxdepth 1 -type f -name 'vip-*.conf' \
-        -printf "%f\n" | egrep '^vip-[[:digit:]]+\.conf$' | LC_COLLATE="C" sort`
+    local FILE
+    cd ${CONFDIR}
+    for FILE in *.conf
+       do [ "${FILE}" != "${CONFDIR}/vip-common.conf" ] && echo -n "${FILE} "
+    done
 }
 
 prog=$"common address redundancy protocol daemon"
@@ -40,7 +43,7 @@ start() {
 
     echo -n $"Starting ${prog}: "
 
-    get_files
+    FILES=`get_files`
 
     if [ -z "${FILES}" ]; then
         ${LOGGER} "no virtual addresses are configured in ${CONFDIR}"
@@ -48,17 +51,27 @@ start() {
         RETVAL=1
     else
         for FILE in ${FILES}; do
-            # Check that the file name gives us an ID between 1 and 255
-            ID=`echo ${FILE}| sed 's/^vip-\(.*\).conf/\1/'`
+
+            unset ID PASSWORD BIND_INTERFACE SOURCE_ADDRESS VIP_ADDRESS OPTIONS
+
+           . ${CONFDIR}/vip-common.conf
+           . ${CONFDIR}/${FILE}
+
+           # If the SOURCE_ADDRESS is not defined in the config, guess it from the ifcfg file
+           [ ${SOURCE_ADDRESS} ] || SOURCE_ADDRESS=$( . /etc/sysconfig/network-scripts/ifcfg-${BIND_INTERFACE} ; echo $IPADDR )
+
+           # If a value for MASTER is set in the file, use it to set advskew value
+           # The default advskew is 0, so if we are not the master, add advskew=1 to the options
+           [ "${MASTER:-NULL}" == "${SOURCE_ADDRESS}" ] || OPTIONS="${OPTIONS} --advskew=1"
+
+           # Set the ID from the config file if it's defined, otherwise guess from the filename
+           [ ${ID} ] || ID=`echo ${FILE} | sed 's/^vip-\(.*\).conf/\1/'`
+
             if [ ${ID} -lt 1 -o ${ID} -gt 255 ]; then
                 ${LOGGER} "ID out of range (1-255) for ${FILE}, skipped VIP ID ${ID}"
                 continue
             fi
 
-            unset PASSWORD BIND_INTERFACE SOURCE_ADDRESS VIP_ADDRESS OPTIONS
-            # Source ucarp settings
-            . ${CONFDIR}/vip-common.conf
-            . ${CONFDIR}/${FILE}
             TMP_RETVAL=0
 
             if [ -z "${PASSWORD}" ]; then
diff --git a/ucarp.spec b/ucarp.spec
index cbfde73..0b43bc7 100644
--- a/ucarp.spec
+++ b/ucarp.spec
@@ -1,7 +1,7 @@
 Summary: Common Address Redundancy Protocol (CARP) for Unix
 Name: ucarp
 Version: 1.5.2
-Release: 3.1%{?dist}
+Release: 4%{?dist}
 # See the COPYING file which details everything
 License: MIT and BSD
 Group: System Environment/Daemons
@@ -100,6 +100,13 @@ fi
 %{_sbindir}/ucarp
 
 %changelog
+* Thu Oct 25 2012 Jon Ciesla <limburgher at gmail.com> - 1.5.2-4
+- Init script fixes from Trent Johnson and Dan Bassett at oreilly.com:
+- Changed the get_files function in order to allow file names that don't include the ID.
+- Moved config sourcing earlier in the script, allowing the ID parameter to be defined in the config, rather than the filename, if desired.
+- Added a MASTER parameter option to the config file, allowing a master node to be selected in a deterministic way using the advskew.
+- Added the ability to define the SOURCE_ADDRESS either in the config file, or using IPADDR from the ifcfg-$BIND_INTERFACE file.
+
 * Thu Oct 25 2012 Jon Ciesla <limburgher at gmail.com> - 1.5.2-3.1
 - Patch for crash.
 


More information about the scm-commits mailing list