Subject: ups-nut rc.d scripts
To: None <tech-pkg@netbsd.org>
From: Johnny Lam <jlam@jgrind.org>
List: tech-pkg
Date: 11/20/2001 10:02:55
Hi,

	I'm trying to improve the ups-nut rc.d scripts to the point that
they may be automatically copied into /etc/rc.d without any harmful effects.
That means that they must respect any rc.conf settings so that they don't
automatically start unless the proper variables are set to YES.  I've
included two scripts below.  Could someone with a UPS system please check to
see if the scripts work correctly?  Note that they may need to be customized
for your setup if the ups-nut configuration directory isn't in /usr/pkg/etc.

	Thanks,

	-- Johnny Lam <jlam@jgrind.org>

------------------------ /etc/rc.d/upsd ------------------------
#! /bin/sh
#
# $NetBSD$
#
# PROVIDE: upsd
# REQUIRE: NETWORK syslogd mountcritremote

if [ -d /etc/rc.d -a -f /etc/rc.subr ]
then
	. /etc/rc.subr
fi

arg="${1:-start}"
rcvar="upsd"

name="upsdrvctl"
command="/usr/pkg/bin/${name}"
required_files="/usr/pkg/etc/nut/ups.conf"
start_cmd="${command} start"
stop_cmd="${command} stop"

if [ ! -d /etc/rc.d ]
then
	echo -n " ${name}"
	${command} "$arg"
else
	load_rc_config $name
	run_rc_command "$arg"
fi

unset start_cmd stop_cmd

name="upsd"
command="/usr/pkg/sbin/${name}"
required_files="/usr/pkg/etc/nut/upsd.conf"

if [ ! -d /etc/rc.d ]
then
	echo -n " ${name}"
	${command} ${command_args}
else
	load_rc_config $name
	run_rc_command "$arg"
fi


------------------------ /etc/rc.d/upsmon ------------------------
#! /bin/sh
#
# $NetBSD$
#
# PROVIDE: upsmon
# REQUIRE: upsd

if [ -d /etc/rc.d -a -f /etc/rc.subr ]
then
	. /etc/rc.subr
fi

name="upsmon"
rcvar="${name}"
command="/usr/pkg/sbin/${name}"
pidfile="/var/run/${name}.pid"
required_files="/usr/pkg/etc/nut/upsmon.conf"

if [ ! -d /etc/rc.d ]
then
	echo -n " ${name}"
	${command} ${upsmon_flags} ${command_args}
else
	load_rc_config $name
	run_rc_command "$1"
fi