From owner-freebsd-hackers Tue Aug 11 19:30:13 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA28883 for freebsd-hackers-outgoing; Tue, 11 Aug 1998 19:30:13 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA28794 for ; Tue, 11 Aug 1998 19:30:05 -0700 (PDT) (envelope-from tlambert@usr01.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id TAA07017; Tue, 11 Aug 1998 19:29:40 -0700 (MST) Received: from usr01.primenet.com(206.165.6.201) via SMTP by smtp01.primenet.com, id smtpd006996; Tue Aug 11 19:29:34 1998 Received: (from tlambert@localhost) by usr01.primenet.com (8.8.5/8.8.5) id TAA05799; Tue, 11 Aug 1998 19:29:31 -0700 (MST) From: Terry Lambert Message-Id: <199808120229.TAA05799@usr01.primenet.com> Subject: Re: Question about shutdown To: mag@h26.216.elnet.msk.ru (MAG) Date: Wed, 12 Aug 1998 02:29:31 +0000 (GMT) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <35D03F68.69837C2A@magc.cd.2573.savbank.ru> from "MAG" at Aug 11, 98 04:56:08 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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? The correct place is the kernel, unless you have a time delay. For UPS's designed to work with user space daemons, there is typically a time argument, ie: "PWROFF 60" -- shut off power 60 seconds after I give you this command. One way to fake the kernel doing the job at the right time in rc.shutdown: 1) Shutdown all the processes, like shutdown will want to do anyway. 2) Unmount all the FS's except /. 3) remount / as read-only 4) sync the crap out of things (in fact, 3 sync's are required as of the soft updates code, since the dependency graph can be three deep; it may also be worthwhile to wait 40 seconds to allow the syncd to empty the soft clocked I/O queue). 5) Power the ups off. Only FS's mounted read/write will be dirty (which should mean "none of them"). NB: Your ups control code will have to live in /sbin or /bin, since /usr was unmounted. You may also have to modify shutdown to refuse to shutdown if your cwd is not root, since your shell may hold an FS open otherwise (standard unmount is not as forceful as the shutdown, which will give up attempting to write after a while, and simply discard dirty buffers). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message