Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Aug 1998 02:29:31 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        mag@h26.216.elnet.msk.ru (MAG)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Question about shutdown
Message-ID:  <199808120229.TAA05799@usr01.primenet.com>
In-Reply-To: <35D03F68.69837C2A@magc.cd.2573.savbank.ru> from "MAG" at Aug 11, 98 04:56:08 pm

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?

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



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