[Nut-upsuser] FreeBSD installation procedure (updated)

forsite forsite at gmail.com
Mon May 25 11:44:13 UTC 2009


The purpose of this posting is to summarize the FreeBSD installation
procedure from the beginning till the very end.

1. Follow the instructions provided in the How-To prepared by Thierry
Thomas (http://people.freebsd.org/~thierry/nut_FreeBSD_HowTo.txt).
Please note the following:

a) if you are using an USB device, as of NUT 2.2 usbhid-ups completely
replaces the legacy hidups driver and provides support for various
manufacturers. At that time, it will be renamed to usbhid-ups;

b) if your USB device is claimed by the uhid and not by ugen driver,
this should be fixed, since libusb-based packages such as NUT can't
work with uhid* device nodes.  Therefore, you need to either
de-configure the uhid driver (in FreeBSD a separate driver handles
USB/HID keyboard and mouse) or blacklist that specific USB VID/PID
combination. Please refer to the following thread for more details on
the issue: http://lists.alioth.debian.org/pipermail/nut-upsuser/2009-May/005058.html

c) 'allowfrom' in upsd.users is obsolete and is no longer used;

d) you may need to insert additional instructions into ups.conf - e.g.
if you need a decent grace delay on the UPS for the shutdown
procedure.  See below for more details on the issue.

2. After you have followed the above How-To instructions and have
tested your configuration, you will need to configure the automatic
UPS shutdown (http://www.networkupstools.org/doc/2.2.0/shutdown.html).
 Put the following sentence either into /etc/rc.shutdown script, or
into /usr/local/etc/rc.d/nut (inside the 'nut_poststop' section,
straight after the '${nut_prefix}/libexec/nut/upsdrvctl stop'
instruction):

	# uncomment for rc.shutdown script
	#
	# nut_prefix=${nut_prefix-"/usr/local"}

	if [ -r /etc/killpower ]; then

		rm -f /etc/killpower

		echo "Killing the power, bye!"
		${nut_prefix}/libexec/nut/upsdrvctl -v shutdown

		if [ $? -ne 0 ]; then
			${nut_prefix}/libexec/nut/UPS_DRIVER -k -D -a UPS_NAME
		fi

		# increase this timeout (to, say, 120 sec) if your configuration is
vulnerable to a power race
		# *** see the section on power races below ***
		sleep 5

		# uh oh... the UPS poweroff failed!
		# you probably should reboot here to avoid getting stuck
		# *** see the section on power races below ***
		#
		# /sbin/reboot

	fi

Arguably rc.shutdown is a better place for this but it's not very
ports friendly.  If you you decide to put this into
/usr/local/etc/rc.d/nut, you need a decent grace delay on the UPS so
the rest of the system will shut down properly.  This can be done by
adding two variables into ups.conf:

	 [UPS_NAME]
		driver = UPS_DRIVER
		port = UPS_PORT
		# Give the system enough time to shutdown when the power fails
		offdelay = 120
		# ondelay must be greater than offdelay so change it
		ondelay = 130

3. Test whether your configuration is able to handle a power race
successfully as described in
http://www.networkupstools.org/doc/2.2.0/shutdown.html and add the
"reboot after timeout" hack, if required.

4. That's it.  At this stage you may wish to add some
post-installation procedures, like cgi-scripts for web-access or any
other.



More information about the Nut-upsuser mailing list