$OpenBSD: README-main,v 1.10 2018/09/04 12:46:22 espie Exp $

+-----------------------------------------------------------------------
| Running nut on OpenBSD
+-----------------------------------------------------------------------

NUT is split into separate components. A hardware driver interfaces
with the device and sends information to upsd. A monitor (upsmon)
connects to upsd and shuts down the machine when necessary.

These components can reside on separate computers (i.e. UPS monitored
by various computers may communicate with a central upsd, and a whole
network may run upsmon to allow for shutdown).

On OpenBSD, daemons from packages are usually started by adding to the
pkg_scripts line in /etc/rc.conf.local. For NUT, machines running
upsd or the hardware driver should include "upsd" in this line, and all
machines should include "upsmon". Where you run both, upsd should
be started first. For example you could use this line:

	pkg_scripts=upsd upsmon [...any other daemons...]

Network devices
---------------
To reduce dependencies for the basic NUT package, some network devices
are supported by optional subpackages: nut-snmp (for SNMP-based devices),
nut-xml (for Eaton/MGE devices using an XML/HTTP protocol).

Connecting to a remote server running nutd(8) requires only the basic
NUT package which also includes the file you are reading now.

Configuring NUT
---------------
The following files must be edited for a typical installation.

* ups.conf

Details of UPS device/s are held here. These may either be directly
connected, or network devices (this can include a NUT server running on
another machine). Configuration sections for this file can be generated
for network and USB devices using nut-scanner(8). This is in the main
NUT package but picks up dependencies at runtime, so if you wish
to scan for network devices, just make sure the relevant package
is installed before you run the scanner.

To scan for network devices, specify start and end IP addresses:

	# nut-scanner -s 192.168.17.1 -e 192.168.17.20

* upsd.users

upsd(8) user authentication is configured here.

* upsmon.conf

This file informs upsmon(8) which devices (configured in ups.conf) it
should monitor. It also contains passwords to authenticate to upsd(8).

Device permissions
------------------
For locally connected UPS devices, the userid running NUT (normally
_ups) must have access to the relevant device nodes.

RS232: Either add _ups to group "dialer" or change the group ownership
of the relevant /dev/tty* device to _ups.

USB: Use "usbdevs -vd" (as root) to identify the specific controller
(/dev/usbXX) and ugen (/dev/ugenXX) device nodes, then chgrp these to _ups.

Special notice for APC USB devices
----------------------------------
Some APC USB devices are reported to only work with NUT if the device is
attached to ugen(4). Normally these devices attach to upd(4) to provide
system power sensors (see "sysctl hw.sensors"). If you are having problems
using such a device with NUT, you may need to prevent this attachment.
 
The option with fewest side-effects is to add the following entries to
the table in /sys/dev/usb/usb_quirks.c and build a new kernel:

{ USB_VENDOR_APC, USB_PRODUCT_APC_UPS, ANY, { UQ_BAD_HID }},
{ USB_VENDOR_APC, USB_PRODUCT_APC_UPS5G, ANY, { UQ_BAD_HID }},

Alternatively, if you do not use a USB keyboard/mouse, you could simply
disable the upd and uhidev drivers. The following line creates a new kernel
with the relevant changes:

  printf 'disable uhidev\ndisable upd\nquit\n' | config -e -o /bsd.no-uhid /bsd

Starting the daemons
--------------------
To start the daemons without rebooting you can use:

	# /etc/rc.d/upsd start
	# /etc/rc.d/upsmon start

NUT documentation refers to a nut.conf file; this can be ignored, it is
only used with their System V init scripts, and not OpenBSD's rc scripts.

It is recommended that you test a full cycle of rebooting, checking
that the daemons are running correctly ("upsc <upsname>" will display
information retrieved by NUT from the UPS), allowing the machine
to be shut down by the UPS, and returning power.
