rpms/ucarp/devel vip-001.list.example, NONE, 1.1 vip-down, NONE, 1.1 vip-helper.sh, NONE, 1.1 vip-up, NONE, 1.1 carp.init, 1.3, 1.4 ucarp.spec, 1.11, 1.12 vip-001.conf.example, 1.2, 1.3

Matthias Saou (thias) fedora-extras-commits at redhat.com
Wed Nov 29 12:00:41 UTC 2006


Author: thias

Update of /cvs/extras/rpms/ucarp/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19956

Modified Files:
	carp.init ucarp.spec vip-001.conf.example 
Added Files:
	vip-001.list.example vip-down vip-helper.sh vip-up 
Log Message:
Improvements from Denis Ovsienko (#200395) and rebuild against new libpcap.



--- NEW FILE vip-001.list.example ---
# Comments are filtered out atomatically...
10.0.0.254/24 dev eth0

# ... and empty lines too.
192.168.1.254/24 dev eth1

# You can assign as many VIPs to a single virtual router, as you need.
172.16.2.32/24 dev eth2
172.16.3.67/24 dev eth2
172.16.4.88/24 dev eth2


--- NEW FILE vip-down ---
#!/bin/sh

usage()
{
	echo "This script is intended to be run by UCARP daemon."
	echo "Usage: $0 <network interface> <IP address> <anything>"
	echo "Usage: $0 <anything> <255.255.255.255> <virtual router ID>"
	exit 1
}

[ $# -eq 3 ] || usage

case $2 in
	255.255.255.255)
		# New-style invocation. Process the the list of addresses
		# specific to this virtual router.
		MYDIR=`dirname $0`
		$MYDIR/vip-helper.sh $3 del
		;;
	*)
		# Old-style invocation. Just add a single address to the same
		# interface UCARP daemon is working on.
		ip address del $2/32 dev $1
		;;
esac



--- NEW FILE vip-helper.sh ---
#!/bin/sh

usage()
{
	echo "This script is intended to be invoked by vip-up.sh or vip-down.sh"
	exit 1
}

[ $# -eq 2 ] || usage

VRID=$1
OP=$2
MYDIR=`dirname $0`

if [ "$VRID" -lt "1" -o "$VRID" -gt 255 ]; then
	echo "VRID must be in 1..255 range"
	exit 2
fi

LISTFILE="$MYDIR/vip-$VRID.list"
if ! [ -s "$LISTFILE" ]; then
	echo "$LISTFILE is missing or empty, no action taken"
	exit 1
fi

egrep ^[^#] $LISTFILE | sed -e 's/^ *\(.*\) *$/\1/' \
	| xargs --max-lines=1 ip address $OP &>/dev/null



--- NEW FILE vip-up ---
#!/bin/sh

usage()
{
	echo "This script is intended to be run by UCARP daemon."
	echo "Usage: $0 <network interface> <IP address> <anything>"
	echo "Usage: $0 <anything> <255.255.255.255> <virtual router ID>"
	exit 1
}

[ $# -eq 3 ] || usage

case $2 in
	255.255.255.255)
		# New-style invocation. Process the the list of addresses
		# specific to this virtual router.
		MYDIR=`dirname $0`
		$MYDIR/vip-helper.sh $3 add
		;;
	*)
		# Old-style invocation. Just add a single address to the same
		# interface the UCARP daemon is working on.
		ip address add $2/32 dev $1
		;;
esac



Index: carp.init
===================================================================
RCS file: /cvs/extras/rpms/ucarp/devel/carp.init,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- carp.init	22 Aug 2006 13:08:17 -0000	1.3
+++ carp.init	29 Nov 2006 12:00:11 -0000	1.4
@@ -2,8 +2,7 @@
 # $Id$
 #
 # chkconfig: - 91 09
-# description: Starts and stops ucarp. \
-#	       used to provide common address redundancy.
+# description: Starts and stops the common address redundancy protocol daemon
 
 # Source function library.
 . /etc/init.d/functions
@@ -15,129 +14,136 @@
 [ ${NETWORKING} = "no" ] && exit 0
 
 get_files() {
-    FILES=`find /etc/sysconfig/carp -maxdepth 1 -type f -name 'vip-*.conf' \
-           -printf "%f\n" | LC_COLLATE="C" sort`
+    FILES=`find $CONFDIR -maxdepth 1 -type f -name 'vip-*.conf' \
+        -printf "%f\n" | egrep '^vip-[[:digit:]]+\.conf$' | LC_COLLATE="C" sort`
 }
 
 prog=$"common address redundancy protocol daemon"
-RETVAL=0
+OUR_INITLOG_ARGS="-n carp -e 2 -s"
+OUR_INITLOG="initlog ${OUR_INITLOG_ARGS}"
+CONFDIR=/etc/sysconfig/carp
+UPSCRIPT=$CONFDIR/vip-up
+DOWNSCRIPT=$CONFDIR/vip-down
 
 start() {
+    RETVAL=-1
+    VIP_RETVAL=0
+
     echo -n $"Starting ${prog}: "
 
     get_files
 
     if [ -z "${FILES}" ]; then
-        failure $"no virtual addresses are configured in /etc/sysconfig/carp/"
+        failure $"no virtual addresses are configured in $CONFDIR:"
         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/'`
             if [ ${ID} -lt 1 -o ${ID} -gt 255 ]; then
-                initlog $INITLOG_ARGS -n carp -s "configuration file name ${FILE} gave us a bad ID of ${ID}:" -e 2
-                RETVAL=1
-                break
+                ${OUR_INITLOG} $"ID out of range (1-255) for ${FILE}, skipped VIP ID ${ID}:"
+                continue
             fi
 
+            unset PASSWORD BIND_INTERFACE BIND_ADDRESS VIP OPTIONS
             # Source ucarp settings
-            . /etc/sysconfig/carp/${FILE}
+            . $CONFDIR/${FILE}
+            TMP_RETVAL=0
 
-            # Check that we have the ifcfg-<if> file for the main interface
-            if [ -f /etc/sysconfig/network-scripts/ifcfg-${BIND_INTERFACE} ]; then
-                . /etc/sysconfig/network-scripts/ifcfg-${BIND_INTERFACE}
-            else
-                initlog $INITLOG_ARGS -n carp -s $"no ifcfg-${BIND_INTERFACE} file found for carp ${FILE} configuration:" -e 2
-                RETVAL=1
-                break
+            if [ -z "${PASSWORD}" ]; then
+                ${OUR_INITLOG} $"no PASSWORD found in ${FILE}, skipped VIP ID ${ID}:"
+                TMP_RETVAL=1
             fi
-            # Check that the ifcfg-<if> file does have an IPADDR
-            BIND_ADDRESS=${IPADDR}
             if [ -z "${BIND_ADDRESS}" ]; then
-                initlog $INITLOG_ARGS -n carp -s $"no IPADDR found in interface file ifcfg-${BIND_INTERFACE}:" -e 2
-                RETVAL=1
-                break
-            fi
-
-            # Check that we have the ifcfg-<if> file for the virtual interface
-            if [ -f /etc/sysconfig/network-scripts/ifcfg-${VIP_INTERFACE} ]; then
-                . /etc/sysconfig/network-scripts/ifcfg-${VIP_INTERFACE}
-            else
-                initlog $INITLOG_ARGS -n carp -s $"no ifcfg-${VIP_INTERFACE} file found for carp ${FILE} configuration:" -e 2
-                RETVAL=1
-                break
+                ${OUR_INITLOG} $"no BIND_ADDRESS found in ${FILE}, skipped VIP ID ${ID}:"
+                TMP_RETVAL=1
             fi
-            # Check that the ifcfg-<if> file does have an IPADDR
-            VIP_ADDRESS=${IPADDR}
             if [ -z "${VIP_ADDRESS}" ]; then
-                initlog $INITLOG_ARGS -n carp -s "no IPADDR found in interface file ifcfg-${VIP_INTERFACE}:" -e 2
-                RETVAL=1
-                break
+                ${OUR_INITLOG} $"no VIP_ADDRESS found in ${FILE}, skipped VIP ID ${ID}:"
+                TMP_RETVAL=1
+            fi
+
+            # If one of more of the above failed, skip the daemon launch
+            if [ ${TMP_RETVAL} -ne 0 ]; then
+                VIP_RETVAL=1
+                continue
             fi
 
-            daemon /usr/sbin/ucarp -v ${ID} -p ${PASSWORD} -s ${BIND_ADDRESS} -a ${VIP_ADDRESS} -i ${VIP_INTERFACE} ${OPTIONS} -B --upscript=/etc/sysconfig/carp/vip-up --downscript=/etc/sysconfig/carp/vip-down
+            [ ${RETVAL} -eq -1 ] && RETVAL=0
+            daemon /usr/sbin/ucarp -v ${ID} -m ${ID} -p ${PASSWORD} -s ${BIND_ADDRESS} -a ${VIP_ADDRESS} -i ${BIND_INTERFACE} ${OPTIONS} -B --upscript=$UPSCRIPT --downscript=$DOWNSCRIPT >/dev/null
             LAUNCH_RETVAL=$?
             [ ${LAUNCH_RETVAL} -ne 0 ] && RETVAL=1
         done
-        [ "${RETVAL}" -ne 0 ] && failure $"error in one or more of the carp configurations, see above:"
+
+        # failure/success or warning if launch worked with some vip errors
+        if [ ${RETVAL} -eq 0 -a ${VIP_RETVAL} -eq 0 ]; then
+            success $"all carp configurations were applied successfully:"
+            touch /var/lock/subsys/carp
+        elif [ ${RETVAL} -eq 0 -a ${VIP_RETVAL} -eq 1 ]; then
+            warning $"error in one or more of the carp configurations:"
+        else
+            failure $"error running one or more of the ucarp daemon instances:"
+        fi
     fi
     echo
-    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/carp
 }
 
 stop() {
-    echo -n $"Shutting down $prog: "
-    killproc /usr/sbin/ucarp
+    echo -n $"Stopping $prog: "
+    killproc /usr/sbin/ucarp >/dev/null
     RETVAL=$?
 
-    # We put all interfaces managed by ucarp down when stopping the service
-    # to avoid conflicting "leftovers"
+    # We unassign all UCARP-managed VIPs when stopping the service
+    # to avoid conflicting "leftovers".
 
     get_files
 
     [ ! -z "${FILES}" ] && \
     for FILE in ${FILES}; do
-
+        ID=`echo ${FILE}| sed 's/^vip-\(.*\).conf/\1/'`
+        unset PASSWORD BIND_INTERFACE BIND_ADDRESS VIP OPTIONS
         # Source ucarp settings
-        . /etc/sysconfig/carp/${FILE}
-
-        # Check that we have the ifcfg-<if> file for the virtual interface
-        if [ -f /etc/sysconfig/network-scripts/ifcfg-${VIP_INTERFACE} ]; then
-            if /sbin/ifconfig ${VIP_INTERFACE} down >/dev/null 2>&1; then
-                initlog $INITLOG_ARGS -n carp -s $"bringing down carp managed interface ${VIP_INTERFACE}:" -e 1
-            else
-                initlog $INITLOG_ARGS -n carp -s $"bringing down carp managed interface ${VIP_INTERFACE}:" -e 2
-            fi
-        fi
+        . $CONFDIR/${FILE}
+        $DOWNSCRIPT $BIND_INTERFACE $VIP_ADDRESS ${ID} &>/dev/null
+        #TMP_RETVAL=$?
+        #[ ${TMP_RETVAL} -ne 0 ] && VIP_RETVAL=1
     done
+
+    # failure/success (no warning, too complicated to handle properly)
+    if [ ${RETVAL} -eq 1 ]; then
+        failure $"it seems like no ucarp daemon were running:"
+    else
+        success $"all ucarp daemons stopped and IP addresses unassigned:"
+        rm -f /var/lock/subsys/carp
+    fi
     echo
-    [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/carp
 }
 
 # See how we were called.
 case "$1" in
   start)
-	start
-	;;
+    start
+    ;;
   stop)
-	stop
-	;;
-  restart|reload)
-	stop
-	start
-	;;
+    stop
+    ;;
+  restart)
+    stop
+    start
+    ;;
   condrestart)
-	if [ -f /var/lock/subsys/carp ]; then
-	    stop
-	    start
-	fi
-	;;
+    if [ -f /var/lock/subsys/carp ]; then
+      stop
+      start
+    fi
+    ;;
   status)
-	status /usr/sbin/ucarp
-	;;
+    status /usr/sbin/ucarp
+    ;;
   *)
-	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
-	exit 1
+    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+    exit 1
 esac
 
 exit $RETVAL
+


Index: ucarp.spec
===================================================================
RCS file: /cvs/extras/rpms/ucarp/devel/ucarp.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ucarp.spec	28 Aug 2006 16:40:12 -0000	1.11
+++ ucarp.spec	29 Nov 2006 12:00:11 -0000	1.12
@@ -1,13 +1,17 @@
 Summary: Common Address Redundancy Protocol (CARP) for Unix
 Name: ucarp
 Version: 1.2
-Release: 4%{?dist}
+Release: 6%{?dist}
 License: BSD
 Group: System Environment/Daemons
 URL: http://www.ucarp.org/
 Source0: http://download.pureftpd.org/pub/ucarp/ucarp-%{version}.tar.bz2
 Source1: carp.init
 Source2: vip-001.conf.example
+Source3: vip-001.list.example
+Source4: vip-up
+Source5: vip-down
+Source6: vip-helper.sh
 Patch0: ucarp-1.3-pre.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 Requires(post): /sbin/chkconfig
@@ -45,32 +49,22 @@
 
 %install
 %{__rm} -rf %{buildroot}
-%makeinstall
+%{__make} install DESTDIR=%{buildroot}
 %find_lang %{name}
 
 # Install the init script
-%{__install} -D -m 0755 %{SOURCE1} \
+%{__install} -D -p -m 0755 %{SOURCE1} \
     %{buildroot}/etc/rc.d/init.d/carp
 
-# Install the example config file
-%{__install} -D -m 0600 %{SOURCE2} \
-    %{buildroot}/etc/sysconfig/carp/vip-001.conf.example
-
-# Install trivial interface up/down scripts
-%{__cat} << 'EOF' > %{buildroot}/etc/sysconfig/carp/vip-up
-#!/bin/sh
-# We could use ifup directly, but it complains if the address is already used
-#/sbin/ifup $1
-. /etc/sysconfig/network-scripts/ifcfg-$1
-#exec /sbin/ip addr add ${IPADDR}/${NETMASK} dev "$1"
-exec /sbin/ifconfig $1 ${IPADDR} netmask ${NETMASK} up
-EOF
-%{__cat} << 'EOF' > %{buildroot}/etc/sysconfig/carp/vip-down
-#!/bin/sh
-#. /etc/sysconfig/network-scripts/ifcfg-$1
-#exec /sbin/ip addr del ${IPADDR}/${NETMASK} dev "$1"
-exec /sbin/ifconfig $1 down
-EOF
+%{__mkdir_p} %{buildroot}/etc/sysconfig/carp
+
+# Install the example config files
+%{__install} -D -p -m 0600 %{SOURCE2} %{SOURCE3} \
+    %{buildroot}/etc/sysconfig/carp/
+
+# Install helper scripts
+%{__install} -D -p -m 0700 %{SOURCE4} %{SOURCE5} %{SOURCE6} \
+    %{buildroot}/etc/sysconfig/carp/
 
 
 %clean
@@ -84,28 +78,36 @@
 
 %preun
 if [ $1 -eq 0 ]; then
-    /sbin/service carp stop >/dev/null 2>&1 || :
+    /sbin/service carp stop &>/dev/null || :
     /sbin/chkconfig --del carp
 fi
 
 %postun
 if [ $1 -ge 1 ]; then
-    /sbin/service carp condrestart >/dev/null 2>&1 || :
+    /sbin/service carp condrestart &>/dev/null || :
 fi
 
 
 %files -f %{name}.lang
 %defattr(-, root, root, 0755)
-%doc AUTHORS COPYING ChangeLog NEWS README examples/linux/*.sh
+%doc AUTHORS COPYING ChangeLog NEWS README
 /etc/rc.d/init.d/carp
 %dir /etc/sysconfig/carp/
 /etc/sysconfig/carp/vip-001.conf.example
-%attr(0700, root, root) %config(noreplace) /etc/sysconfig/carp/vip-up
-%attr(0700, root, root) %config(noreplace) /etc/sysconfig/carp/vip-down
+/etc/sysconfig/carp/vip-001.list.example
+/etc/sysconfig/carp/vip-up
+/etc/sysconfig/carp/vip-down
+/etc/sysconfig/carp/vip-helper.sh
 %{_sbindir}/ucarp
 
 
 %changelog
+* Wed Nov 29 2006 Matthias Saou <http://freshrpms.net/> 1.2-6
+- Rebuild against new libpcap.
+
+* Mon Nov 13 2006 Matthias Saou <http://freshrpms.net/> 1.2-5
+- Include all improvements from Denis Ovsienko (#200395).
+
 * Mon Aug 28 2006 Matthias Saou <http://freshrpms.net/> 1.2-4
 - FC6 rebuild.
 


Index: vip-001.conf.example
===================================================================
RCS file: /cvs/extras/rpms/ucarp/devel/vip-001.conf.example,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vip-001.conf.example	22 Jun 2006 10:05:17 -0000	1.2
+++ vip-001.conf.example	29 Nov 2006 12:00:11 -0000	1.3
@@ -2,19 +2,46 @@
 # The number (from 001 to 255) in the name of the file is the identifier
 # $Id$
 
-# Set the same password on all mamchines sharing the same virtual IP
+# Set the same password on all machines sharing the same virtual router ID.
 PASSWORD="love"
 
-# You are required to have an IPADDR= line in the configuration file for
-# this interface (so no DHCP allowed)
+# UCARP daemon by default uses the first PCAP-capable interface as returned by
+# pcap_lookupdev(), this is often "eth0". This option allows you to change
+# this behaviour.
 BIND_INTERFACE="eth0"
 
-# Do *NOT* use a main interface for the virtual IP, use an ethX:Y alias
-# with the corresponding /etc/sysconfig/network-scripts/ifcfg-ethX:Y file
-# already configured and ith ONBOOT=no
-VIP_INTERFACE="eth0:0"
+# This is a mandatory option. UCARP daemon will use this IP address for its
+# announces regardless of the addresses actually assigned to the interface.
+#BIND_ADDRESS="10.0.0.2"
+
+# There is a simple and an advanced way to configure UCARP. In both ways you
+# have two physical routers with distinct IP addresses on the same IP network.
+
+# In the simple scenario, you want a single virtual IP address from the _same_
+# network to be taken over by one of the routers. You configure this VIP right
+# here then:
+#VIP_ADDRESS="10.10.10.10"
+
+# In the complex scenario, your virtual router consists of more than one IP
+# address. For example, you might want to assign to the virtual router not only
+# the address which is used as the default gateway on the LAN, but also the only
+# real IP address, which you got from your ISP. Your configuration would have
+# two steps then:
+# 1. Configure the VIP_ADDRESS to "255.255.255.255"
+# 2. Create a file in the same directory which holds vip-XXX.conf, with a name
+# vip-XXX.list. For example, if the .conf file is named vip-001.conf, the .list
+# file would be vip-001.list. Each meaningful line of this file will be used as
+# an argument for "ip address add" and "ip address del" commands. This way you
+# can control, which IP addresses will be assigned to which interfaces.
+#VIP_ADDRESS="255.255.255.255"
 
 # If you have extra options to add, see "ucarp --help" output
 # (the lower the "-k <val>" the higher priority and "-P" to become master ASAP)
-OPTIONS="-k 128 -P"
+# Please note you can use only the following options here:
+# --preempt (-P): becomes a master as soon as possible
+# --neutral (-n): don't run downscript at start if backup
+# --advbase=<seconds> (-b <seconds>): advertisement frequency
+# --advskew=<skew> (-k <skew>): advertisement skew (0-255)
+# The rest of options list is built up by the UCARP initscript.
 
+OPTIONS="-k 128 -P"




More information about the fedora-extras-commits mailing list