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

Daniel O'Connor doconnor at gsoft.com.au
Tue Aug 21 07:53:03 UTC 2007


On Tue, 21 Aug 2007, Bryan wrote:
> 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! ***
>         reboot
> fi

I dunno where you put this but it is almost certainly wrong :)
(Although I doubt it does any actual harm if it's in rc.shutdown)

Modify /usr/local/etc/rc.d/nut so that nut_poststop looks like..
nut_poststop() {
        ${nut_prefix}/libexec/nut/upsdrvctl stop

        if [ -r /etc/killpower ]; then
                rm -f /etc/killpower
                ${nut_prefix}/libexec/nut/upsdrvctl -v shutdown
                if [ $? -ne 0 ]; then
                        ${nut_prefix}/libexec/nut/mge-shut -k -D -a ups1
                fi
                sleep 5
        fi
}

I can't remember why I put the mge-shut thing in there though..

Note that for this you need a decent grace delay on the UPS so the rest of
the system will shut down properly.

Arguably rc.shutdown is a better place for this but it's not very ports
friendly..

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part.
Url : http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20070821/599aa65b/attachment-0001.pgp 


More information about the Nut-upsuser mailing list