[Nut-upsuser] FreeBSD rc.d scripts or shutdown howto?

Bryan gruvin at gmail.com
Tue Aug 21 05:07:41 UTC 2007

Thanks again Charles.

On 21/08/07, Charles Lepple <clepple at gmail.com> wrote:
> upsdrvctl doesn't actually communicate with upsd - it simply starts
> and stops drivers directly (and except in the case of shutting down
> the UPS, the drivers then connect to upsd).

A little knowledge goes a long way! :-)

In the end, the problem was the opposite of what I'd thought. Turns
out that 'upsdrvctl shutdown' was failing not because  the ups drivers
had been unloaded, but because they were STILL loaded, and when they
are, an attempt by upsdrvctl to load usbdrv-ups again fails, thus...

# /usr/local/ups/bin/upsdrvctl shutdown
Network UPS Tools - UPS driver controller
Network UPS Tools: 0.28 USB communication driver 0.28 - core 0.30 ()

No matching HID UPS found
Driver failed to start (exit status=1)

This would appear to be a bug. Running 'usbdrv-ups -a <upsname> -k'
reports the same error, of course.

So the fix was simply to force an unload/kill of everything UPS before
forcing the shutdown, thus...

if [ -f /etc/killpower ]; then

        echo "Killing the power, bye!"

        # Do this the manual way.
        /usr/local/ups/sbin/upsd -c stop
        /usr/bin/killall usbhid-ups
        sleep 2
        # this needs to get deleted me thinks!
        rm -f /etc/killpower
        /usr/local/ups/bin/usbhid-ups -a mge600 -k

        sleep 120

        # uh oh... the UPS power-off failed
        # you probably want to reboot here so you don't get stuck!
        # *** see the section on power races in shutdown.txt! ***

I used 'usbhid-ups -a mge600 -k' instead of 'upsdrvctl shutdown', but
in fact either works. I just figured I'd remove a variable from the
mix and go straight for the UPS's throat, so-to-speak. :-)

That code is right at the end of rc.shutdown (well almost) and works
perfectly. Yeh! :-P Not bad for a whole day's work! *grin*


More information about the Nut-upsuser mailing list