HOWTO Setup NUT (Network UPS Tools) on Debian

This article was first written in August 2004 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/158).
NUT is the Network UPS Tools. To setup NUT on Debian, you first need to know what kind of UPS you have, and how it is/will be connected to your Debian machine. We will not yet analyse how to do monitoring over the network, but only on the machine physically connected to the UPS, which we suppose has been installed under Debian GNU/Linux (tested on Sarge). First, install the package nut (there are several other NUT-related packages, but you only really need this one). It will create a /etc/nut directory, which you have to populate with files in /usr/share/doc/nut/examples/. Uncompress them all, and change the owner to nut:nut and the rights to -rw-r-----. Then, modify the ups.conf file to suite your UPS. Example:
[apcups]
        driver = apcsmart
        port = /dev/ttyS0
        desc = "APC SmartUPS"
        sdtype = 0
You can find the list of drivers and options available in /usr/share/doc/nut/README.gz. Go change the "no" you need (at least START_UPSD) into "yes" in /etc/default/nut. Now, the tricky part is that upsd needs to be able to access the peripheral, for example /dev/ttyS0. It is really different given that you use devfs or udev or yet the old /dev way… I will provide more information here soon.