--- 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