From owner-freebsd-hackers Tue Aug 11 08:05:37 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA14756 for freebsd-hackers-outgoing; Tue, 11 Aug 1998 08:05:37 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from aries.fortean.com (aries.fortean.com [209.42.229.210]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA14625 for ; Tue, 11 Aug 1998 08:04:40 -0700 (PDT) (envelope-from walter@fortean.com) Received: from localhost (walter@localhost) by aries.fortean.com (8.8.8/8.8.8) with SMTP id LAA10281; Tue, 11 Aug 1998 11:02:52 -0400 (EDT) (envelope-from walter@fortean.com) X-Authentication-Warning: aries.fortean.com: walter owned process doing -bs Date: Tue, 11 Aug 1998 11:02:51 -0400 (EDT) From: "Bruce M. Walter" To: MAG cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Question about shutdown In-Reply-To: <35D03F68.69837C2A@magc.cd.2573.savbank.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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