Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 1998 11:02:51 -0400 (EDT)
From:      "Bruce M. Walter" <walter@fortean.com>
To:        MAG <mag@h26.216.elnet.msk.ru>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Question about shutdown
Message-ID:  <Pine.BSF.3.96.980811103256.9816A-100000@aries.fortean.com>
In-Reply-To: <35D03F68.69837C2A@magc.cd.2573.savbank.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
> I have written an UPS monitor daemon. But I cannot decide where the
> "Turn the UPS power off" command
> must be (I tryed /etc/rc.shutdown, but the filesystems were improperly
> dismounted, reboot, halt and shutdown
> commands do not call /etc/rc.shutdown, etc...).
>     Who can help me?

I've written one myself as well...  There was a discussion several months
back on hackers regarding this, and the answer is:

Not where you'd think ;)

Actually, to sum up that discussion, there is a flag that gets passed into
reboot (RB_POWEROFF...  see man 2 reboot) which, when received, should
shutdown and poweroff the machine.  There is no built-in kernel support
for this, although I believe the APM stuff interfaces for ATX boards.

My package has a driver component as well as a userland daemon.  On
bootup, the driver installs a callback function (via at_shutdown) which
sends the poweroff signal to the UPS if reboot gets called with
RB_POWEROFF.

If powerfail is detected during boot, it goes into a tight loop (checking
for user intervention) to prevent bootup.  This is what needs to happen
in the case of intermittant power loss.

Once the system boots, the monitor daemon runs and queries the driver for
the UPS status, also making that status available via a TCP port in case
you need to link several systems off a single UPS.

I had submitted patches (kern/5863) which corrected the function of the
halt/reboot -p commands and also prioritized and added a third kernel
callout function list which gets called after all of the other drivers
spin-down stuff is called (namely the DPT driver which uses the second
shutdown callout list to sync the array...  Very bad to poweroff during
that, take my word)  I don't believe any interest was shown, so I just run
the patches here.

Currently I support all of the GenPower cables, APC BackUPS and Pro
devices and a TrippLite or two if IIRC.  My code is languishing due to
lack of interest outside my office, but you're more than welcome to see
what I've got.  It works well here, and I'd love someone else to use it.
The code is at:

ftp://ftp.fortean.com/pub/bupsd/backupsd-1.1.tar.gz

It's still pretty rough package-wise, but once it's built it's solid.

- Bruce

==========================================================
|| Bruce M. Walter         ||   426 South Dawson Street ||
|| Principal               ||   Raleigh, NC 27601 USA   ||
|| NIXdesign Group, Inc.   ||   Tel: 919.829.4908       ||
|| Concept + Code          ||   Fax: 919.829.4993       ||
==========================================================
|| BSD Unix -- It's not just a job, it's a way of life! ||
==========================================================


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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980811103256.9816A-100000>