aboutsummaryrefslogtreecommitdiffstats
path: root/net/balance
diff options
context:
space:
mode:
authoreik <eik@FreeBSD.org>2003-11-23 04:49:09 +0800
committereik <eik@FreeBSD.org>2003-11-23 04:49:09 +0800
commit8a1ecf4b774e8d63cf977d5175ac5e83cf581547 (patch)
treee9e14b28005f04a71465e851e6c16ea93c029c90 /net/balance
parent0688779922ae28b9884a0e51dba86c896d55646e (diff)
downloadfreebsd-ports-gnome-8a1ecf4b774e8d63cf977d5175ac5e83cf581547.tar.gz
freebsd-ports-gnome-8a1ecf4b774e8d63cf977d5175ac5e83cf581547.tar.zst
freebsd-ports-gnome-8a1ecf4b774e8d63cf977d5175ac5e83cf581547.zip
added rc.subr(8) start/stop script
PR: 59339 Approved by: Joseph Scott <joseph@randomnetworks.com> (maintainer), marcus (mentor)
Diffstat (limited to 'net/balance')
-rw-r--r--net/balance/Makefile11
-rw-r--r--net/balance/files/balance.sh79
-rw-r--r--net/balance/pkg-plist1
3 files changed, 89 insertions, 2 deletions
diff --git a/net/balance/Makefile b/net/balance/Makefile
index 718e1a45f550..bb7d7e8dc0cc 100644
--- a/net/balance/Makefile
+++ b/net/balance/Makefile
@@ -17,14 +17,21 @@ COMMENT= Simple but powerful generic tcp proxy with round robin features
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>
diff --git a/net/balance/files/balance.sh b/net/balance/files/balance.sh
new file mode 100644
index 000000000000..bfffe90a3b31
--- /dev/null
+++ b/net/balance/files/balance.sh
@@ -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"
diff --git a/net/balance/pkg-plist b/net/balance/pkg-plist
index 010b8ed360d6..aae93de48847 100644
--- a/net/balance/pkg-plist
+++ b/net/balance/pkg-plist
@@ -1 +1,2 @@
bin/balance
+etc/rc.d/balance.sh