nut - Software for UPS monitoring, safe shutdown ChangeLog

HOWTO


# NUT 2.7.4
# =========
# This is the latest release from the "stable" tree

# Go here to make sure your UPS is supported:
# http://www.networkupstools.org/stable-hcl.html

# Prerequisites (most optional):
# pkg-config
# libcppunit
# Net-SNMP
# libusb
# GLib
# libneon >= 0.25.0
# libpowerman
# Avahi
# FreeIPMI
# OpenSSL (for SSL support)
# mozilla-nss (for SSL support; comes with Slack >= 14.0)
# tcp wrappers
# GD (required for --with-cgi)
# AsciiDoc and a2x (found in Slackware's linuxdoc-tools package)
# dblatex (required for --with-doc)
# hotplug
#  and/or udev
#  and/or systemd
# aspell

# Get it
cd
test -f installed/nut-2.7.4.tar.gz &&
mv installed/nut-2.7.4.tar.gz .
test ! -f nut-2.7.4.tar.gz &&
wget http://www.networkupstools.org/source/2.7/nut-2.7.4.tar.gz

# Verify tarball w/ md5sum:
echo "3ba53656933d7471f95140b32a5b8d5c  nut-2.7.4.tar.gz" | md5sum -c

# Verify tarball w/ sha256sum:
echo "980e82918c52d364605c0703a5dcf01f74ad2ef06e3d365949e43b7d406d25a7  nut-2.7.4.tar.gz" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 55CA5976 > /dev/null 2>&1 || gpg --recv-keys 55CA5976 ) &&
wget -nc http://www.networkupstools.org/source/2.7/nut-2.7.4.tar.gz.sig &&
  gpg --verify nut-2.7.4.tar.gz.sig && rm nut-2.7.4.tar.gz.sig

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "nut-*" -exec rm -r {} \;
tar xzvf ~/nut-2.7.4.tar.gz
cd nut-2.7.4
test $UID = 0 && chown -R root:root .

# Under the source tree, read README, INSTALL, and docs/* for more info
# about setting it up, and on the web site, here is the documentation:
# http://www.networkupstools.org/documentation.html

# If upgrading, read ./UPGRADING and after 'make install', you should
# probably look under /usr/local/ups/ for any old files that do not have
# today's date

# If your UPS has a USB monitoring cable, add --with-usb
# If you want SNMP drivers, add --with-snmp
# If you want CGI scripts, add --with-cgi
# If you want NUT development files, add --with-dev (formerly --with-lib)
# If you know what driver your UPS uses (check the Compatibility page on
#  the web site), pass --with-drivers=xxxxx
# If you want a local copy of the docs (also available on the web site), add
#  --with-doc
#
# Read through './configure --help' and docs/configure.txt for more info

# For a Belkin F6C100-UNV that I used to have, which could use a serial
# cable or usbhid-ups with a USB cable:
# ./configure --with-user=ups --with-group=nut # --with-usb --with-cgi --with-ipv6=no # --with-drivers=usbhid-ups,belkinunv

# For a Powercom UPS hooked up via serial cable:
# ./configure --with-user=ups --with-group=nut --with-cgi # --with-drivers=powercom

# For a CyberPower 1500 via USB and an APC Back-UPS Pro via serial:
./configure --with-user=ups --with-group=nut --with-cgi --with-usb --with-drivers=usbhid-ups,apcsmart

# Configure the build
# Two UPSes via USB, one via usbhid-ups, one via apcupsd-ups
./configure --with-user=ups --with-group=nut --with-cgi --with-usb --with-drivers=usbhid-ups,apcupsd-ups

# Build it
make

# Become root to install it
su

# Remove old shared library files before installing the new version
test -d /usr/local/ups/lib &&
( cd /usr/local/ups/lib
   rm -f libupsclient.so.1 libupsclient.so.1.* )

# Install it
make install

# Between versions 2.7.1 and 2.7.4, upsdrvctl moved from bin to sbin, so
# make sure you update any scripts that are set with the old path
test -f /usr/local/ups/bin/upsdrvctl &&
rm -f /usr/local/ups/bin/upsdrvctl

# Add a 'ups' user and 'nut' group, if they don't already exist
# (I use those names only because the docs use those)
getent group | grep "^nut:" > /dev/null 2>&1 || groupadd nut
id ups > /dev/null 2>&1 || useradd -g nut -m ups

# Add /usr/local/ups/bin to PATH, /usr/local/ups/man to MANPATH, add
# /usr/local/ups/pkgconfig to PKG_CONFIG_PATH
cat << EOF > /etc/profile.d/nut.sh
#!/bin/sh
export PATH="\${PATH}:/usr/local/ups/bin"
export MANPATH="\${MANPATH}:/usr/local/ups/share/man"
export PKG_CONFIG_PATH="\${PKG_CONFIG_PATH}:/usr/local/ups/lib/pkgconfig"
EOF
chmod +x /etc/profile.d/nut.sh
. /etc/profile.d/nut.sh

# Now that you can read the man pages, read them.  Run this to
# list which ones are available:
ls -1 /usr/local/ups/share/man/man?/

# Create the directory for UPS status data
mkdir -p /var/state/ups
chmod 0770 /var/state/ups
chown root:nut /var/state/ups

# If you _don't_ use devfs, udev or something else that dynamically
# creates device files, and your UPS is connected to /dev/ttyS1
# (COM1 in DOS/Windows).
chmod 0660 /dev/ttyS0
chown root:nut /dev/ttyS0

# If you use udev, check the scripts/udev/ directory.  You may already
# have one automatically installed as /lib/udev/rules.d/52-nut-usbups.rules
# That udev rules file should handle setting the group owner of the device
# file(s) to be the 'nut' group
#
# To make udev reload it's rules, run '/etc/rc.d/rc.udev reload'
#
# After udev rules have been reloaded, if your UPS is connected via
# a USB cable, unplug and re-plug it

## Create one section per UPS in the configuration file:
## (there's a sample named ups.conf.sample)
## /usr/local/ups/etc/ups.conf
##
## Here's an example for a Belkin F6C100-UNV using a serial cable:
##
#[belkin]
#       driver = belkinunv
#       port = /dev/ttyS0
#       desc = "Belkin F6C100-UNV"
##
## and here is a CyberPower CP1500AVRLCD via USB cable:
##
#[cyberpower]
#        driver = usbhid-ups
#        port = auto
#        desc = "CyberPower CP1500AVRLCD"
##
## If you have multiple USB-based UPSes using the same driver, you'll need
## to use vendor, product, serial, vendorid, productid, and/or bus in
## ups.conf so the driver will know which one it's talking to.  See the
## driver's man page for more info (e.g. 'man usbhid-ups').
##
## When you're done with ups.conf:
chown root:nut /usr/local/ups/etc/ups.conf
chmod 640 /usr/local/ups/etc/ups.conf

# Now start the driver, it will start whatever is configured in ups.conf
/usr/local/ups/sbin/upsdrvctl start

# Now configure upsd, create a /usr/local/ups/etc/upsd.conf,
# you can refer to the upsd.conf.sample in there and read
# 'man upsd.conf'.  Here's a basic example that will set it
# to listen to the localhost address (127.0.0.1) and the IP
# for (in this case) the eth0 interface (192.168.1.2):
#LISTEN 127.0.0.1
#LISTEN 192.168.1.2
#
# When you're done:
chown root:nut /usr/local/ups/etc/upsd.conf
chmod 640 /usr/local/ups/etc/upsd.conf

# For now, create a blank upsd.users
touch /usr/local/ups/etc/upsd.users
chown root:nut /usr/local/ups/etc/upsd.users
chmod 640 /usr/local/ups/etc/upsd.users

# Start upsd:
/usr/local/ups/sbin/upsd

# Make sure it's communicating (OL = on line):
# (e.g.: '/usr/local/ups/bin/upsc belkin ups.status'
/usr/local/ups/bin/upsc upsname_in_ups_dot_conf ups.status

# Dump info from the UPS:
# (e.g.: '/usr/local/ups/bin/upsc belkin')
/usr/local/ups/bin/upsc upsname_in_ups_dot_conf

# Note: if this is an upgrade, allowfrom has been replaced by tcp wrappers
# Now create a upsd user for upsmon to use
# Open up /usr/local/ups/etc/upsd.users
# Put something in there like this:
# [monuser]
#       password = tXR9vCzD
#       upsmon master
# See 'man upsd.users' for more info (and the notes in INSTALL)
# Then, reload upsd:
/usr/local/ups/sbin/upsd -c reload

# Create a blank /usr/local/ups/etc/upsmon.conf
# (so it will be 640 already when you put a password in there)
touch /usr/local/ups/etc/upsmon.conf
chown root:nut /usr/local/ups/etc/upsmon.conf
chmod 640 /usr/local/ups/etc/upsmon.conf
# Read the upsmon and upsmon.conf man pages for more info
# (and the notes in INSTALL)
# Here are some examples that you may want to put in there:
# (typical for a master/local one)
#POWERDOWNFLAG /etc/killpower
#MONITOR upsname_in_ups_dot_conf 1 monuser tXR9vCzD master
#SHUTDOWNCMD "/sbin/shutdown -h +0"

# Start upsmon:
/usr/local/ups/sbin/upsmon

## Add something to /etc/rc.d/rc.local to start upsdrvctl, upsd,
## and upsmon on boot-up.  Here's a basic example:
#if [ -d /usr/local/ups ]; then
#  echo "Starting NUT..."
#  /usr/local/ups/sbin/upsdrvctl start
#  /usr/local/ups/sbin/upsd
#  /usr/local/ups/sbin/upsmon
#fi
## I have a much more complicated rc.nut script here:
## http://englanders.us/pub/linux/misc/rc.nut

# Update /etc/rc.d/rc.6 - rc.0 is a symlink to it, so it will
# take care of both.  Do not use /etc/rc.d/rc.local_shutdown, it
# has to happen later in the shutdown process than things run there would.
# See here:
# http://www.networkupstools.org/docs/user-manual.chunked/ar01s06.html#UPS_shutdown
# for more info about having NUT shut down your machine when the power fails.
# See your specific driver's man page for info specific to your driver/UPS.
# Add something like this after the part that re-mounts filesystems read-only:
#if [ -f /etc/killpower ]; then
#  echo "Killing the power, bye!"
#  /usr/local/ups/sbin/upsdrvctl shutdown
#  sleep 120
#  # Run reboot here?
#fi

# To install the CGIs, first copy them into your cgi-bin directory.
# Wherever it says apachegroup, replace that with whatever Group
# is set to in httpd.conf (usually 'nobody' or 'daemon')
test -d /var/www/cgi-bin &&
( cd /usr/local/ups/cgi-bin
   cp -p *.cgi /var/www/cgi-bin/
   chown root:apache /var/www/cgi-bin/ups*.cgi
   chmod 750 /var/www/cgi-bin/ups*.cgi )
test -d /usr/local/apache2/cgi-bin &&
( cd /usr/local/apache2/cgi-bin
   rm -f upsimage.cgi upsset.cgi upsstats.cgi
   cp -f /usr/local/ups/cgi-bin/*.cgi .
   chown root:apachegroup ups*.cgi
   chmod 750 ups*.cgi )

# If you are installing the CGI scripts, create a hosts.conf,
# upsstats.html, and ups-single.html, then open up hosts.conf
# with a text editor to set the UPS(es) in there:
cd /usr/local/ups/etc
cp hosts.conf.sample hosts.conf
cp upsstats.html.sample upsstats.html
cp upsstats-single.html.sample upsstats-single.html
chown root:apachegroup hosts.conf upsstats.html upsstats-single.html
chmod 640 hosts.conf upsstats.html upsstats-single.html
#
## Here's an example of what one of mine has set in hosts.conf:
#MONITOR belkin "Belkin F6C100-UNV UPS"
#
## Another one might be like this:
#MONITOR powercom@host1.foo.org "UPS connected to host1"
#MONITOR powercom@host1.foo.org "UPS connected to host2"
#
# If you set up hosts.conf to list remote hosts, make sure the one with
# the CGIs installed allows port 3493/tcp out and the other host(s) allows
# 3493/tcp from the one with the CGIs on it.

# Then if all is well, you should be able to go to
# http://yourserver.foo.org/cgi-bin/upsstats.cgi

# You may also want to check out KNutClient if you use KDE
# or Windows NUT client if you're stuck using that OS

# Become yourself again
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/nut-*.tar.*
mv nut-2.7.4.tar.gz installed/


# If you ever want to uninstall NUT, this should do it:
cd
su
test -d src/nut-* && ( cd src/nut-* ; make uninstall )
test -x /etc/rc.d/rc.nut && /etc/rc.d/rc.nut stop
/usr/local/ups/sbin/upsdrvctl stop
sleep 2
killall upsmon upssched
sleep 2
killall -9 upsmon upssched
test -d /usr/local/ups && rm -r /usr/local/ups
rm -f /lib/udev/rules.d/52-nut-usbups.rules
exit
find ~/src -maxdepth 1 -type d -name "nut-*" -exec rm -r {} \;
rm -f ~/installed/nut-*.tar.*

List of HOWTOs

Last updated: 2022-04-15 4:04pm EDT(-0400)
Copyright © 2001-2022 Jason Englander. All Rights reserved.
[HTML5]