Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Jul 2013 10:04:47 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        "Julian H. Stacey" <jhs@berklix.com>, freebsd-mobile@freebsd.org
Subject:   Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script.
Message-ID:  <2E491218-DFE8-417D-A41E-5DA27BFC94B3@bsdimp.com>
In-Reply-To: <20130705130452.GB13495@stack.nl>
References:  <201307051252.r65Cq46b046582@fire.js.berklix.net> <20130705130452.GB13495@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jul 5, 2013, at 7:04 AM, Jilles Tjoelker wrote:

> On Fri, Jul 05, 2013 at 02:52:04PM +0200, Julian H. Stacey wrote:
>> Hi mobile@
>> I need ** my laptop to call a script before shutdown,=20
>> (perhaps automaticaly too with something like 'test -e ` etc,
>> though perhaps the default should remain with no test)
>=20
>> I dont see any hooks in man shutdown or halt ? =20
>> I could hack
>> 	/usr/src/sbin/shutdown/shutdown.c	&
>> 	/usr/src/sbin/reboot/reboot.c		# (source of halt)
>> or does someone have a better idea ?
>=20
>> FreeBSD has a mass of scripts etc for system start up, but seems =
light
>> on close down hooks ?  I seem to recall on system 5 there were table
>> entries for up & down for lots of things, (though I never got
>> on with 5, not lots of others here either, & am not advocating that =
route),=20
>> but is there a better way than adding a hook to system("/some_path"); =
?
>=20
>> BTW ** What I'm calling manually before halt is my
>> 	  http://www.berklix.com/~jhs/bin/.sh/umountusb
>> A combo of umounts of USB sticks/disks with plain dos & ufs + also
>> mdconfig -d & gbde detach for encrypted file system on both hard
>> disk & USB sticks.  (When I forget to call it before halt, the
>> laptop hangs on USB.)
>=20
> shutdown(8) signals init (unless -o is given), which will run
> /etc/rc.shutdown from multi-user mode. The same applies to =
ctrl+alt+del,
> kernel-controlled overheating shutdown, etc.
>=20
> reboot(8) and halt(8) do not involve init and do not run any shutdown
> scripts. I think they should be changed to signal init (except reboot
> -q, halt -q) and should not be used until then. However, there are
> apparently some problems with that.

I think so too. fasthalt/fastreboot is what I'd call it, but I've come =
around to thinking that you're right here. It will be a small hassle for =
some people to adapt to the new system, but I think it will be worth it.

> The incorrect umount order should perhaps be fixed in the kernel.

Agreed.

Warner




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2E491218-DFE8-417D-A41E-5DA27BFC94B3>