ports/180336: [PATCH] sysutils/apcupsd: support multiple instances of apcupsd
Craig Leres
leres at ee.lbl.gov
Fri Jul 5 22:30:00 UTC 2013
>Number: 180336
>Category: ports
>Synopsis: [PATCH] sysutils/apcupsd: support multiple instances of apcupsd
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 05 22:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Craig Leres
>Release: FreeBSD 9.1-RELEASE amd64
>Organization:
Lawrence Berkeley National Laboratory
>Environment:
System: FreeBSD fun.ee.lbl.gov 9.1-RELEASE FreeBSD 9.1-RELEASE #5 r15: Sat Apr 20 20:56:40 PDT 2013 leres at fun.ee.lbl.gov:/sys/amd64/compile/LBL amd64
>Description:
It's possible to run multiple instances of apcupsd on a
single host but the current rc.d script doesn't allow this.
>How-To-Repeat:
>Fix:
The attached patch updates apcupsd.in to manage more than
one apcupsd by adding a list of configuration files to
/etc/rc.conf, e.g.:
apcupsd_enable="YES"
apcupsd_configs="
/usr/local/etc/apcupsd/apcupsd.conf
/usr/local/etc/apcupsd/apcupsd2.conf
"
apcupsd_flags=""
--- patch.txt begins here ---
--- files/apcupsd.in.orig 2013-07-05 14:16:30.000000000 -0700
+++ files/apcupsd.in 2013-07-05 14:16:38.000000000 -0700
@@ -11,8 +11,9 @@
#
# apcupsd_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable apcupsd.
-# apcupsd_args (str): Custom additional arguments to be passed
-# to apcupsd (default empty).
+# apcupsd_flags (str): Custom additional arguments to be passed
+# to apcupsd (default --kill-on-powerfail).
+# apcupsd_configs (str): A list of configs to run multiple instances.
#
. /etc/rc.subr
@@ -24,11 +25,26 @@
: ${apcupsd_enable="NO"}
: ${apcupsd_flags="--kill-on-powerfail"}
-: ${apcupsd_pidfile="/var/run/apcupsd.pid"}
-: ${apcupsd_lockfile="/var/spool/lock/apcupsd.lock"}
pidfile="/var/run/apcupsd.pid"
-required_files="%%ETCDIR%%/apcupsd.conf"
+required_files="${apcupsd_configs:-%%ETCDIR%%/apcupsd.conf}"
command="%%PREFIX%%/sbin/apcupsd"
-run_rc_command "$1"
+case ${apcupsd_configs} in
+
+'')
+ # One instance with the default config
+ run_rc_command "$1"
+ ;;
+
+*)
+ # One or more instance
+ dn="`/usr/bin/dirname ${pidfile}`"
+ for config in ${apcupsd_configs}; do
+ base="`/usr/bin/basename ${config} .conf`"
+ pidfile="${dn}/${base}.pid"
+ command_args="-f ${config} -P ${pidfile}"
+ run_rc_command "$1"
+ done
+ ;;
+esac
--- patch.txt ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list