ports/sysutils/nut/files/nut.in
Cy Schubert fe1fd540a2 If nut_upsshut is YES in rc.conf and POWERDOWNFLAG directive is in
upsmon.conf, send a powerdown signal to the UPS to shut down at
poweroff.

Suggested by:	Alexander Milanov <a@amilanov.com>
2017-06-14 06:46:32 +00:00

55 lines
999 B
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: nut
# REQUIRE: NETWORKING
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these nut_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/nut
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
nut_enable=${nut_enable:-"NO"}
nut_prefix=${nut_prefix:-"%%PREFIX%%"}
. /etc/rc.subr
name="nut"
rcvar=nut_enable
load_rc_config $name
required_dirs="%%STATEDIR%%"
required_files="${nut_prefix}/etc/nut/ups.conf ${nut_prefix}/etc/nut/upsd.conf ${nut_prefix}/etc/nut/upsd.users"
command="${nut_prefix}/sbin/upsd"
pidfile="%%STATEDIR%%/upsd.pid"
start_precmd="nut_prestart"
stop_postcmd="nut_poststop"
nut_prestart() {
${nut_prefix}/sbin/upsdrvctl start
}
nut_poststop() {
if ${nut_prefix}/sbin/upsdrvctl stop && checkyesno nut_upsshut; then
if ${nut_prefix}/sbin/upsmon -K; then
${nut_prefix}/sbin/upsdrvctl shutdown
fi
fi
}
extra_commands=reload
reload()
{
kill -HUP `cat $pidfile`
}
run_rc_command "$1"