mirror of
https://git.freebsd.org/ports.git
synced 2025-06-06 13:20:32 -04:00
Add support for running multiple instances of apcupsd[1] Add an option to use `shutdown -p` rather than `shutdown -h`[2] Set as @sample several scripts that can be customized[3] Add an option for build with MODBUS USB driver support (Enabled by default)[4] Set LICENSE_FILE [5] Sort OPTIONS and make a small adjustment in pkg-message Take maintainer'ship PR: 180336 [1] PR: 187924 [2][3] PR: 215809 [4] PR: 220002 [5] Submitted by: leres@ee.lbl.gov [1] Submitted by: tdb [3] Submitted by: ipluta@wp.pl [4] Submitted by: takefu@airport.fm [5] Approved by: garga (mentor) Differential Revision: https://reviews.freebsd.org/D11224
83 lines
1.7 KiB
Bash
83 lines
1.7 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# PROVIDE: apcupsd
|
|
# REQUIRE: SERVERS
|
|
# BEFORE: DAEMON
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following line to /etc/rc.conf[.local] to enable apcupsd
|
|
#
|
|
# apcupsd_enable (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable apcupsd.
|
|
# 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
|
|
|
|
name=apcupsd
|
|
rcvar=apcupsd_enable
|
|
|
|
load_rc_config $name
|
|
|
|
: ${apcupsd_enable="NO"}
|
|
: ${apcupsd_flags="--kill-on-powerfail"}
|
|
|
|
pidfile=/var/run/${name}.pid
|
|
required_files="${apcupsd_configs:-%%ETCDIR%%/apcupsd.conf}"
|
|
command=%%PREFIX%%/sbin/${name}
|
|
restart_cmd=${name}_restart_cmd
|
|
|
|
apcupsd_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
|
|
}
|
|
|
|
apcupsd_restart_cmd()
|
|
{
|
|
if [ -n "${apcupsd_configs}" ]; then
|
|
# One or more named configs
|
|
for config in ${apcupsd_configs}; do
|
|
apcupsd_precmd ${config}
|
|
run_rc_command stop
|
|
done
|
|
for config in ${apcupsd_configs}; do
|
|
apcupsd_precmd ${config}
|
|
run_rc_command start
|
|
done
|
|
else
|
|
# Default config
|
|
apcupsd_precmd
|
|
run_rc_command stop
|
|
run_rc_command start
|
|
fi
|
|
}
|
|
|
|
if [ "$1" = restart ]; then
|
|
apcupsd_precmd
|
|
run_rc_command $1
|
|
elif [ -n "${apcupsd_configs}" ]; then
|
|
# One or more named configs
|
|
for config in ${apcupsd_configs}; do
|
|
apcupsd_precmd ${config}
|
|
run_rc_command $1
|
|
done
|
|
else
|
|
# Default config
|
|
apcupsd_precmd
|
|
run_rc_command $1
|
|
fi
|