From owner-freebsd-mobile@FreeBSD.ORG Wed Jul 17 15:29:28 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1332476B; Wed, 17 Jul 2013 15:29:28 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from land.berklix.org (land.berklix.org [144.76.10.75]) by mx1.freebsd.org (Postfix) with ESMTP id 826F68BC; Wed, 17 Jul 2013 15:29:27 +0000 (UTC) Received: from park.js.berklix.net (pD9FBEF06.dip0.t-ipconnect.de [217.251.239.6]) (authenticated bits=128) by land.berklix.org (8.14.5/8.14.5) with ESMTP id r6HFTPls089574; Wed, 17 Jul 2013 15:29:26 GMT (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (fire.js.berklix.net [192.168.91.41]) by park.js.berklix.net (8.14.3/8.14.3) with ESMTP id r6HFTHjA004066; Wed, 17 Jul 2013 17:29:17 +0200 (CEST) (envelope-from jhs@berklix.com) Received: from fire.js.berklix.net (localhost [127.0.0.1]) by fire.js.berklix.net (8.14.4/8.14.4) with ESMTP id r6HFTBIZ063855; Wed, 17 Jul 2013 17:29:17 +0200 (CEST) (envelope-from jhs@fire.js.berklix.net) Message-Id: <201307171529.r6HFTBIZ063855@fire.js.berklix.net> To: John Baldwin Subject: Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script. From: "Julian H. Stacey" Organization: http://berklix.com BSD Unix Linux Consultancy, Munich Germany User-agent: EXMH on FreeBSD http://berklix.com/free/ X-URL: http://www.berklix.com In-reply-to: Your message "Wed, 10 Jul 2013 14:35:56 EDT." <201307101435.56193.jhb@freebsd.org> Date: Wed, 17 Jul 2013 17:29:11 +0200 Sender: jhs@berklix.com Cc: freebsd-mobile@freebsd.org X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 15:29:28 -0000 Hi, Reference: > From: John Baldwin > Date: Wed, 10 Jul 2013 14:35:56 -0400 John Baldwin wrote: > On Friday, July 05, 2013 6:35:02 pm Julian H. Stacey wrote: > > > 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. > > > > Thanks Jilles, So I appended to my rc.shutdown > > # -x not -f below to also allow a symbolic link to work. > > if [ -x "/etc/rc.shutmedia" ]; then > > /etc/rc.shutmedia > > & renamed my URL to http://www.berklix.com/~jhs/bin/.sh/rc.shutmedia > > > > > > > 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. > > > > > > The incorrect umount order should perhaps be fixed in the kernel. > > > > Yes, bad enough for a local laptop to hang, > > if it was a remote server, very nasty. > > You can just put a script in /usr/local/etc/rc.d. If it has the > 'shutdown' keyword it gets run with a 'stop' command during shutdown. > > (Just grep for "shutdown" in /etc/rc.d to find example scripts) Thanks John, I tried, it works :-) This thread also includes USB shutdowns so I'm cross referencing: http://lists.freebsd.org/pipermail/freebsd-stable/2013-July/074280.html Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultant, Munich http://berklix.com Reply below not above, like a play script. Indent old text with "> ". Send plain text. No quoted-printable, HTML, base64, multipart/alternative.