Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Aug 2001 12:18:23 -0500
From:      Christopher Farley <chris@northernbrewer.com>
To:        "Gary W. Swearingen" <swear@aa.net>
Cc:        Christopher Hall <hsw@acm.org>, questions@FreeBSD.ORG
Subject:   Re: rc.shutdown and SmartUPS
Message-ID:  <20010808121823.A96388@northernbrewer.com>
In-Reply-To: <a6pua6qz7d.ua6@localhost.localdomain>; from swear@aa.net on Wed, Aug 08, 2001 at 09:43:50AM -0700
References:  <chris@northernbrewer.com> <200108080115.f781FnU45606@x4.tucheng.generalresources.com> <20010808013811.A61371@northernbrewer.com> <a6pua6qz7d.ua6@localhost.localdomain>

next in thread | previous in thread | raw e-mail | index | archive | help
Gary W. Swearingen (swear@aa.net) wrote:

> I've been suprised that I've not seen anyone consider this before (when
> I investigated about ten USP programs while using Linux).  Most seemed
> more concerened about having their system get running again unattended.

Shutting the system down cleanly is easy, at least with NUT.
Preparing it to boot up properly upon restoration of power was
decidedly trickier.

At first I thought it would be enough to shut down the computer with a
'shutdown -h now'. Eventually, the batteries on the UPS would die and the 
power to the computer would be cut. My computers are set to reboot once 
the AC power returns.

But what happens in that odd case where the power comes back on after
you've issued the shutdown -h, but before the UPS dies? The computer
just sits there until someone reboots it. 

> I was concerned about the system trying to boot up and shut down while
> the mains power was going on and off while the battery was near dead.
> A small risk, but as I'm not running a server, one I needn't take.

NUT allows you to set the shutdown command to whatever you want. So
if you don't care about it coming back up, you can do a shutdown -h, and
at least your disks will be synced and dismounted properly.

> I still haven't figured how to shutdown properly in FreeBSD as it seems
> more of the shutdown process happens in "init" (as opposed to scripts)
> than in Linux where I could change a script to shut down the UPS after
> the disks are unmounted.   I was planning to write a script to shutdown
> the Linux way.  I'll have to look into the software you're discussing.

NUT is pretty nice, it's under active development, and it supports a
huge variety of UPS devices. There's even cgi scripts that allow you to
monitor the status of your UPS(es) remotely.

I found NUT a bit tricky to configure initially. It requires that you run
three daemons: a driver daemon specific to your UPS; upsd, which
communicates with the driver and authenticates listeners; and upsmon, which 
monitors the status of the UPS and sends out messages if certain events 
occur. Optionally, a forth daemon does logging, which is pretty useful
if you want to see how long it takes for your batteries to dissipate
and recharge...

It took me a while to realize that the driver daemon wants to create a
file in /var/db, and it does not have permissions to do so. The solution
is to 'touch' the file as root, and change the ownership and permissions
as desired. That was about the only major undocumented installation issue.

To shut down the UPS you run the driver with the -k option. It takes a 
few seconds for it to send the shutdown command to the UPS, and then 
another several seconds for the UPS to actually shut down. What I found
disturbing is that after issuing the shutdown command, the driver never
returns. I kind of expected that it would, so you can resume the rest of
the shutdown.

I assume NUT is written for Linux first and foremost, because the
examples given for the shutdown script do not work with FreeBSD.
Running the shutdown command in the background and then sleeping for 2
seconds works for me.

-- 
Christopher Farley
www.northernbrewer.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010808121823.A96388>