From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Jun 3 15:30:01 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D71EF1065670 for ; Tue, 3 Jun 2008 15:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B8BDA8FC15 for ; Tue, 3 Jun 2008 15:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m53FU1Oe067617 for ; Tue, 3 Jun 2008 15:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m53FU1D7067616; Tue, 3 Jun 2008 15:30:01 GMT (envelope-from gnats) Resent-Date: Tue, 3 Jun 2008 15:30:01 GMT Resent-Message-Id: <200806031530.m53FU1D7067616@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Piotr Rybicki Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70DB11065672 for ; Tue, 3 Jun 2008 15:24:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 623528FC14 for ; Tue, 3 Jun 2008 15:24:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m53FM9E4074924 for ; Tue, 3 Jun 2008 15:22:09 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m53FM8ba074923; Tue, 3 Jun 2008 15:22:08 GMT (envelope-from nobody) Message-Id: <200806031522.m53FM8ba074923@www.freebsd.org> Date: Tue, 3 Jun 2008 15:22:08 GMT From: Piotr Rybicki To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/124238: [ports: heartbeat] patch request X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2008 15:30:02 -0000 >Number: 124238 >Category: ports >Synopsis: [ports: heartbeat] patch request >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Jun 03 15:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Piotr Rybicki >Release: 7.0-R1 >Organization: Innervision >Environment: I believe this is not needed >Description: #1 port sysutils/heartbeat has problem when trying to find an interface for ip address. To fetch this interface, following line is applied (shell script): $IFCONFIG | grep "$ipaddr" -B4 | grep "UP," | cut -d ":" -f 1 This usability is limited to one alias per interface (grep -B4). I provide here a patch which drops this limitation. #2 heartbeat lacks a proper 'resource' for starting/stopping rc.d scripts upon moving through the nodes. I provide here a script (BSDService) which allows this functionality. This file should be installed in /usr/local/etc/ha.d/resource.d Please update this port by adding my 2 patches. Best regards & have a good day! >How-To-Repeat: #1 - try using more than one IP alias as a cluster resource #2 - try to use rc.d service as a cluster resource (in an easy way) >Fix: #1 - patch # diff -u ~ryba/_ha_orig/IPaddr /usr/local/etc/ha.d/resource.d/IPaddr --- /home/ryba/_ha_orig/IPaddr 2008-06-03 13:48:41.000000000 +0200 +++ /usr/local/etc/ha.d/resource.d/IPaddr 2008-06-03 14:24:26.000000000 +0200 @@ -80,6 +80,28 @@ } # +# Find out which alias serves the given IP address +# The argument is an IP address, and its output +# is an aliased interface name (e.g., "eth0:0"). +# +find_interface_bsd() { + + ipaddr="$1"; + + for ifname in `$IFCONFIG -l` + do +# echo "IFNAME:$ifname" + $IFCONFIG $ifname | grep "inet.*[: ]$ipaddr " >/dev/null 2>&1 + if [ $? -eq 0 ] + then + echo $ifname + return 0 + fi + done + return 1 +} + +# # Find out which alias serves the given IP address # The argument is an IP address, and its output # is an aliased interface name (e.g., "eth0:0"). @@ -131,6 +153,9 @@ SunOS) IF=`find_interface_solaris $BASEIP` ;; + *BSD) + IF=`find_interface_bsd $BASEIP` + ;; *) IF=`find_interface_generic $BASEIP` ;; @@ -461,6 +486,9 @@ SunOS) j=1 ;; + *BSD) + j=1 + ;; *) j=0 TRYADRCNT=`ls "${NICBASE}:"* | wc -l | tr -d ' ' 2>/dev/null` #2) - BSDService resource file: # cat BSDService #!/bin/sh # # Created VI 2008 by Piotr Rybicki (meritus@innervision.pl) # # This script can be used do start/stop FreeBSD's # /usr/local/etc/rc.d/* services. # # One MUST NOT enable service (in /etc/rc.conf # there cannot be SERVICE_enable"YES" line) # # usage: $0 {start|stop|status} # # An example usage in /usr/local/etc/ha.d/haresources: # node1 10.0.0.170 BSDService::mysql-server # usage() { cat <<-! usage: $0 SERVICE {start|stop|status}"; ! exit 1 } . /usr/local/etc/ha.d/shellfuncs RCD=/usr/local/etc/rc.d #VARLIB=/var/lib/heartbeat #VLFILE=$VARLIB/rsctmp/Delay BSDService_Status() { if [ ! -f $RCD/$1 ] then echo "There is no $RCD/$1 script!. Fatal" fi $RCD/$1 onestatus 2>&1 1>/dev/null if [ $? -eq 0 ] then if [ $2 = 'verbose' ] then echo "Service $1 is running OK" fi return 0 else if [ $2 = 'verbose' ] then echo "Service $1 is NOT running" fi return 1 fi } BSDService_Start() { BSDService_Status $1 noverbose if [ $? -eq 0 ] then echo "Service $1 already running" return 0 else $RCD/$1 onestart return $? fi } BSDService_Stop() { BSDService_Status $1 noverbose if [ $? -eq 0 ] then $RCD/$1 onestop return $? else echo "Service $1 already stopped" return 0 fi } if [ $# -ne 2 ] then usage; exit 1; fi case $2 in start) BSDService_Start $1 ;; stop) BSDService_Stop $1 ;; status) BSDService_Status $1 verbose ;; *) usage exit 1;; esac exit $? >Release-Note: >Audit-Trail: >Unformatted: