summaryrefslogtreecommitdiff
path: root/sysutils/apcctrl/files/apcctrl.in
diff options
context:
space:
mode:
authorDanilo G. Baio <dbaio@FreeBSD.org>2019-10-31 23:43:55 +0000
committerDanilo G. Baio <dbaio@FreeBSD.org>2019-10-31 23:43:55 +0000
commit389101e02889c46936075a5c2568b2e7348ca3c6 (patch)
treefb45f6d617638459bad00f44cfbde8025b25e190 /sysutils/apcctrl/files/apcctrl.in
parent- Update to 1.5.2 (diff)
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>
Notes
Notes: svn path=/head/; revision=516204
Diffstat (limited to 'sysutils/apcctrl/files/apcctrl.in')
-rw-r--r--sysutils/apcctrl/files/apcctrl.in83
1 files changed, 83 insertions, 0 deletions
diff --git a/sysutils/apcctrl/files/apcctrl.in b/sysutils/apcctrl/files/apcctrl.in
new file mode 100644
index 000000000000..56fd4f3b557a
--- /dev/null
+++ b/sysutils/apcctrl/files/apcctrl.in
@@ -0,0 +1,83 @@
+#!/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