From eikemeier@fillmore-labs.com  Sun Nov 16 07:53:04 2003
Return-Path: <eikemeier@fillmore-labs.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CCAC916A4CE
	for <FreeBSD-gnats-submit@FreeBSD.org>; Sun, 16 Nov 2003 07:53:04 -0800 (PST)
Received: from mx2.fillmore-labs.com (lima.fillmore-labs.com [62.138.193.83])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D496F43FAF
	for <FreeBSD-gnats-submit@FreeBSD.org>; Sun, 16 Nov 2003 07:53:03 -0800 (PST)
	(envelope-from eikemeier@fillmore-labs.com)
Received: from pd951af62.dip.t-dialin.net
	([217.81.175.98] helo=fillmore-labs.com ident=bwnlmnlje2iu0osv)
	by mx2.fillmore-labs.com with asmtp (TLSv1:AES256-SHA:256)
	(Exim 4.24; FreeBSD 4.9)
	id 1ALPCw-000GgS-Eh
	for FreeBSD-gnats-submit@FreeBSD.org; Sun, 16 Nov 2003 16:53:02 +0100
Message-Id: <3FB79D5C.6010209@fillmore-labs.com>
Date: Sun, 16 Nov 2003 16:53:00 +0100
From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: [PATCH] net/balance: rc.subr(8) script

>Number:         59339
>Category:       ports
>Synopsis:       [PATCH] net/balance: rc.subr(8) script
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    eik
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 16 08:00:38 PST 2003
>Closed-Date:    Sat Nov 22 12:50:23 PST 2003
>Last-Modified:  Sat Nov 22 12:50:23 PST 2003
>Originator:     Oliver Eikemeier
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
Fillmore Labs - http://www.fillmore-labs.com
>Environment:
System: FreeBSD nuuk.fillmore-labs.com 5.1-CURRENT

>Description:

A rcNG script for port net/balance.

Sample entry in rc.conf(5):

balance_enable="YES"
balance_hosts="host1 host2"
balance_host1_adress="host1.domain.example"
balance_host1_ports="ftp http"
balance_host1_targets="host1.internal.domain.example"
balance_host2_adress="host2.domain.example"
balance_host2_ports="ssh ldap 8180"
balance_host2_targets="host2.internal.domain.example"

>How-To-Repeat:
>Fix:

--- balance.patch begins here ---
Index: net/balance/Makefile
===================================================================
RCS file: /home/ncvs/ports/net/balance/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- net/balance/Makefile	4 Nov 2003 20:11:47 -0000	1.8
+++ net/balance/Makefile	7 Nov 2003 12:30:17 -0000
@@ -17,14 +17,21 @@
 ALL_TARGET=	balance
 USE_REINPLACE=	yes
 
+USE_RC_SUBR=	yes
+
 MAN1=	balance.1
 
 post-patch:
 	${REINPLACE_CMD} -e 's|^CFLAGS|#CFLAGS|g ; \
 		s|^CC|#CC|g' ${WRKSRC}/Makefile
 
+post-build:
+	@${SED} -e 's,%%RC_SUBR%%,${RC_SUBR},g' -e 's,%%PREFIX%%,${PREFIX},g' \
+		${FILESDIR}/${PORTNAME}.sh >${WRKDIR}/${PORTNAME}.sh
+
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/balance ${PREFIX}/bin
-	${INSTALL_MAN} ${WRKSRC}/balance.1 ${PREFIX}/man/man1
+	@${INSTALL_PROGRAM} ${WRKSRC}/balance ${PREFIX}/bin
+	@${INSTALL_MAN} ${WRKSRC}/balance.1 ${PREFIX}/man/man1
+	@${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME}.sh ${PREFIX}/etc/rc.d/${PORTNAME}.sh
 
 .include <bsd.port.mk>
Index: net/balance/pkg-plist
===================================================================
RCS file: /home/ncvs/ports/net/balance/pkg-plist,v
retrieving revision 1.1
diff -u -r1.1 pkg-plist
--- net/balance/pkg-plist	19 Dec 2000 12:17:21 -0000	1.1
+++ net/balance/pkg-plist	4 Nov 2003 20:09:14 -0000
@@ -1 +1,2 @@
 bin/balance
+etc/rc.d/balance.sh
Index: net/balance/files/balance.sh
===================================================================
RCS file: net/balance/files/balance.sh
diff -N net/balance/files/balance.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ net/balance/files/balance.sh	4 Nov 2003 20:10:21 -0000
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: balance
+# REQUIRE: LOGIN
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable balance:
+#
+#balance_enable="YES"
+#balance_hosts="host1"
+#balance_host1_adress="host1.external.example"
+#balance_host1_ports="http 8180"
+#balance_host1_targets="host1.internal.example"
+#
+# See balance(8) for flags
+#
+
+. %%RC_SUBR%%
+
+name=balance
+rcvar=`set_rcvar`
+command=%%PREFIX%%/bin/balance
+
+start_cmd=start_cmd
+stop_cmd=stop_cmd
+status_cmd=status_cmd
+
+start_cmd()
+{
+	if [ -x "${command}" ]; then
+		for host in ${balance_hosts}; do
+			eval ports=\"\${balance_${host}_ports}\"
+			eval adress=\"\${balance_${host}_adress}\"
+			eval targets=\"\${balance_${host}_targets}\"
+			for port in ${ports}; do
+				"${command}" -b ${adress} ${port} ${targets}
+			done
+		done
+	fi
+}
+
+stop_cmd()
+{
+	if [ -x "${command}" ]; then
+		for host in ${balance_hosts}; do
+			eval ports=\"\${balance_${host}_ports}\"
+			eval adress=\"\${balance_${host}_adress}\"
+			for port in ${ports}; do
+				echo "balance at ${adress}:${port}"
+				"${command}" -b ${adress} -c kill ${port}
+			done
+		done
+	fi
+}
+
+status_cmd()
+{
+	if [ -x "${command}" ]; then
+		for host in ${balance_hosts}; do
+			eval ports=\"\${balance_${host}_ports}\"
+			eval adress=\"\${balance_${host}_adress}\"
+			for port in ${ports}; do
+				echo "balance at ${adress}:${port}"
+				"${command}" -b ${adress} -c show ${port}
+			done
+		done
+	fi
+}
+
+# set defaults
+
+balance_enable=${balance_enable:-"NO"}
+
+load_rc_config $name
+run_rc_command "$1"
--- balance.patch ends here ---




>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: eik 
State-Changed-When: Sun Nov 16 17:09:07 CET 2003 
State-Changed-Why:  
mine 


Responsible-Changed-From-To: freebsd-ports-bugs->eik 
Responsible-Changed-By: eik 
Responsible-Changed-When: Sun Nov 16 17:09:07 CET 2003 
Responsible-Changed-Why:  
asked maintainer for his opinion 

http://www.freebsd.org/cgi/query-pr.cgi?pr=59339 

From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: Joseph Scott <joseph@randomnetworks.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/59339: [PATCH] net/balance: rc.subr(8) script
Date: Sun, 16 Nov 2003 17:08:51 +0100

 Hi Joseph,
 
 could you please have a look into PR 59339:
   <http://www.freebsd.org/cgi/query-pr.cgi?pr=59339>
 and tell me what you think?
 
 Thanks
     Oliver
 

From: Joseph Scott <joseph@randomnetworks.com>
To: Oliver Eikemeier <eikemeier@fillmore-labs.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/59339: [PATCH] net/balance: rc.subr(8) script
Date: Sun, 16 Nov 2003 16:43:46 -0800 (PST)

 On Sun, 16 Nov 2003, Oliver Eikemeier wrote:
 
 -> Hi Joseph,
 ->
 -> could you please have a look into PR 59339:
 ->   <http://www.freebsd.org/cgi/query-pr.cgi?pr=59339>
 -> and tell me what you think?
 
 	I don't have a 5.x box to try this on, so assuming that this works
 I'm fine with it.  It may be nice to make this conditional to only be done
 on systems that have the new 5.x rc.d features.
 
 --
 Joseph Scott                            | ICQ:         41906697
 joseph@randomnetworks.com               | Yahoo Msger: somestrangeid
 http://www.randomnetworks.com/joseph/   | MSN Msger:   joseph@randomnetworks.com

From: Oliver Eikemeier <eikemeier@fillmore-labs.com>
To: Joseph Scott <joseph@randomnetworks.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/59339: [PATCH] net/balance: rc.subr(8) script
Date: Mon, 17 Nov 2003 01:55:31 +0100

 Joseph Scott wrote:
 
 > 	I don't have a 5.x box to try this on, so assuming that this works
 > I'm fine with it.  It may be nice to make this conditional to only be done
 > on systems that have the new 5.x rc.d features.
 
 Try it on a 4.x system, I use exactly this script on my 4-STABLE
 for two months now :)
 
 

From: Joseph Scott <joseph@randomnetworks.com>
To: Oliver Eikemeier <eikemeier@fillmore-labs.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: ports/59339: [PATCH] net/balance: rc.subr(8) script
Date: Tue, 18 Nov 2003 21:54:45 -0800 (PST)

 On Mon, 17 Nov 2003, Oliver Eikemeier wrote:
 
 -> Joseph Scott wrote:
 ->
 -> > 	I don't have a 5.x box to try this on, so assuming that this works
 -> > I'm fine with it.  It may be nice to make this conditional to only be done
 -> > on systems that have the new 5.x rc.d features.
 ->
 -> Try it on a 4.x system, I use exactly this script on my 4-STABLE
 -> for two months now :)
 
 	I haven't tested this yet, but if it's been working fine for you
 then I'm ok with having it committed.
 
 --
 Joseph Scott                            | ICQ:         41906697
 joseph@randomnetworks.com               | Yahoo Msger: somestrangeid
 http://www.randomnetworks.com/joseph/   | MSN Msger:   joseph@randomnetworks.com
State-Changed-From-To: feedback->closed 
State-Changed-By: eik 
State-Changed-When: Sat Nov 22 21:50:00 CET 2003 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=59339 
>Unformatted:
