2002-09-20 04:01:54 +02:00
|
|
|
#!@RCD_SCRIPTS_SHELL@
|
2001-11-21 16:50:55 +01:00
|
|
|
#
|
2004-02-15 14:14:25 +01:00
|
|
|
# $NetBSD: upsdriver.sh,v 1.8 2004/02/15 13:14:25 lukem Exp $
|
2001-11-21 16:50:55 +01:00
|
|
|
#
|
|
|
|
# PROVIDE: upsdriver
|
|
|
|
# REQUIRE: NETWORK syslogd mountcritremote
|
|
|
|
#
|
2002-01-08 19:33:36 +01:00
|
|
|
# You will need to set some variables in /etc/rc.conf to start the UPS
|
|
|
|
# driver(s) properly, e.g.
|
2001-11-21 16:50:55 +01:00
|
|
|
#
|
|
|
|
# upsdriver=YES
|
|
|
|
# upsdriver_type="newapc"
|
|
|
|
# upsdriver_flags="-a smartups"
|
|
|
|
#
|
2001-11-21 21:39:40 +01:00
|
|
|
# If "upsdriver_type" is unset, then use "upsdrvctl" to control the UPS
|
|
|
|
# drivers. Please refer to nutupsdrv(8) for more information about the
|
|
|
|
# arguments to pass to the UPS drivers.
|
2001-11-21 16:50:55 +01:00
|
|
|
|
2002-02-05 07:04:36 +01:00
|
|
|
if [ -f /etc/rc.subr ]
|
2001-11-21 16:50:55 +01:00
|
|
|
then
|
|
|
|
. /etc/rc.subr
|
|
|
|
fi
|
|
|
|
|
|
|
|
name="upsdriver"
|
|
|
|
rcvar=$name
|
2001-11-21 21:39:40 +01:00
|
|
|
|
2002-02-05 07:04:36 +01:00
|
|
|
if [ -f /etc/rc.subr ]
|
2001-11-21 21:39:40 +01:00
|
|
|
then
|
|
|
|
load_rc_config $name
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${upsdriver_type:-upsdrvctl}" = "upsdrvctl" ]
|
|
|
|
then
|
2004-02-15 14:14:25 +01:00
|
|
|
ctl_command="@PREFIX@/libexec/nut/upsdrvctl"
|
2001-11-21 21:39:40 +01:00
|
|
|
required_files="@NUT_CONFDIR@/ups.conf"
|
|
|
|
start_cmd="${ctl_command} start"
|
|
|
|
stop_cmd="${ctl_command} stop"
|
|
|
|
else
|
2004-02-15 14:14:25 +01:00
|
|
|
command="@PREFIX@/libexec/nut/${upsdriver_type}"
|
2001-11-21 21:39:40 +01:00
|
|
|
#
|
|
|
|
# XXX - We need a way to easily determine the pidfile, which is of
|
|
|
|
# XXX - the form @NUT_STATEDIR@/${updriver_type}-${tty}.pid
|
|
|
|
#
|
|
|
|
#pidfile="@NUT_STATEDIR@/${upsdriver_type}-${tty}.pid"
|
|
|
|
fi
|
2001-11-21 16:50:55 +01:00
|
|
|
|
2002-02-05 07:04:36 +01:00
|
|
|
if [ -f /etc/rc.subr ]
|
2001-11-21 16:50:55 +01:00
|
|
|
then
|
2001-11-21 22:38:50 +01:00
|
|
|
run_rc_command "$1"
|
|
|
|
else
|
2001-11-21 16:50:55 +01:00
|
|
|
@ECHO@ -n " ${name}"
|
2001-11-21 21:39:40 +01:00
|
|
|
if [ -n "${start_cmd}" ]
|
|
|
|
then
|
|
|
|
${start_cmd}
|
|
|
|
else
|
|
|
|
${command} ${upsdriver_flags} ${command_args}
|
|
|
|
fi
|
2001-11-21 16:50:55 +01:00
|
|
|
fi
|