ports/sysutils/apcctrl/files/apcctrl.in
Danilo G. Baio 389101e028 Add sysutils/apcctrl: Fork of apcupsd 3.14.x with support for Brazilian APC nobreaks
ApcCtrl is an unofficial branch from apcupsd 3.14.x. It can be
used for controlling Brazilian APC UPS models (herited from Microsol).

Models supported or in tests:
  - BACK-UPS BR 1200VA (BZ1200BI-BR)
  - BACK-UPS BR 1500VA (BZ1500PBI-BR)
  - BACK-UPS BR 2200VA (BZ2200BI-BR and BZ2200I-BR)
  - SMART-UPS BR 1000VA (SUA1000BI-BR and SOLIS1000BI)
  - SMART-UPS BR 1500VA (SUA1500BI-BR and SOLIS1500BI)
  - SMART-UPS BR 2000VA (SUA2000BI-BR)
  - SMART-UPS BR 3000VA (SUA3000BI-BR)
  - STAY 800 (PS800)
  - STAY 700 (PS700)

WWW: http://www.apcctrl.com.br

PR:		241623
Submitted by:	Mario Lobo <lobo@bsd.com.br>
2019-10-31 23:43:55 +00:00

83 lines
1.7 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: apcctrl
# REQUIRE: SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf[.local] to enable apcctrl
#
# apcctrl_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable apcctrl.
# apcctrl_flags (str): Custom additional arguments to be passed
# to apcctrl (default --kill-on-powerfail).
# apcctrl_configs (str): A list of configs to run multiple instances.
#
. /etc/rc.subr
name=apcctrl
rcvar=apcctrl_enable
load_rc_config $name
: ${apcctrl_enable="NO"}
: ${apcctrl_flags="--kill-on-powerfail"}
pidfile=/var/run/${name}.pid
required_files="${apcctrl_configs:-%%ETCDIR%%/apcctrl.conf}"
command=%%PREFIX%%/sbin/${name}
restart_cmd=${name}_restart_cmd
apcctrl_precmd()
{
config=$1
dn="`/usr/bin/dirname ${pidfile}`"
if [ -n "${config}" ]; then
# Specific config
base="`/usr/bin/basename ${config} .conf`"
pidfile="${dn}/${base}.pid"
command_args="-f ${config} -P ${pidfile}"
else
# Default config
command_args=""
fi
}
apcctrl_restart_cmd()
{
if [ -n "${apcctrl_configs}" ]; then
# One or more named configs
for config in ${apcctrl_configs}; do
apcctrl_precmd ${config}
run_rc_command stop
done
for config in ${apcctrl_configs}; do
apcctrl_precmd ${config}
run_rc_command start
done
else
# Default config
apcctrl_precmd
run_rc_command stop
run_rc_command start
fi
}
if [ "$1" = restart ]; then
apcctrl_precmd
run_rc_command $1
elif [ -n "${apcctrl_configs}" ]; then
# One or more named configs
for config in ${apcctrl_configs}; do
apcctrl_precmd ${config}
run_rc_command $1
done
else
# Default config
apcctrl_precmd
run_rc_command $1
fi