From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Jul 5 22:30:00 2013 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B9927E3B for ; Fri, 5 Jul 2013 22:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id A0461187D for ; Fri, 5 Jul 2013 22:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r65MU0w4079546 for ; Fri, 5 Jul 2013 22:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r65MU0fh079543; Fri, 5 Jul 2013 22:30:00 GMT (envelope-from gnats) Resent-Date: Fri, 5 Jul 2013 22:30:00 GMT Resent-Message-Id: <201307052230.r65MU0fh079543@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, Craig Leres Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 97B8992A for ; Fri, 5 Jul 2013 22:20:32 +0000 (UTC) (envelope-from leres@ee.lbl.gov) Received: from fun.ee.lbl.gov (fun.ee.lbl.gov [IPv6:2620:83:8000:102::ca]) by mx1.freebsd.org (Postfix) with ESMTP id 6CC5C181F for ; Fri, 5 Jul 2013 22:20:32 +0000 (UTC) Received: from fun.ee.lbl.gov (localhost [127.0.0.1]) by fun.ee.lbl.gov (8.14.7/8.14.7) with ESMTP id r65MKSgu082061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Jul 2013 15:20:28 -0700 (PDT) Received: (from leres@localhost) by fun.ee.lbl.gov (8.14.7/8.14.7/Submit) id r65MKS5X082060; Fri, 5 Jul 2013 15:20:28 -0700 (PDT) Message-Id: <201307052220.r65MKS5X082060@fun.ee.lbl.gov> Date: Fri, 5 Jul 2013 15:20:28 -0700 (PDT) From: Craig Leres To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: ports/180336: [PATCH] sysutils/apcupsd: support multiple instances of apcupsd Cc: leres@ee.lbl.gov X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Craig Leres List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 22:30:00 -0000 >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@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: